File: connections.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 (50 lines) | stat: -rw-r--r-- 1,345 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'multi_json'
require 'socket'
require 'cucumber/wire/connection'
require 'cucumber/wire/configuration'
require 'cucumber/wire/data_packet'
require 'cucumber/wire/exception'
require 'cucumber/wire/step_definition'
require 'cucumber/wire/snippet'
require 'cucumber/configuration'
require 'cucumber/step_match'

module Cucumber
  module Wire

    class Connections
      attr_reader :connections
      private :connections

      def initialize(connections, configuration)
        raise ArgumentError unless connections
        @connections = connections
        @configuration = configuration
      end

      def find_match(test_step)
        matches = step_matches(test_step.name)
        return unless matches.any?
        # TODO: handle ambiguous matches (push to cucumber?)
        matches.first
      end

      def step_matches(step_name)
        connections.map{ |c| c.step_matches(step_name)}.flatten
      end

      def begin_scenario(test_case)
        connections.each { |c| c.begin_scenario(test_case) }
      end

      def end_scenario(test_case)
        connections.each { |c| c.end_scenario(test_case) }
      end

      def snippets(code_keyword, step_name, multiline_arg_class_name)
        connections.map { |c| c.snippet_text(code_keyword, step_name, multiline_arg_class_name) }.flatten
      end

    end
  end
end