Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
seancaffery committed Oct 9, 2016
1 parent 6179f5b commit 5ce589f
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 134 deletions.
40 changes: 20 additions & 20 deletions spec/lib/stepdown/analyzer_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/stepdown/bluff_graph_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 10 additions & 12 deletions spec/lib/stepdown/feature_parser_spec.rb
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/stepdown/graph_spec.rb
Expand Up @@ -16,32 +16,32 @@ 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

describe "loading stat files" do
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",
Expand All @@ -52,7 +52,7 @@ class DummyGraph
:label=>"12/6",
:unused_steps=>[123]}]

stats.length.should == 2
expect(stats.length).to eq 2
end

end
Expand Down
39 changes: 19 additions & 20 deletions spec/lib/stepdown/options_spec.rb
Expand Up @@ -11,86 +11,85 @@
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

describe "selecting reporter" do
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

describe "using default directories" do
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

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/stepdown/scenario_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 5ce589f

Please sign in to comment.