File: step_definition.rb

package info (click to toggle)
ruby-cucumber-wire 8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 140 kB
  • sloc: ruby: 499; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
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
# frozen_string_literal: true

require 'cucumber/core/test/location'

module Cucumber
  module Wire
    class StepDefinition
      attr_reader :id, :regexp_source, :location, :registry, :expression

      def initialize(connection, data, registry)
        @connection = connection
        @registry = registry
        @id = data['id']
        @regexp_source = begin
          Regexp.new(data['regexp'])
        rescue StandardError
          data['regexp'] || 'Unknown'
        end
        @expression = registry.create_expression(@regexp_source)
        @location = Core::Test::Location.from_file_colon_line(data['source'] || 'unknown:0')
      end

      def invoke(args)
        @connection.invoke(@id, args)
      end
    end
  end
end