From 5ce589f35d840e043e3303c3390e504be72b8e57 Mon Sep 17 00:00:00 2001 From: Sean Caffery Date: Sun, 9 Oct 2016 16:57:39 +1100 Subject: [PATCH] Fix deprecation warnings --- spec/lib/stepdown/analyzer_spec.rb | 40 ++++++------- spec/lib/stepdown/bluff_graph_spec.rb | 6 +- spec/lib/stepdown/feature_parser_spec.rb | 22 ++++--- spec/lib/stepdown/graph_spec.rb | 14 ++--- spec/lib/stepdown/options_spec.rb | 39 ++++++------ spec/lib/stepdown/scenario_spec.rb | 6 +- spec/lib/stepdown/statistics_spec.rb | 73 +++++++++++------------ spec/lib/stepdown/step_collection_spec.rb | 26 ++++---- spec/lib/stepdown/step_group_spec.rb | 10 ++-- spec/lib/stepdown/step_instance_spec.rb | 25 ++++---- 10 files changed, 127 insertions(+), 134 deletions(-) diff --git a/spec/lib/stepdown/analyzer_spec.rb b/spec/lib/stepdown/analyzer_spec.rb index d026bf3..d304175 100644 --- a/spec/lib/stepdown/analyzer_spec.rb +++ b/spec/lib/stepdown/analyzer_spec.rb @@ -16,17 +16,17 @@ it "should return an HTML reporter" do reporter = @analyzer.reporter('html', double('stats')) - reporter.should be_instance_of(Stepdown::HTMLReporter) + expect(reporter).to be_instance_of(Stepdown::HTMLReporter) end it "should return a text reporter" do reporter = @analyzer.reporter('text', double('stats')) - reporter.should be_instance_of(Stepdown::TextReporter) + expect(reporter).to be_instance_of(Stepdown::TextReporter) end it "should return a quiet reporter" do reporter = @analyzer.reporter('quiet', double('stats')) - reporter.should be_instance_of(Stepdown::Reporter) + expect(reporter).to be_instance_of(Stepdown::Reporter) end end @@ -37,32 +37,32 @@ instance = double('instance', :step_collection => []) reporter = double('reporter') stats = double('stats') - reporter.should_receive(:output_overview) + expect(reporter).to receive(:output_overview) - @analyzer.should_receive(:instance).and_return(instance) - @analyzer.should_receive(:feature_files).and_return(features) - @analyzer.should_receive(:process_feature_files).with(features).and_return([]) - @analyzer.should_receive(:reporter).and_return(reporter) - stats.should_receive(:generate) - - Stepdown::Statistics.stub(:new).with([], instance.step_collection).and_return(stats) - Stepdown::YamlWriter.should_receive(:write).with(anything) - Stepdown::FlotGraph.should_receive(:create_graph) + expect(@analyzer).to receive(:instance).and_return(instance) + expect(@analyzer).to receive(:feature_files).and_return(features) + expect(@analyzer).to receive(:process_feature_files).with(features).and_return([]) + expect(@analyzer).to receive(:reporter).and_return(reporter) + expect(stats).to receive(:generate) + + allow(Stepdown::Statistics).to receive(:new).with([], instance.step_collection).and_return(stats) + expect(Stepdown::YamlWriter).to receive(:write).with(anything) + expect(Stepdown::FlotGraph).to receive(:create_graph) @analyzer.analyze end end - + describe "#process_feature_files" do it "should instantiate a bunch of stuff" do double_listener = double(:listener) - @analyzer.stub(:instance) - Stepdown::FeatureParser.should_receive(:new).with(anything).and_return(double_listener) + allow(@analyzer).to receive(:instance) + expect(Stepdown::FeatureParser).to receive(:new).with(anything).and_return(double_listener) double_parser = double(:gherkin_parser) - Gherkin::Parser::Parser.should_receive(:new).and_return(double_parser) - File.stub(:read) - double_parser.should_receive(:parse) - double_listener.should_receive(:scenarios) + expect(Gherkin::Parser::Parser).to receive(:new).and_return(double_parser) + allow(File).to receive(:read) + expect(double_parser).to receive(:parse) + expect(double_listener).to receive(:scenarios) @analyzer.process_feature_files(["blah.txt"]) end end diff --git a/spec/lib/stepdown/bluff_graph_spec.rb b/spec/lib/stepdown/bluff_graph_spec.rb index 20193ca..c4a85c2 100644 --- a/spec/lib/stepdown/bluff_graph_spec.rb +++ b/spec/lib/stepdown/bluff_graph_spec.rb @@ -17,9 +17,9 @@ require 'stringio' io = StringIO.new - File.stub(:open).with(anything, anything).and_yield(io) + allow(File).to receive(:open).with(anything, anything).and_yield(io) - Stepdown::BluffGraph.should_receive(:collect_stats).and_return([stats, labels]) + expect(Stepdown::BluffGraph).to receive(:collect_stats).and_return([stats, labels]) stub_const("Stepdown::BluffGraph::BLUFF_DEFAULT_OPTIONS", "DEFAULT") expected_graph = <<-GRAPH DEFAULT @@ -31,7 +31,7 @@ g.labels = {"0":"12 / 6"}; g.draw(); GRAPH - Stepdown::BluffGraph.create_graph.string.should == expected_graph + expect(Stepdown::BluffGraph.create_graph.string).to eq expected_graph end end diff --git a/spec/lib/stepdown/feature_parser_spec.rb b/spec/lib/stepdown/feature_parser_spec.rb index cf0db99..d0abac5 100644 --- a/spec/lib/stepdown/feature_parser_spec.rb +++ b/spec/lib/stepdown/feature_parser_spec.rb @@ -4,7 +4,7 @@ describe Stepdown::FeatureParser do def stub_line_match_with(instance, line, value) - instance.stub(:line_matches).with(line).and_return(value) + allow(instance).to receive(:line_matches).with(line).and_return(value) end describe "creating scenarios" do @@ -16,28 +16,28 @@ def stub_line_match_with(instance, line, value) it "should create a scenario for a scenario line" do scenario = double("scenario", :name => 'scenario') - Stepdown::Scenario.should_receive(:new).and_return(scenario) + expect(Stepdown::Scenario).to receive(:new).and_return(scenario) @parser.scenario(scenario) - @parser.scenarios.should =~ [scenario] + expect(@parser.scenarios).to match [scenario] end it "should create a scenario for a background line" do background = double("background", :name => '') - Stepdown::Scenario.should_receive(:new).and_return(background) + expect(Stepdown::Scenario).to receive(:new).and_return(background) @parser.background(background) - @parser.scenarios.should =~ [background] + expect(@parser.scenarios).to match [background] end it "should create a scenario for a scenario outline" do outline = double("outline", :name => 'outline') - Stepdown::Scenario.should_receive(:new).and_return(outline) + expect(Stepdown::Scenario).to receive(:new).and_return(outline) @parser.scenario_outline(outline) - @parser.scenarios.should =~ [outline] + expect(@parser.scenarios).to match [outline] end end @@ -47,7 +47,6 @@ def stub_line_match_with(instance, line, value) @step_instance = double("step_instance") @parser = Stepdown::FeatureParser.new(@step_instance) @parser.scenario(double('scenario', :name => 'scenario')) - end it "should not add unmatched steps" do @@ -59,7 +58,7 @@ def stub_line_match_with(instance, line, value) stub_line_match_with(@step_instance, line, step) steps << step end - + unmatched_lines.each do |line| stub_line_match_with(@step_instance, line, nil) end @@ -71,7 +70,7 @@ def stub_line_match_with(instance, line, value) end scenarios = @parser.scenarios - scenarios.first.steps.collect{|s| s.regex }.should =~ ["matched", "match 2"] + expect(scenarios.first.steps.collect{|s| s.regex }).to match ["matched", "match 2"] end it "should add matched steps" do @@ -85,8 +84,7 @@ def stub_line_match_with(instance, line, value) end scenarios = @parser.scenarios - scenarios.first.steps.collect{|s| s.regex }.should =~ ["matched", "match 2"] - + expect(scenarios.first.steps.collect{|s| s.regex }).to match ["matched", "match 2"] end end diff --git a/spec/lib/stepdown/graph_spec.rb b/spec/lib/stepdown/graph_spec.rb index 3e98ab1..acedf2b 100644 --- a/spec/lib/stepdown/graph_spec.rb +++ b/spec/lib/stepdown/graph_spec.rb @@ -16,24 +16,24 @@ class DummyGraph before :each do stats = [{:no_scen => 10, :unused => 2, :label => "label 1"}, {:no_scen => 20, :unused => 3, :label => "label 2"}] - @fixture.stub(:load_stats).and_return(stats) + allow(@fixture).to receive(:load_stats).and_return(stats) end it "should return the labels associated with a stat set" do - @fixture.collect_stats[1].should == ["label 1", "label 2"] + expect(@fixture.collect_stats[1]).to eq ["label 1", "label 2"] end it "should break collect group stats based on given keys" do - @fixture.collect_stats[0].should == {:no_scen=>[10, 20], + expect(@fixture.collect_stats[0]).to eq({:no_scen=>[10, 20], :unused=>[2, 3], - :label=>["label 1", "label 2"]} + :label=>["label 1", "label 2"]}) end end describe "creating a label from a file name" do it "should return day/month" do - @fixture.date_from_file_name("20110512.yml").should == "12/5" + expect(@fixture.date_from_file_name("20110512.yml")).to eq "12/5" end end @@ -41,7 +41,7 @@ class DummyGraph it "should load correctly" do Stepdown.output_directory = File.dirname(__FILE__) + '/../../fixtures' stats = @fixture.load_stats - stats.should == [{:number_scenarios=>[685], + expect(stats).to eq [{:number_scenarios=>[685], :total_steps=>[531], :steps_per_scenario=>["12.91"], :label=>"11/6", @@ -52,7 +52,7 @@ class DummyGraph :label=>"12/6", :unused_steps=>[123]}] - stats.length.should == 2 + expect(stats.length).to eq 2 end end diff --git a/spec/lib/stepdown/options_spec.rb b/spec/lib/stepdown/options_spec.rb index e48e8c5..5e11287 100644 --- a/spec/lib/stepdown/options_spec.rb +++ b/spec/lib/stepdown/options_spec.rb @@ -11,23 +11,22 @@ it "should allow setting only steps directory" do @options.parse(["--steps=step_dir"]) - @options.steps_dir.should == "step_dir" - @options.features_dir.should == "features" - + expect(@options.steps_dir).to eq "step_dir" + expect(@options.features_dir).to eq "features" end it "should allow setting only features directory" do @options.parse(["--features=features_dir"]) - @options.steps_dir.should == "features/step_definitions" - @options.features_dir.should == "features_dir" + expect(@options.steps_dir).to eq "features/step_definitions" + expect(@options.features_dir).to eq "features_dir" end it "should allow setting features and settings directory" do @options.parse(["--features=features_dir", "--steps=steps_dir"]) - @options.steps_dir.should == "steps_dir" - @options.features_dir.should == "features_dir" + expect(@options.steps_dir).to eq "steps_dir" + expect(@options.features_dir).to eq "features_dir" end end @@ -35,19 +34,19 @@ it "should select html by default" do @options.parse([]) - @options.reporter.should == "html" + expect(@options.reporter).to eq "html" end it "should allow selecting html" do @options.parse(["--output=html"]) - @options.reporter.should == "html" + expect(@options.reporter).to eq "html" end it "should allow selecting text" do @options.parse(["--output=text"]) - @options.reporter.should == "text" + expect(@options.reporter).to eq "text" end end @@ -55,42 +54,42 @@ it "should select relative step directory" do @options.parse([]) - @options.steps_dir == "features/step_definitions" + expect(@options.steps_dir).to eq "features/step_definitions" end it "should select relative feature directory" do @options.parse([]) - @options.features_dir.should == "features" + expect(@options.features_dir).to eq "features" end end describe "validating options" do require 'stringio' before :each do - Dir.stub(:pwd).and_return("") + allow(Dir).to receive(:pwd).and_return("") @io = StringIO.new end it "should report an invalid steps directory" do @options.parse(["--steps=steps_dir"]) - lambda do + expect do @options.validate(@io) - @io.string.should == "Directory steps_dir does not exist" - end.should raise_error(SystemExit) + expect(@io.string).to eq "Directory steps_dir does not exist" + end.to raise_error(SystemExit) end it "should report an invalid features directory" do @options.parse(["--features=features_dir"]) - lambda do + expect do @options.validate(@io) - @io.string.should == "Directory features_dir does not exist" - end.should raise_error(SystemExit) + expect(@io.string).to eq "Directory features_dir does not exist" + end.to raise_error(SystemExit) end it "should allow output to be supressed" do @options.parse(["-q"]) - @options.quiet.should == true + expect(@options.quiet).to be true end end diff --git a/spec/lib/stepdown/scenario_spec.rb b/spec/lib/stepdown/scenario_spec.rb index b04777c..c7e662f 100644 --- a/spec/lib/stepdown/scenario_spec.rb +++ b/spec/lib/stepdown/scenario_spec.rb @@ -23,15 +23,15 @@ it "should add steps to cache" do steps = [@s1, @s2, @s3] - @scenario.steps.should =~ steps + expect(@scenario.steps).to match steps end it "should return the total number of steps" do - @scenario.step_count.should == 4 + expect(@scenario.step_count).to eq 4 end it "should return the number of unique steps" do - @scenario.unique_step_count.should == 3 + expect(@scenario.unique_step_count).to eq 3 end end diff --git a/spec/lib/stepdown/statistics_spec.rb b/spec/lib/stepdown/statistics_spec.rb index fb788c2..2fdb89c 100644 --- a/spec/lib/stepdown/statistics_spec.rb +++ b/spec/lib/stepdown/statistics_spec.rb @@ -10,13 +10,13 @@ it "should return the total number of steps" do steps = [double('step_1'), double('step_2')] reporter = Stepdown::Statistics.new([], steps) - reporter.total_steps.should == 2 + expect(reporter.total_steps).to eq 2 end it "should return the total number of scenarios" do scenarios = [double('scenario_1'), double('scenario_2')] reporter = Stepdown::Statistics.new(scenarios, []) - reporter.total_scenarios.should == 2 + expect(reporter.total_scenarios).to eq 2 end it "should return the number of steps per scenario" do @@ -25,7 +25,7 @@ scenario2 = double("scenario2", :steps => [], :step_count => 0) reporter = Stepdown::Statistics.new([scenario1, scenario2], []) - reporter.steps_per_scenario.should == "1.50" + expect(reporter.steps_per_scenario).to eq "1.50" end it "should return the number of unique steps per scenario" do @@ -34,7 +34,7 @@ scenario2 = double("scenario2", :steps => steps[0...1], :unique_step_count => 1, :step_count => 1) reporter = Stepdown::Statistics.new([scenario1, scenario2], []) - reporter.unique_steps.should == "1.33" + expect(reporter.unique_steps).to eq "1.33" end end @@ -74,26 +74,25 @@ it "should return the correct step grouping" do reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection) - reporter.groupings[0].step_collection.should =~ [@s1,@s2,@s3,@s4,@s5] - reporter.groupings[1].step_collection.should =~ [@s1,@s2,@s3,@s4,@s5] - reporter.groupings[2].step_collection.should =~ [@s1,@s2,@s3,@s4] - reporter.groupings[3].step_collection.should =~ [@s1,@s2,@s3,@s4] - reporter.groupings[4].step_collection.should =~ [@s1,@s2,@s5] - + expect(reporter.groupings[0].step_collection).to eq [@s1,@s2,@s3,@s4,@s5] + expect(reporter.groupings[1].step_collection).to eq [@s1,@s2,@s3,@s4,@s5] + expect(reporter.groupings[2].step_collection).to eq [@s1,@s2,@s3,@s4] + expect(reporter.groupings[3].step_collection).to eq [@s1,@s2,@s3,@s4] + expect(reporter.groupings[4].step_collection).to eq [@s1,@s2,@s5] end it "should return usage for steps across scenarios" do reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection) group_1 = reporter.groupings.detect{|g| g.id == 1} - group_1.use_count.should == 8 + expect(group_1.use_count).to eq 8 end it "should return usage for steps in scenarios with duplicated steps" do reporter = Stepdown::Statistics.new([@scen_1, @scen_2], @collection) group_5 = reporter.groupings.detect{|g| g.id == 5} - group_5.use_count.should == 4 + expect(group_5.use_count).to eq 4 end end @@ -134,27 +133,27 @@ reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection) usage = reporter.usages.detect{|use| use.step.id == 1} - usage.total_usage.should == 3 - usage.number_scenarios.should == 2 - usage.use_scenario.should == "1.50" - end + expect(usage.total_usage).to eq 3 + expect(usage.number_scenarios).to eq 2 + expect(usage.use_scenario).to eq "1.50" + end it "should return duplicate usage of a step in a scenario" do reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection) usage = reporter.usages.detect{|use| use.step.id == 5} - usage.total_usage.should == 2 - usage.number_scenarios.should == 1 - usage.use_scenario.should == "2.00" + expect(usage.total_usage).to eq 2 + expect(usage.number_scenarios).to eq 1 + expect(usage.use_scenario).to eq "2.00" end it "should return usage of a step in a scenario" do reporter = Stepdown::Statistics.new([@scen_2, @scen_1], @collection) usage = reporter.usages.detect{|use| use.step.id == 3} - usage.total_usage.should == 1 - usage.number_scenarios.should == 1 - usage.use_scenario.should == "1.00" + expect(usage.total_usage).to eq 1 + expect(usage.number_scenarios).to eq 1 + expect(usage.use_scenario).to eq "1.00" end end @@ -170,19 +169,19 @@ @use_1.total_usage += 1 @use_2.total_usage += 1 - @reporter.stub(:step_usages).and_return([@use_1, @use_2, @use_3]) + allow(@reporter).to receive(:step_usages).and_return([@use_1, @use_2, @use_3]) end it "should return used steps" do - @reporter.usages.should =~ [@use_1, @use_2] + expect(@reporter.usages).to match [@use_1, @use_2] end it "should return unused steps" do - @reporter.unused.should =~ [@use_3] + expect(@reporter.unused).to match [@use_3] end it "should return the number of unused steps" do - @reporter.unused_step_count.should == 1 + expect(@reporter.unused_step_count).to eq 1 end end @@ -194,7 +193,7 @@ @reporter = Stepdown::Statistics.new([scen_1, scen_2], Stepdown::StepCollection.new) - @reporter.empty().should == [scen_1,scen_2] + expect(@reporter.empty).to eq [scen_1,scen_2] end it "should not return scenarios with steps" do @@ -205,7 +204,7 @@ @reporter = Stepdown::Statistics.new([scen_1, scen_2], Stepdown::StepCollection.new) - @reporter.empty().should == [scen_2] + expect(@reporter.empty).to eq [scen_2] end end @@ -218,26 +217,26 @@ @stats = Stepdown::Statistics.new([], double('step_collection')) end - methods = ["groupings", "usages", "empty", "unused"] + methods = ["groupings", "usages", "empty", "unused"] methods.each do |method| - it "should return the top 10 #{method}" do - @stats.should_receive(method.to_sym).and_return(@all) - @stats.send("#{method}_top".to_sym).should eql @top_10 + it "should return the top 10 #{method}" do + expect(@stats).to receive(method.to_sym).and_return(@all) + expect(@stats.send("#{method}_top".to_sym)).to eql @top_10 end end - + methods.each do |method| it "should return the rest of #{method}" do - @stats.stub(method.to_sym).and_return(@all) - @stats.send("#{method}_rest".to_sym).should eql @rest + allow(@stats).to receive(method.to_sym).and_return(@all) + expect(@stats.send("#{method}_rest".to_sym)).to eql @rest end end methods.each do |method| it "should not break if there are not enough elements for a requested collection" do - @stats.stub(method.to_sym).and_return([]) - @stats.send("#{method}_rest".to_sym).should be_empty + allow(@stats).to receive(method.to_sym).and_return([]) + expect(@stats.send("#{method}_rest".to_sym)).to be_empty end end diff --git a/spec/lib/stepdown/step_collection_spec.rb b/spec/lib/stepdown/step_collection_spec.rb index c7ae89f..284799b 100644 --- a/spec/lib/stepdown/step_collection_spec.rb +++ b/spec/lib/stepdown/step_collection_spec.rb @@ -9,7 +9,7 @@ end it "should return an empty hash when for an empty group" do - @collection.steps.should be_empty + expect(@collection.steps).to be_empty end it "should return the current steps in the group" do @@ -17,7 +17,7 @@ @collection.add_step(2,/regex 2/) @collection.add_step(3,/regex 3/) - @collection.steps.collect{|s| s.regex }.should =~ [/regex 1/,/regex 2/,/regex 3/] + expect(@collection.steps.collect{|s| s.regex }).to match [/regex 1/,/regex 2/,/regex 3/] end describe "adding a step to the step group" do @@ -27,11 +27,10 @@ it "should add new steps" do step = double("step") - Stepdown::Step.stub(:new).and_return(step) - step.should_receive(:count=).with(1) + allow(Stepdown::Step).to receive(:new).and_return(step) + expect(step).to receive(:count=).with(1) @collection.add_step(1, /regex/) - @collection.steps.should == [step] - + expect(@collection.steps).to eq [step] end it "should update the count for an existing step" do @@ -39,7 +38,7 @@ @collection.add_step(1,/regex/) @collection.add_step(1,/regex/) - @collection.steps[0].count.should == 2 + expect(@collection.steps[0].count).to eq 2 end it "should update step counts when multiple steps present" do @@ -52,10 +51,9 @@ @collection.add_step(3,/regex/) @collection.add_step(3,/regex/) - @collection.steps.detect{|s| s.id == 1}.count.should == 2 - @collection.steps.detect{|s| s.id == 2}.count.should == 1 - @collection.steps.detect{|s| s.id == 3}.count.should == 3 - + expect(@collection.steps.detect{|s| s.id == 1}.count).to eq 2 + expect(@collection.steps.detect{|s| s.id == 2}.count).to eq 1 + expect(@collection.steps.detect{|s| s.id == 3}.count).to eq 3 end end @@ -67,11 +65,11 @@ it "should return a step for an existing id" do @collection.add_step(0, /regex/) - @collection[0].should be_instance_of(Stepdown::Step) + expect(@collection[0]).to be_instance_of(Stepdown::Step) end it "should return nil for a step that doesn't exist" do - @collection[1].should be_nil + expect(@collection[1]).to be_nil end end @@ -85,7 +83,7 @@ @collection.add_step(42, /step 2/) @collection.add_step(60, /step 3/) - @collection.each_with_index{|step, i| step.id.should == ids[i] } + @collection.each_with_index{|step, i| expect(step.id).to eq ids[i] } end end diff --git a/spec/lib/stepdown/step_group_spec.rb b/spec/lib/stepdown/step_group_spec.rb index dee976c..1f41238 100644 --- a/spec/lib/stepdown/step_group_spec.rb +++ b/spec/lib/stepdown/step_group_spec.rb @@ -17,9 +17,9 @@ @step_group.add_step(Stepdown::Step.new(3,/regex/)) @step_group.add_step(Stepdown::Step.new(2,/regex/)) - @step_group.step_collection[0].count.should == 3 - @step_group.step_collection[1].count.should == 2 - @step_group.step_collection[2].count.should == 1 + expect(@step_group.step_collection[0].count).to eq 3 + expect(@step_group.step_collection[1].count).to eq 2 + expect(@step_group.step_collection[2].count).to eq 1 end end @@ -30,12 +30,12 @@ end it "should return 0 for an empty group" do - @step_group.use_count.should be_zero + expect(@step_group.use_count).to be_zero end it "should return 0 for an empty group" do @step_group.update_use_count(10) - @step_group.use_count.should == 10 + expect(@step_group.use_count).to eq 10 end end diff --git a/spec/lib/stepdown/step_instance_spec.rb b/spec/lib/stepdown/step_instance_spec.rb index 60c0325..0a77679 100644 --- a/spec/lib/stepdown/step_instance_spec.rb +++ b/spec/lib/stepdown/step_instance_spec.rb @@ -10,14 +10,14 @@ end it "should deal with missing constants" do - lambda{ @step_instance.instance_eval("MissingConst") }.should_not raise_error - lambda{ @step_instance.instance_eval("MissingConst::MissingClass") }.should_not raise_error - lambda{ @step_instance.instance_eval("MissingConst::MissingClass.missing_method") }.should_not raise_error + expect { @step_instance.instance_eval("MissingConst") }.to_not raise_error + expect { @step_instance.instance_eval("MissingConst::MissingClass") }.to_not raise_error + expect { @step_instance.instance_eval("MissingConst::MissingClass.missing_method") }.to_not raise_error end it "should deal with missing methods" do - lambda{ @step_instance.doesnt_exist }.should_not raise_error - lambda{ Stepdown::StepInstance.doesnt_exist }.should_not raise_error + expect { @step_instance.doesnt_exist }.to_not raise_error + expect { Stepdown::StepInstance.doesnt_exist }.to_not raise_error end describe "returning steps" do @@ -26,7 +26,7 @@ @step_instance.When(/when/) @step_instance.Then(/then/) - @step_instance.step_collection.length.should == 3 + expect(@step_instance.step_collection.length).to eq 3 end end @@ -34,34 +34,33 @@ describe "returning matched steps" do it "should return nil when no matching step found" do @step_instance.Given(/some step/) - @step_instance.line_matches("Given some other step").should be_nil + expect(@step_instance.line_matches("Given some other step")).to be_nil end it "should parse And steps" do @step_instance.Given(/matched step/) - @step_instance.line_matches("And matched step").regex.should == /matched step/ + expect(@step_instance.line_matches("And matched step").regex).to eq(/matched step/) end it "should parse Given steps" do @step_instance.Given(/matched step/) - @step_instance.line_matches("Given matched step").regex.should == /matched step/ + expect(@step_instance.line_matches("Given matched step").regex).to eq(/matched step/) end it "should parse When steps" do @step_instance.When(/matched step/) - @step_instance.line_matches("When matched step").regex.should == /matched step/ + expect(@step_instance.line_matches("When matched step").regex).to eq(/matched step/) end it "should parse Then steps" do @step_instance.Then(/matched step/) - @step_instance.line_matches("Then matched step").regex.should == /matched step/ + expect(@step_instance.line_matches("Then matched step").regex).to eq(/matched step/) end it "should parse And steps" do @step_instance.And(/matched step/) - @step_instance.line_matches("And matched step").regex.should == /matched step/ + expect(@step_instance.line_matches("And matched step").regex).to eq(/matched step/) end - end describe "parsing step definitions" do