File: snippet.rb

package info (click to toggle)
ruby-cucumber-wire 0.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 754; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Cucumber
  module Wire
    module Snippet
      class Generator
        def initialize(connections)
          # This array is shared mutable state with the wire language.
          @connections = connections
        end

        def call(code_keyword, step_name, multiline_arg, snippet_type)
          @connections.snippets(code_keyword, step_name, MultilineArgClassName.new(multiline_arg).to_s).join("\n")
        end

        class MultilineArgClassName
          def initialize(arg)
            arg.describe_to(self)
            @result = ""
          end

          def data_table(*)
            @result = "Cucumber::MultilineArgument::DataTable"
          end

          def doc_string(*)
            @result = "Cucumber::MultilineArgument::DocString"
          end

          def to_s
            @result
          end
        end
      end
    end
  end
end