Sha256: a7ac7ea4e499bfaf0f56aae77d40c6cdccfe50e03dff3bfe54daf31db217be01

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

require_relative 'cucumber_helper'

describe Cucumber::Runtime, 'extended with cucumber_priority' do

  before(:each) do
    prepare_cucumber_example
  end

  describe '#step_matches' do

    it 'returns an overriding step if the only other match is a overridable step' do
      overridable_step = @main.Given(/^there is a movie with a (.*?) tone$/){ }.overridable
      overriding_step = @main.Given(/^there is a movie with a funny tone$/){ }
      match = first_step_match('there is a movie with a funny tone')
      match.step_definition.should == overriding_step
      match.should be_a(Cucumber::StepMatch)
    end

    it 'raises Cucumber::Ambiguous if more than two overriding steps match' do
      @main.Given(/^there is a movie with (.*?) tone$/){}.overridable(:priority => 1000)
      @main.Given(/^there is a movie with a [^ ]+ tone$/){}
      @main.Given(/^there is a movie with a funny tone$/){}
      expect do
        first_step_match('there is a movie with a funny tone')
      end.to raise_error(Cucumber::Ambiguous)
    end

    it 'returns the overridable step with the highest priority if no overriding steps match' do
      overridable_step = @main.Given(/^there is a movie with a (.*?) tone$/){ }.overridable
      higher_overridable_step = @main.Given(/^there is a movie with a [^ ]+ tone$/){ }.overridable(:priority => 5)
      lower_overridable_step = @main.Given(/^there is a movie with a [^ ]+ tone$/){ }.overridable(:priority => -5)
      match = first_step_match('there is a movie with a funny tone')
      match.step_definition.should == higher_overridable_step
      match.should be_a(Cucumber::StepMatch)
    end
    
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber_priority-0.1.2 spec/cucumber_priority/support_code_ext_spec.rb