spec/macros4cuke/macro-step_spec.rb in macros4cuke-0.3.25 vs spec/macros4cuke/macro-step_spec.rb in macros4cuke-0.3.26

- old
+ new

@@ -28,39 +28,39 @@ subject { MacroStep.new(sample_phrase, sample_template, true) } context 'Creation & initialization:' do it 'should be created with a phrase, substeps and a table use indicator' do - ->(){ MacroStep.new(sample_phrase, sample_template, true) }.should_not raise_error + expect { MacroStep.new(sample_phrase, sample_template, true) }.not_to raise_error end it 'should complain when a sub-step argument can never be assigned a value via the phrase' do msg = "The sub-step argument 'password' does not appear in the phrase." - ->(){ MacroStep.new(sample_phrase, sample_template, false) }.should raise_error( + expect { MacroStep.new(sample_phrase, sample_template, false) }.to raise_error( Macros4Cuke::UnreachableSubstepArgument, msg) end it 'should complain when an argument in phrase never occurs in substeps' do phrase = 'enter my credentials as <foobar>' msg = "The phrase argument 'foobar' does not appear in a sub-step." - ->(){ MacroStep.new(phrase, sample_template, true) }.should raise_error( + expect { MacroStep.new(phrase, sample_template, true) }.to raise_error( Macros4Cuke::UselessPhraseArgument, msg) end it 'should know its key' do - subject.key.should == 'enter_my_credentials_as_X_T' + expect(subject.key).to eq('enter_my_credentials_as_X_T') end it 'should know the tags(placeholders) from its phrase' do - subject.phrase_args.should == %w[userid] + expect(subject.phrase_args).to eq(%w[userid]) end it 'should know the tags(placeholders) from its phrase and template' do - subject.args.should == %w[userid password] + expect(subject.args).to eq(%w[userid password]) end end # context @@ -75,11 +75,11 @@ And I fill in "Username" with "nobody" And I fill in "Password" with "no-secret" And I click "Submit" SNIPPET - text.should == expectation + expect(text).to eq(expectation) end it 'should render steps even when one argument has no actual value' do # Special case: password has no value... text = subject.expand(phrase_instance, [ ]) @@ -89,11 +89,11 @@ And I fill in "Username" with "nobody" And I fill in "Password" with "" And I click "Submit" SNIPPET - text.should == expectation + expect(text).to eq(expectation) end it 'should un-escape the double-quotes for phrase arguments' do specific_phrase = %q|enter my credentials as "quotable\""| text = subject.expand(specific_phrase, [ %w(password no-secret) ]) @@ -103,29 +103,29 @@ And I fill in "Username" with "quotable"" And I fill in "Password" with "no-secret" And I click "Submit" SNIPPET - text.should == expectation + expect(text).to eq(expectation) end it 'should complain when an unknown variable is used' do # Error case: there is no macro argument called <unknown> error_message = "Unknown macro-step argument 'unknown'." args = [ %w(unknown anything) ] - ->(){ subject.expand(phrase_instance, args) }.should raise_error( + expect { subject.expand(phrase_instance, args) }.to raise_error( UnknownArgumentError, error_message) end - - + + it 'should complain when argument gets a value from phrase and table' do # Error case: there is no macro argument called <unknown> phrase = %Q|enter my credentials as "nobody"| msg = "The macro argument 'userid' has value 'nobody' and 'valueTable'." args = [ %w(userid someone), %w(password no-secret) ] - ->(){ subject.expand(phrase, args) }.should raise_error( + expect { subject.expand(phrase, args) }.to raise_error( AmbiguousArgumentValue, msg) end it 'should expand built-in variables' do @@ -136,16 +136,16 @@ London Paris San Francisco <quotes> SNIPPET - + instance = MacroStep.new(phrase, substeps, true) actual = instance.expand(phrase, []) expected = substeps.gsub(/<quotes>/, '"""') - actual.should == expected + expect(actual).to eq(expected) end - + end # context end # describe \ No newline at end of file