Sha256: 6da8dd56b4772cb445bc31a4e42c2c861b17d80209aae793a6f2ba1534125edb

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'yaml'
require 'cucumber/cucumber_expressions/cucumber_expression'
require 'cucumber/cucumber_expressions/parameter_type_registry'

module Cucumber
  module CucumberExpressions
    describe CucumberExpression do
      Dir['../testdata/cucumber-expression/transformation/*.yaml'].each do |path|
        expectation = YAML.load_file(path)
        it "transforms #{path}" do
          parameter_registry = ParameterTypeRegistry.new
          if expectation['exception']
            expect {
              cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
              cucumber_expression.match(expectation['text'])
            }.to raise_error(expectation['exception'])
          else
            cucumber_expression = CucumberExpression.new(expectation['expression'], parameter_registry)
            matches = cucumber_expression.match(expectation['text'])
            values = matches.nil? ? nil : matches.map { |arg| arg.value(nil) }
            expect(values).to eq(expectation['expected_args'])
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-cucumber-expressions-17.0.1/spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
cucumber-cucumber-expressions-17.0.1 spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb
cucumber-cucumber-expressions-17.0.0 spec/cucumber/cucumber_expressions/cucumber_expression_transformation_spec.rb