From 57c700542f6b730f4676e37bd13fb3f7a669278d Mon Sep 17 00:00:00 2001 From: Sasha Gerrand Date: Wed, 13 Aug 2014 16:29:05 +0100 Subject: [PATCH 1/3] Prefer `double` over `mock` "DEPRECATION: mock is deprecated. Use double instead." --- spec/auto_tagger/base_spec.rb | 6 +++--- spec/auto_tagger/capistrano_helper_spec.rb | 4 ++-- spec/auto_tagger/command_line_spec.rb | 14 +++++++------- spec/auto_tagger/git/ref_set_spec.rb | 2 +- spec/auto_tagger/git/ref_spec.rb | 4 ++-- spec/auto_tagger/git/repo_spec.rb | 2 +- spec/auto_tagger/options_spec.rb | 2 +- spec/auto_tagger/recipes_spec.rb | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spec/auto_tagger/base_spec.rb b/spec/auto_tagger/base_spec.rb index ca21720..f56f607 100644 --- a/spec/auto_tagger/base_spec.rb +++ b/spec/auto_tagger/base_spec.rb @@ -252,7 +252,7 @@ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags-ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/heads/master") ] - base.repo.stub(:refs) { mock("RefSet", :all => refs) } + base.repo.stub(:refs) { double("RefSet", :all => refs) } base.refs_for_stage("ci").should == [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009") ] @@ -267,7 +267,7 @@ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/1002"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/heads/master") ] - base.repo.stub(:refs) { mock("RefSet", :all => refs) } + base.repo.stub(:refs) { double("RefSet", :all => refs) } base.refs_for_stage("ci").map(&:name).should == [ "refs/tags/ci/999", "refs/tags/ci/1001", "refs/tags/ci/1002" ] end end @@ -293,7 +293,7 @@ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2009") ] - base.repo.stub(:refs) { mock("RefSet", :all => refs) } + base.repo.stub(:refs) { double("RefSet", :all => refs) } base.release_tag_entries.should == [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/demo/2009"), diff --git a/spec/auto_tagger/capistrano_helper_spec.rb b/spec/auto_tagger/capistrano_helper_spec.rb index d4b33a1..d348f2a 100644 --- a/spec/auto_tagger/capistrano_helper_spec.rb +++ b/spec/auto_tagger/capistrano_helper_spec.rb @@ -20,8 +20,8 @@ it "returns the sha of the last ref from that stage" do helper = AutoTagger::CapistranoHelper.new({}) - ref = mock(AutoTagger::Git::Ref, :sha => "abc123") - auto_tagger = mock AutoTagger::Base, :last_ref_from_previous_stage => ref + ref = double(AutoTagger::Git::Ref, :sha => "abc123") + auto_tagger = double AutoTagger::Base, :last_ref_from_previous_stage => ref helper.stub(:auto_tagger) { auto_tagger } helper.ref.should == "abc123" end diff --git a/spec/auto_tagger/command_line_spec.rb b/spec/auto_tagger/command_line_spec.rb index af65668..66dea38 100644 --- a/spec/auto_tagger/command_line_spec.rb +++ b/spec/auto_tagger/command_line_spec.rb @@ -17,7 +17,7 @@ describe "#cleanup" do it "runs the cleanup command with a stage" do command_line = AutoTagger::CommandLine.new ["cleanup"] - tagger = mock(AutoTagger::Base, :cleanup => 7) + tagger = double(AutoTagger::Base, :cleanup => 7) AutoTagger::Base.should_receive(:new).and_return(tagger) command_line.execute.last.should include("7") end @@ -32,7 +32,7 @@ describe "#delete_locally" do it "runs the delete_locally command" do command_line = AutoTagger::CommandLine.new ["delete_locally"] - tagger = mock(AutoTagger::Base, :delete_locally => 7) + tagger = double(AutoTagger::Base, :delete_locally => 7) AutoTagger::Base.should_receive(:new).and_return(tagger) command_line.execute.last.should include("7") end @@ -47,7 +47,7 @@ describe "#delete_on_remote" do it "runs the delete_on_remote command" do command_line = AutoTagger::CommandLine.new ["delete_on_remote"] - tagger = mock(AutoTagger::Base, :delete_on_remote => 7) + tagger = double(AutoTagger::Base, :delete_on_remote => 7) AutoTagger::Base.should_receive(:new).and_return(tagger) command_line.execute.last.should include("7") end @@ -62,7 +62,7 @@ describe "#list" do it "runs the list command" do command_line = AutoTagger::CommandLine.new ["list"] - tagger = mock(AutoTagger::Base, :list => ["foo", "bar"]) + tagger = double(AutoTagger::Base, :list => ["foo", "bar"]) AutoTagger::Base.should_receive(:new).and_return(tagger) command_line.execute.last.should include("foo", "bar") end @@ -76,7 +76,7 @@ it "runs the config command" do command_line = AutoTagger::CommandLine.new ["config"] - config = mock(AutoTagger::Configuration, :settings => {"foo" => "bar"}) + config = double(AutoTagger::Configuration, :settings => {"foo" => "bar"}) AutoTagger::Configuration.should_receive(:new).and_return(config) command_line.execute.last.should include("foo", "bar") end @@ -84,14 +84,14 @@ describe "#create" do it "runs the create command" do command_line = AutoTagger::CommandLine.new ["create"] - tagger = mock(AutoTagger::Base, :create_ref => mock(AutoTagger::Git::Ref, :name => "refs/tags")) + tagger = double(AutoTagger::Base, :create_ref => double(AutoTagger::Git::Ref, :name => "refs/tags")) AutoTagger::Base.should_receive(:new).and_return(tagger) command_line.execute.last.should include("refs/tags") end it "includes a deprecation command when necessary" do command_line = AutoTagger::CommandLine.new ["ci"] - tagger = mock(AutoTagger::Base, :create_ref => mock(AutoTagger::Git::Ref, :name => "refs/tags")) + tagger = double(AutoTagger::Base, :create_ref => double(AutoTagger::Git::Ref, :name => "refs/tags")) AutoTagger::Base.should_receive(:new).and_return(tagger) result = command_line.execute.last result.should include("DEPRECATION") diff --git a/spec/auto_tagger/git/ref_set_spec.rb b/spec/auto_tagger/git/ref_set_spec.rb index 2bcf38b..eb2953c 100644 --- a/spec/auto_tagger/git/ref_set_spec.rb +++ b/spec/auto_tagger/git/ref_set_spec.rb @@ -3,7 +3,7 @@ describe AutoTagger::Git::RefSet do before do - @repo = mock(AutoTagger::Git::Repo, :exec => true) + @repo = double(AutoTagger::Git::Repo, :exec => true) @ref_set = AutoTagger::Git::RefSet.new(@repo) @refstring = <<-LIST 23087241c495773c8eece1c195cc453a8055c4eb refs/tags/200808080808 diff --git a/spec/auto_tagger/git/ref_spec.rb b/spec/auto_tagger/git/ref_spec.rb index ec91c4f..417273a 100644 --- a/spec/auto_tagger/git/ref_spec.rb +++ b/spec/auto_tagger/git/ref_spec.rb @@ -3,7 +3,7 @@ describe AutoTagger::Git::Ref do before do - @repo = mock(AutoTagger::Git::Repo, :exec => true) + @repo = double(AutoTagger::Git::Repo, :exec => true) @ref = AutoTagger::Git::Ref.new(@repo, "85af4e", "refs/auto_tags/ci") end @@ -43,4 +43,4 @@ end end -end \ No newline at end of file +end diff --git a/spec/auto_tagger/git/repo_spec.rb b/spec/auto_tagger/git/repo_spec.rb index b5a45c0..67c63b8 100644 --- a/spec/auto_tagger/git/repo_spec.rb +++ b/spec/auto_tagger/git/repo_spec.rb @@ -4,7 +4,7 @@ before do File.stub(:exists?).and_return(true) - @commander = mock(AutoTagger::Commander) + @commander = double(AutoTagger::Commander) end describe "#path" do diff --git a/spec/auto_tagger/options_spec.rb b/spec/auto_tagger/options_spec.rb index 0929047..5615006 100644 --- a/spec/auto_tagger/options_spec.rb +++ b/spec/auto_tagger/options_spec.rb @@ -157,4 +157,4 @@ it_should_behave_like "common options" end -end \ No newline at end of file +end diff --git a/spec/auto_tagger/recipes_spec.rb b/spec/auto_tagger/recipes_spec.rb index f6bdeda..8e4a26f 100644 --- a/spec/auto_tagger/recipes_spec.rb +++ b/spec/auto_tagger/recipes_spec.rb @@ -5,14 +5,14 @@ describe "create_ref" do before do - @auto_tagger = mock(AutoTagger::Base) + @auto_tagger = double(AutoTagger::Base) AutoTagger::Base.should_receive(:new).and_return(@auto_tagger) @config = Capistrano::Configuration.instance = Capistrano::Configuration.new @config.load "lib/auto_tagger/recipes" @config.stub(:real_revision).and_return("REAL_REVISION") - @ref = mock(:name => "TAG", :sha => "SHA") + @ref = double(:name => "TAG", :sha => "SHA") end it "creates a tag from the real_revision when :auto_tagger_stage is set" do From 3e5c981eb0a72fcc68788b83773fc4084546730b Mon Sep 17 00:00:00 2001 From: Sasha Gerrand Date: Wed, 13 Aug 2014 16:29:33 +0100 Subject: [PATCH 2/3] The interface for be_(false|true) has changed --- spec/auto_tagger/command_line_spec.rb | 2 +- spec/auto_tagger/options_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/auto_tagger/command_line_spec.rb b/spec/auto_tagger/command_line_spec.rb index 66dea38..7d8002a 100644 --- a/spec/auto_tagger/command_line_spec.rb +++ b/spec/auto_tagger/command_line_spec.rb @@ -5,7 +5,7 @@ describe "#execute" do it "runs the version command" do command_line = AutoTagger::CommandLine.new ["version"] - command_line.execute.first.should be_true + command_line.execute.first.should eq(true) command_line.execute.last.should include(AutoTagger::VERSION) end diff --git a/spec/auto_tagger/options_spec.rb b/spec/auto_tagger/options_spec.rb index 5615006..5337258 100644 --- a/spec/auto_tagger/options_spec.rb +++ b/spec/auto_tagger/options_spec.rb @@ -30,13 +30,13 @@ it "understands --dry-run" do options = AutoTagger::Options.from_command_line ["--dry-run"] - options[:dry_run].should be_true + options[:dry_run].should eq(true) options = AutoTagger::Options.from_command_line ["--dry-run=true"] - options[:dry_run].should be_true + options[:dry_run].should eq(true) options = AutoTagger::Options.from_command_line ["--dry-run=false"] - options[:dry_run].should be_false + options[:dry_run].should eq(false) end it "understands --fetch-refs" do @@ -60,7 +60,7 @@ options[:offline].should be_nil options = AutoTagger::Options.from_command_line ["--offline=true"] - options[:offline].should be_true + options[:offline].should eq(true) end end From d13ced836e9ff4308538ee67885341c73f47a8e8 Mon Sep 17 00:00:00 2001 From: Sasha Gerrand Date: Wed, 13 Aug 2014 16:31:43 +0100 Subject: [PATCH 3/3] Convert specs to RSpec 3.0.3 syntax with Transpec This conversion is done by Transpec 2.2.0 with the following command: transpec * 157 conversions from: obj.should to: expect(obj).to * 129 conversions from: == expected to: eq(expected) * 68 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 49 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 12 conversions from: proc { }.should to: expect { }.to * 3 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 2 conversions from: obj.should_not to: expect(obj).not_to See also: https://github.com/yujinakayama/transpec#supported-conversions --- spec/auto_tagger/base_spec.rb | 164 ++++++++++----------- spec/auto_tagger/capistrano_helper_spec.rb | 50 +++---- spec/auto_tagger/command_line_spec.rb | 56 +++---- spec/auto_tagger/commander_spec.rb | 14 +- spec/auto_tagger/configuration_spec.rb | 130 ++++++++-------- spec/auto_tagger/git/ref_set_spec.rb | 30 ++-- spec/auto_tagger/git/ref_spec.rb | 12 +- spec/auto_tagger/git/repo_spec.rb | 68 ++++----- spec/auto_tagger/options_spec.rb | 76 +++++----- spec/auto_tagger/recipes_spec.rb | 10 +- 10 files changed, 305 insertions(+), 305 deletions(-) diff --git a/spec/auto_tagger/base_spec.rb b/spec/auto_tagger/base_spec.rb index f56f607..d17fdd4 100644 --- a/spec/auto_tagger/base_spec.rb +++ b/spec/auto_tagger/base_spec.rb @@ -8,7 +8,7 @@ :dry_run => true, :verbose => true, :executable => "/usr/bin/git" - AutoTagger::Git::Repo.should_receive(:new).with "/foo", + expect(AutoTagger::Git::Repo).to receive(:new).with "/foo", :execute_commands => false, :verbose => true, :executable => "/usr/bin/git" @@ -20,15 +20,15 @@ it "returns nil if there is no previous stage" do refs = "0f7324495f06e2b refs/tags/ci/2001" base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "ci" - base.repo.stub(:read).and_return(refs) - base.last_ref_from_previous_stage.should be_nil + allow(base.repo).to receive(:read).and_return(refs) + expect(base.last_ref_from_previous_stage).to be_nil end it "returns nil if there are no matching refs" do refs = "0f7324495f06e2b refs/tags-ci/2001" base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "ci" - base.repo.stub(:read).and_return(refs) - base.last_ref_from_previous_stage.should be_nil + allow(base.repo).to receive(:read).and_return(refs) + expect(base.last_ref_from_previous_stage).to be_nil end it "should return the last ref from the previous stage" do @@ -38,9 +38,9 @@ 61c6627d766c1be refs/tags/demo/2001 } base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo" - base.repo.stub(:read).and_return(refs) + allow(base.repo).to receive(:read).and_return(refs) ref = AutoTagger::Git::Ref.new(base.repo, "41dee06050450ac", "refs/tags/ci/2003") - base.last_ref_from_previous_stage.name.should == "refs/tags/ci/2003" + expect(base.last_ref_from_previous_stage.name).to eq("refs/tags/ci/2003") end it "should return the last ref with correct order (git show-ref is not ordered)" do @@ -50,9 +50,9 @@ b8d7ce86f1c6440080e0c315c7cc1c0fe702127f refs/tags/ci/999 } base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo" - base.repo.stub(:read).and_return(refs) + allow(base.repo).to receive(:read).and_return(refs) ref = AutoTagger::Git::Ref.new(base.repo, "a80af49962c95a92df59a527a3ce60e22da290fc", "refs/tags/ci/1002") - base.last_ref_from_previous_stage.name.should == "refs/tags/ci/1002" + expect(base.last_ref_from_previous_stage.name).to eq("refs/tags/ci/1002") end it "should return the last ref with correct order using other date separator(git show-ref is not ordered)" do @@ -62,78 +62,78 @@ b8d7ce86f1c6440080e0c315c7cc1c0fe702127f refs/tags/ci/2011-09-08-18-17-43 } base = AutoTagger::Base.new :stages => ["ci", "demo", "production"], :stage => "demo", :date_separator => "-" - base.repo.stub(:read).and_return(refs) + allow(base.repo).to receive(:read).and_return(refs) ref = AutoTagger::Git::Ref.new(base.repo, "a80af49962c95a92df59a527a3ce60e22da290fc", "refs/tags/ci/2011-09-09-19-17-43") - base.last_ref_from_previous_stage.name.should == "refs/tags/ci/2011-09-09-19-17-43" + expect(base.last_ref_from_previous_stage.name).to eq("refs/tags/ci/2011-09-09-19-17-43") end end describe "#create_ref" do it "creates a ref with the given sha and returns the ref" do base = AutoTagger::Base.new :stage => "demo" - base.stub(:timestamp).and_return("20081010") + allow(base).to receive(:timestamp).and_return("20081010") - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("update-ref refs/tags/demo/20081010 abc123") ref = base.create_ref "abc123" - ref.name.should == "refs/tags/demo/20081010" - ref.sha.should == "abc123" + expect(ref.name).to eq("refs/tags/demo/20081010") + expect(ref.sha).to eq("abc123") end it "defaults to the latest commit sha" do base = AutoTagger::Base.new :stage => "demo" - base.stub(:timestamp).and_return("20081010") + allow(base).to receive(:timestamp).and_return("20081010") - base.repo.should_receive(:latest_commit_sha).and_return("abc123") - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("update-ref refs/tags/demo/20081010 abc123") + expect(base.repo).to receive(:latest_commit_sha).and_return("abc123") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("update-ref refs/tags/demo/20081010 abc123") ref = base.create_ref - ref.name.should == "refs/tags/demo/20081010" - ref.sha.should == "abc123" + expect(ref.name).to eq("refs/tags/demo/20081010") + expect(ref.sha).to eq("abc123") end it "respects the passed in date separator" do time = Time.now.utc timestamp = time.strftime("%Y-%m-%d-%H-%M-%S") base = AutoTagger::Base.new :stage => "ci", :date_separator => "-" - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("update-ref refs/tags/ci/#{timestamp} abc123") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("update-ref refs/tags/ci/#{timestamp} abc123") base.create_ref "abc123" end it "raises an error if the stage is not set" do - proc do + expect do AutoTagger::Base.new({}).create_ref - end.should raise_error(AutoTagger::Base::StageCannotBeBlankError) + end.to raise_error(AutoTagger::Base::StageCannotBeBlankError) end it "fetches tags before creating tags" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("fetch origin refs/tags/*:refs/tags/*") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("fetch origin refs/tags/*:refs/tags/*") base.create_ref "abc123" end it "does not fetch tags before creating tags if fetch tags is false" do base = AutoTagger::Base.new :stage => "ci", :fetch_tags => false - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("push origin refs/tags/*:refs/tags/*") base.create_ref "abc123" end it "pushes tags before creating tags" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("push origin refs/tags/*:refs/tags/*") base.create_ref "abc123" end it "does not push tags before creating tags if push tags is false" do base = AutoTagger::Base.new :stage => "ci", :push_tags => false - base.repo.stub(:exec) { true } - base.repo.should_receive(:exec).with("push origin refs/tags/*:refs/tags/*") + allow(base.repo).to receive(:exec) { true } + expect(base.repo).to receive(:exec).with("push origin refs/tags/*:refs/tags/*") base.create_ref "abc123" end end @@ -141,24 +141,24 @@ describe "#delete_locally" do it "blows up if you don't enter a stage" do base = AutoTagger::Base.new({}) - proc do + expect do base.delete_locally - end.should raise_error(AutoTagger::Base::StageCannotBeBlankError) + end.to raise_error(AutoTagger::Base::StageCannotBeBlankError) end it "executes the local delete commands for all the refs that match" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.stub(:refs_for_stage) do + allow(base.repo).to receive(:exec) { true } + allow(base).to receive(:refs_for_stage) do [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2010") ] end - base.repo.should_receive(:exec).with("update-ref -d refs/tags/ci/2008") - base.repo.should_receive(:exec).with("update-ref -d refs/tags/ci/2009") - base.repo.should_not_receive(:exec).with("update-ref -d refs/tags/ci/2010") + expect(base.repo).to receive(:exec).with("update-ref -d refs/tags/ci/2008") + expect(base.repo).to receive(:exec).with("update-ref -d refs/tags/ci/2009") + expect(base.repo).not_to receive(:exec).with("update-ref -d refs/tags/ci/2010") base.delete_locally end end @@ -166,29 +166,29 @@ describe "#delete_on_remote" do it "blows up if you don't enter a stage" do base = AutoTagger::Base.new({}) - proc do + expect do base.delete_on_remote - end.should raise_error(AutoTagger::Base::StageCannotBeBlankError) + end.to raise_error(AutoTagger::Base::StageCannotBeBlankError) end it "does not push if there are no tags" do base = AutoTagger::Base.new :stage => "ci" - base.stub(:refs_for_stage).with("ci") { [] } - base.repo.should_not_receive(:exec) + allow(base).to receive(:refs_for_stage).with("ci") { [] } + expect(base.repo).not_to receive(:exec) base.delete_on_remote end it "executes the remote delete commands in a batch" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.stub(:refs_for_stage).with("ci") do + allow(base.repo).to receive(:exec) { true } + allow(base).to receive(:refs_for_stage).with("ci") do [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2010") ] end - base.repo.should_receive(:exec).with("push origin :refs/tags/ci/2008 :refs/tags/ci/2009") + expect(base.repo).to receive(:exec).with("push origin :refs/tags/ci/2008 :refs/tags/ci/2009") base.delete_on_remote end end @@ -196,55 +196,55 @@ describe "#cleanup" do it "blows up if you don't enter a stage" do base = AutoTagger::Base.new({}) - proc do + expect do base.cleanup - end.should raise_error(AutoTagger::Base::StageCannotBeBlankError) + end.to raise_error(AutoTagger::Base::StageCannotBeBlankError) end it "executes delete locally" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } - base.should_receive(:delete_local_refs) + allow(base.repo).to receive(:exec) { true } + allow(base).to receive(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } + expect(base).to receive(:delete_local_refs) base.cleanup end it "executes delete on remote if push refs is true" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } - base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } - base.should_receive(:delete_remote_refs) + allow(base.repo).to receive(:exec) { true } + allow(base).to receive(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } + expect(base).to receive(:delete_remote_refs) base.cleanup end it "does not execute delete on remote if push refs is false" do base = AutoTagger::Base.new :stage => "ci", :offline => true - base.repo.stub(:exec) { true } - base.stub(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } - base.should_not_receive(:delete_remote_refs) + allow(base.repo).to receive(:exec) { true } + allow(base).to receive(:refs_for_stage).with("ci") { [AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008")] } + expect(base).not_to receive(:delete_remote_refs) base.cleanup end end describe ".items_to_remove" do it "returns the items that can be removed from an array, based on the keep value passed in" do - AutoTagger::Base.items_to_remove(["2008"], 0).should == ["2008"] - AutoTagger::Base.items_to_remove(["2008"], 1).should == [] - AutoTagger::Base.items_to_remove(["2008", "2009"], 0).should == ["2008", "2009"] - AutoTagger::Base.items_to_remove(["2008", "2009"], 1).should == ["2008"] - AutoTagger::Base.items_to_remove(["2008", "2009"], 2).should == [] - AutoTagger::Base.items_to_remove(["2008", "2009"], 3).should == [] - AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 0).should == ["2008", "2009", "2010"] - AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 1).should == ["2008", "2009"] - AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 2).should == ["2008"] - AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 3).should == [] + expect(AutoTagger::Base.items_to_remove(["2008"], 0)).to eq(["2008"]) + expect(AutoTagger::Base.items_to_remove(["2008"], 1)).to eq([]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009"], 0)).to eq(["2008", "2009"]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009"], 1)).to eq(["2008"]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009"], 2)).to eq([]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009"], 3)).to eq([]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 0)).to eq(["2008", "2009", "2010"]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 1)).to eq(["2008", "2009"]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 2)).to eq(["2008"]) + expect(AutoTagger::Base.items_to_remove(["2008", "2009", "2010"], 3)).to eq([]) end end describe "#refs_for_stage" do it "returns refs that match the given stage" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } + allow(base.repo).to receive(:exec) { true } refs = [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/auto_tags/ci/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), @@ -252,31 +252,31 @@ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags-ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/heads/master") ] - base.repo.stub(:refs) { double("RefSet", :all => refs) } - base.refs_for_stage("ci").should == [ + allow(base.repo).to receive(:refs) { double("RefSet", :all => refs) } + expect(base.refs_for_stage("ci")).to eq([ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009") - ] + ]) end it "orders refs based on last part of tag" do base = AutoTagger::Base.new :stage => "ci" - base.repo.stub(:exec) { true } + allow(base.repo).to receive(:exec) { true } refs = [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/1001"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/999"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/1002"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/heads/master") ] - base.repo.stub(:refs) { double("RefSet", :all => refs) } - base.refs_for_stage("ci").map(&:name).should == [ "refs/tags/ci/999", "refs/tags/ci/1001", "refs/tags/ci/1002" ] + allow(base.repo).to receive(:refs) { double("RefSet", :all => refs) } + expect(base.refs_for_stage("ci").map(&:name)).to eq([ "refs/tags/ci/999", "refs/tags/ci/1001", "refs/tags/ci/1002" ]) end end describe "#list" do it "return a list of refs for the given stage" do base = AutoTagger::Base.new :stage => "ci" - base.should_receive(:fetch) - base.should_receive(:refs_for_stage).with("ci") + expect(base).to receive(:fetch) + expect(base).to receive(:refs_for_stage).with("ci") base.list end end @@ -284,7 +284,7 @@ describe "#release_tag_entries" do it "lists the last ref from each stage" do base = AutoTagger::Base.new :stage => "ci", :stages => ["ci", "demo", "production"] - base.repo.stub(:exec) { true } + allow(base.repo).to receive(:exec) { true } refs = [ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), @@ -293,12 +293,12 @@ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2008"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2009") ] - base.repo.stub(:refs) { double("RefSet", :all => refs) } - base.release_tag_entries.should == [ + allow(base.repo).to receive(:refs) { double("RefSet", :all => refs) } + expect(base.release_tag_entries).to eq([ AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/ci/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/demo/2009"), AutoTagger::Git::Ref.new(base.repo, "abc123", "refs/tags/production/2009") - ] + ]) end end diff --git a/spec/auto_tagger/capistrano_helper_spec.rb b/spec/auto_tagger/capistrano_helper_spec.rb index d348f2a..b3c310b 100644 --- a/spec/auto_tagger/capistrano_helper_spec.rb +++ b/spec/auto_tagger/capistrano_helper_spec.rb @@ -5,38 +5,38 @@ describe "#ref" do it "returns the specified branch when passed the :head variable" do helper = AutoTagger::CapistranoHelper.new :branch => "release", :head => nil - helper.ref.should == "release" + expect(helper.ref).to eq("release") end it "returns the specified tag" do helper = AutoTagger::CapistranoHelper.new :tag => "v0.1.7" - helper.ref.should == "v0.1.7" + expect(helper.ref).to eq("v0.1.7") end it "returns the specified ref" do helper = AutoTagger::CapistranoHelper.new :ref => "refs/auto_tags/ci" - helper.ref.should == "refs/auto_tags/ci" + expect(helper.ref).to eq("refs/auto_tags/ci") end it "returns the sha of the last ref from that stage" do helper = AutoTagger::CapistranoHelper.new({}) ref = double(AutoTagger::Git::Ref, :sha => "abc123") auto_tagger = double AutoTagger::Base, :last_ref_from_previous_stage => ref - helper.stub(:auto_tagger) { auto_tagger } - helper.ref.should == "abc123" + allow(helper).to receive(:auto_tagger) { auto_tagger } + expect(helper.ref).to eq("abc123") end it "returns the branch when specified" do helper = AutoTagger::CapistranoHelper.new :branch => "release" - helper.ref.should == "release" + expect(helper.ref).to eq("release") end end describe "#auto_tagger" do it "returns an AutoTagger::Base object with the correct options" do helper = AutoTagger::CapistranoHelper.new({}) - helper.stub(:auto_tagger_options).and_return({:foo => "bar"}) - AutoTagger::Base.should_receive(:new).with({:foo => "bar"}) + allow(helper).to receive(:auto_tagger_options).and_return({:foo => "bar"}) + expect(AutoTagger::Base).to receive(:new).with({:foo => "bar"}) helper.auto_tagger end end @@ -44,29 +44,29 @@ describe "#auto_tagger_options" do it "includes :stage from :auto_tagger_stage, :stage" do helper = AutoTagger::CapistranoHelper.new :stage => "demo" - helper.auto_tagger_options[:stage].should == "demo" + expect(helper.auto_tagger_options[:stage]).to eq("demo") helper = AutoTagger::CapistranoHelper.new :auto_tagger_stage => "demo" - helper.auto_tagger_options[:stage].should == "demo" + expect(helper.auto_tagger_options[:stage]).to eq("demo") helper = AutoTagger::CapistranoHelper.new :auto_tagger_stage => "demo", :stage => "ci" - helper.auto_tagger_options[:stage].should == "demo" + expect(helper.auto_tagger_options[:stage]).to eq("demo") end it "includes stages" do helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => ["demo"] - helper.auto_tagger_options[:stages].should == ["demo"] + expect(helper.auto_tagger_options[:stages]).to eq(["demo"]) end it "includes :auto_tagger_working_directory" do helper = AutoTagger::CapistranoHelper.new :auto_tagger_working_directory => "/foo" - helper.auto_tagger_options[:path].should == "/foo" + expect(helper.auto_tagger_options[:path]).to eq("/foo") end it "includes and deprecates :working_directory" do - AutoTagger::Deprecator.should_receive(:warn) + expect(AutoTagger::Deprecator).to receive(:warn) helper = AutoTagger::CapistranoHelper.new :working_directory => "/foo" - helper.auto_tagger_options[:path].should == "/foo" + expect(helper.auto_tagger_options[:path]).to eq("/foo") end [ @@ -84,16 +84,16 @@ ].each do |key| it "includes :#{key} when specified" do helper = AutoTagger::CapistranoHelper.new({}) - helper.auto_tagger_options.should_not have_key(key) + expect(helper.auto_tagger_options).not_to have_key(key) helper = AutoTagger::CapistranoHelper.new(:"auto_tagger_#{key}" => "value") - helper.auto_tagger_options.should have_key(key) - helper.auto_tagger_options[key].should == "value" + expect(helper.auto_tagger_options).to have_key(key) + expect(helper.auto_tagger_options[key]).to eq("value") end end it "accepts capistrano's dry_run" do - AutoTagger::CapistranoHelper.new(:dry_run => "shazbot").auto_tagger_options[:dry_run].should == "shazbot" + expect(AutoTagger::CapistranoHelper.new(:dry_run => "shazbot").auto_tagger_options[:dry_run]).to eq("shazbot") end [ @@ -111,7 +111,7 @@ ].each do |dry_run, auto_tagger_dry_run, preferred| it "prefers auto_tagger_dry_run=#{auto_tagger_dry_run.inspect} to dry_run=#{dry_run.inspect}" do helper = AutoTagger::CapistranoHelper.new(:dry_run => dry_run, :auto_tagger_dry_run => auto_tagger_dry_run) - helper.auto_tagger_options[:dry_run].should == preferred + expect(helper.auto_tagger_options[:dry_run]).to eq(preferred) end end end @@ -119,23 +119,23 @@ describe "#stages" do it "understands :stages" do helper = AutoTagger::CapistranoHelper.new :stages => ["demo"] - helper.stages.should == ["demo"] + expect(helper.stages).to eq(["demo"]) end it "understands :auto_tagger_stages" do helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => ["demo"] - helper.auto_tagger_options[:stages].should == ["demo"] + expect(helper.auto_tagger_options[:stages]).to eq(["demo"]) end it "understands and deprecates :autotagger_stages" do - AutoTagger::Deprecator.should_receive(:warn) + expect(AutoTagger::Deprecator).to receive(:warn) helper = AutoTagger::CapistranoHelper.new :autotagger_stages => ["demo"] - helper.stages.should == ["demo"] + expect(helper.stages).to eq(["demo"]) end it "makes all stages strings" do helper = AutoTagger::CapistranoHelper.new :auto_tagger_stages => [:demo] - helper.stages.should == ["demo"] + expect(helper.stages).to eq(["demo"]) end end diff --git a/spec/auto_tagger/command_line_spec.rb b/spec/auto_tagger/command_line_spec.rb index 7d8002a..d7280d5 100644 --- a/spec/auto_tagger/command_line_spec.rb +++ b/spec/auto_tagger/command_line_spec.rb @@ -5,27 +5,27 @@ describe "#execute" do it "runs the version command" do command_line = AutoTagger::CommandLine.new ["version"] - command_line.execute.first.should eq(true) - command_line.execute.last.should include(AutoTagger::VERSION) + expect(command_line.execute.first).to eq(true) + expect(command_line.execute.last).to include(AutoTagger::VERSION) end it "runs the help command" do command_line = AutoTagger::CommandLine.new ["help"] - command_line.execute.last.should include("USAGE") + expect(command_line.execute.last).to include("USAGE") end describe "#cleanup" do it "runs the cleanup command with a stage" do command_line = AutoTagger::CommandLine.new ["cleanup"] tagger = double(AutoTagger::Base, :cleanup => 7) - AutoTagger::Base.should_receive(:new).and_return(tagger) - command_line.execute.last.should include("7") + expect(AutoTagger::Base).to receive(:new).and_return(tagger) + expect(command_line.execute.last).to include("7") end it "prints a friendly error message when no stage is provided" do command_line = AutoTagger::CommandLine.new ["cleanup"] - AutoTagger::Base.should_receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) - command_line.execute.last.should include("You must provide a stage") + expect(AutoTagger::Base).to receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) + expect(command_line.execute.last).to include("You must provide a stage") end end @@ -33,14 +33,14 @@ it "runs the delete_locally command" do command_line = AutoTagger::CommandLine.new ["delete_locally"] tagger = double(AutoTagger::Base, :delete_locally => 7) - AutoTagger::Base.should_receive(:new).and_return(tagger) - command_line.execute.last.should include("7") + expect(AutoTagger::Base).to receive(:new).and_return(tagger) + expect(command_line.execute.last).to include("7") end it "prints a friendly error message when no stage is provided" do command_line = AutoTagger::CommandLine.new ["delete_locally"] - AutoTagger::Base.should_receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) - command_line.execute.last.should include("You must provide a stage") + expect(AutoTagger::Base).to receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) + expect(command_line.execute.last).to include("You must provide a stage") end end @@ -48,14 +48,14 @@ it "runs the delete_on_remote command" do command_line = AutoTagger::CommandLine.new ["delete_on_remote"] tagger = double(AutoTagger::Base, :delete_on_remote => 7) - AutoTagger::Base.should_receive(:new).and_return(tagger) - command_line.execute.last.should include("7") + expect(AutoTagger::Base).to receive(:new).and_return(tagger) + expect(command_line.execute.last).to include("7") end it "prints a friendly error message when no stage is provided" do command_line = AutoTagger::CommandLine.new ["delete_on_remote"] - AutoTagger::Base.should_receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) - command_line.execute.last.should include("You must provide a stage") + expect(AutoTagger::Base).to receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) + expect(command_line.execute.last).to include("You must provide a stage") end end @@ -63,45 +63,45 @@ it "runs the list command" do command_line = AutoTagger::CommandLine.new ["list"] tagger = double(AutoTagger::Base, :list => ["foo", "bar"]) - AutoTagger::Base.should_receive(:new).and_return(tagger) - command_line.execute.last.should include("foo", "bar") + expect(AutoTagger::Base).to receive(:new).and_return(tagger) + expect(command_line.execute.last).to include("foo", "bar") end it "prints a friendly error message when no stage is provided" do command_line = AutoTagger::CommandLine.new ["list"] - AutoTagger::Base.should_receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) - command_line.execute.last.should include("You must provide a stage") + expect(AutoTagger::Base).to receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) + expect(command_line.execute.last).to include("You must provide a stage") end end it "runs the config command" do command_line = AutoTagger::CommandLine.new ["config"] config = double(AutoTagger::Configuration, :settings => {"foo" => "bar"}) - AutoTagger::Configuration.should_receive(:new).and_return(config) - command_line.execute.last.should include("foo", "bar") + expect(AutoTagger::Configuration).to receive(:new).and_return(config) + expect(command_line.execute.last).to include("foo", "bar") end describe "#create" do it "runs the create command" do command_line = AutoTagger::CommandLine.new ["create"] tagger = double(AutoTagger::Base, :create_ref => double(AutoTagger::Git::Ref, :name => "refs/tags")) - AutoTagger::Base.should_receive(:new).and_return(tagger) - command_line.execute.last.should include("refs/tags") + expect(AutoTagger::Base).to receive(:new).and_return(tagger) + expect(command_line.execute.last).to include("refs/tags") end it "includes a deprecation command when necessary" do command_line = AutoTagger::CommandLine.new ["ci"] tagger = double(AutoTagger::Base, :create_ref => double(AutoTagger::Git::Ref, :name => "refs/tags")) - AutoTagger::Base.should_receive(:new).and_return(tagger) + expect(AutoTagger::Base).to receive(:new).and_return(tagger) result = command_line.execute.last - result.should include("DEPRECATION") - result.should include("refs/tags") + expect(result).to include("DEPRECATION") + expect(result).to include("refs/tags") end it "prints a friendly error message when no stage is provided" do command_line = AutoTagger::CommandLine.new ["create"] - AutoTagger::Base.should_receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) - command_line.execute.last.should include("You must provide a stage") + expect(AutoTagger::Base).to receive(:new).and_raise(AutoTagger::Base::StageCannotBeBlankError) + expect(command_line.execute.last).to include("You must provide a stage") end end diff --git a/spec/auto_tagger/commander_spec.rb b/spec/auto_tagger/commander_spec.rb index e5f2219..bf77b81 100644 --- a/spec/auto_tagger/commander_spec.rb +++ b/spec/auto_tagger/commander_spec.rb @@ -5,14 +5,14 @@ describe "#read" do it "execute the command and returns the results" do commander = AutoTagger::Commander.new("/foo", false) - commander.should_receive(:`).with('cd "/foo" && ls') + expect(commander).to receive(:`).with('cd "/foo" && ls') commander.read("ls") end it "puts the response when it's verbose" do commander = AutoTagger::Commander.new("/foo", true) - commander.stub(:`) - commander.should_receive(:puts).with('cd "/foo" && ls') + allow(commander).to receive(:`) + expect(commander).to receive(:puts).with('cd "/foo" && ls') commander.read("ls") end end @@ -20,14 +20,14 @@ describe "#execute" do it "executes and doesn't return anything" do commander = AutoTagger::Commander.new("/foo", false) - commander.should_receive(:system).with('cd "/foo" && ls') + expect(commander).to receive(:system).with('cd "/foo" && ls') commander.execute("ls") end it "puts the response when it's verbose" do commander = AutoTagger::Commander.new("/foo", true) - commander.stub(:system) - commander.should_receive(:puts).with('cd "/foo" && ls') + allow(commander).to receive(:system) + expect(commander).to receive(:puts).with('cd "/foo" && ls') commander.execute("ls") end end @@ -35,7 +35,7 @@ describe "#print" do it "returns the command to be run" do commander = AutoTagger::Commander.new("/foo", false) - commander.should_receive(:puts).with('cd "/foo" && ls') + expect(commander).to receive(:puts).with('cd "/foo" && ls') commander.print("ls") end end diff --git a/spec/auto_tagger/configuration_spec.rb b/spec/auto_tagger/configuration_spec.rb index 2bb2653..63a0532 100644 --- a/spec/auto_tagger/configuration_spec.rb +++ b/spec/auto_tagger/configuration_spec.rb @@ -4,281 +4,281 @@ before do # make sure that the specs don't pick up this gem's .auto_tagger file - File.stub(:read) { nil } + allow(File).to receive(:read) { nil } end describe "#working_directory" do it "returns the current directory when path is nil" do dir = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) - Dir.stub(:pwd) { dir } + allow(Dir).to receive(:pwd) { dir } config = AutoTagger::Configuration.new({}) - config.working_directory.should == dir + expect(config.working_directory).to eq(dir) end it "expands path when path is set" do dir = File.expand_path(".") config = AutoTagger::Configuration.new :path => "." - config.working_directory.should == dir + expect(config.working_directory).to eq(dir) end end describe "#opts_file" do it "expands the passed in opts file path in reference to the working directory" do config = AutoTagger::Configuration.new :opts_file => "../.foo_tagger", :path => "/foo/bar" - config.opts_file.should == "/foo/.foo_tagger" + expect(config.opts_file).to eq("/foo/.foo_tagger") end it "defaults to looking in the working directories .auto_tagger file" do config = AutoTagger::Configuration.new :path => "/foo" - config.opts_file.should == "/foo/.auto_tagger" + expect(config.opts_file).to eq("/foo/.auto_tagger") end end describe "#file_settings" do it "return a hash representing the options specified in the opts file" do config = AutoTagger::Configuration.new - config.stub(:opts_file) { "/foo/.auto_tagger" } - File.should_receive(:exists?) { true } - File.should_receive(:read).with("/foo/.auto_tagger").and_return("--offline=false\n--verbose=true") - config.file_settings.should == {:offline => false, :verbose => true} + allow(config).to receive(:opts_file) { "/foo/.auto_tagger" } + expect(File).to receive(:exists?) { true } + expect(File).to receive(:read).with("/foo/.auto_tagger").and_return("--offline=false\n--verbose=true") + expect(config.file_settings).to eq({:offline => false, :verbose => true}) end it "ignores blank lines and whitespace" do config = AutoTagger::Configuration.new - config.stub(:opts_file) { "/foo/.auto_tagger" } - File.should_receive(:exists?).with("/foo/.auto_tagger") { true } - File.should_receive(:read).with("/foo/.auto_tagger").and_return(" --offline=false \n\n--verbose=true\n") - config.file_settings.should == {:offline => false, :verbose => true} + allow(config).to receive(:opts_file) { "/foo/.auto_tagger" } + expect(File).to receive(:exists?).with("/foo/.auto_tagger") { true } + expect(File).to receive(:read).with("/foo/.auto_tagger").and_return(" --offline=false \n\n--verbose=true\n") + expect(config.file_settings).to eq({:offline => false, :verbose => true}) end it "returns an empty hash if the file doens't exist" do - File.stub(:exists?) { false } + allow(File).to receive(:exists?) { false } config = AutoTagger::Configuration.new :path => "/foo" - config.file_settings.should == {} + expect(config.file_settings).to eq({}) end # TODO: print warnings instead of blowing up?? it "doesn't parse options that are not valid for the opts file" do - File.stub(:exists?) { true } - File.should_receive(:read).with("/foo/.auto_tagger").and_return("--opts-file=/foo") + allow(File).to receive(:exists?) { true } + expect(File).to receive(:read).with("/foo/.auto_tagger").and_return("--opts-file=/foo") config = AutoTagger::Configuration.new :path => "/foo" - proc do - config.file_settings.should == {} - end.should raise_error(OptionParser::InvalidOption) + expect do + expect(config.file_settings).to eq({}) + end.to raise_error(OptionParser::InvalidOption) end end describe "#settings" do it "should merge the passed in settings with the file settings" do config = AutoTagger::Configuration.new :stage => "demo", :offline => true - config.stub(:file_settings).and_return({:stage => "ci", :verbose => false}) - config.settings.should == {:stage => "demo", :offline => true, :verbose => false} + allow(config).to receive(:file_settings).and_return({:stage => "ci", :verbose => false}) + expect(config.settings).to eq({:stage => "demo", :offline => true, :verbose => false}) end end describe "#stages" do it "splits on a comma if it's a string, ignoring whitespace" do config = AutoTagger::Configuration.new :stages => ",ci,, demo , production," - config.stages.should == ["ci", "demo", "production"] + expect(config.stages).to eq(["ci", "demo", "production"]) end it "returns the passed in stages if it's an array" do config = AutoTagger::Configuration.new :stages => ["ci", "demo"] - config.stages.should == ["ci", "demo"] + expect(config.stages).to eq(["ci", "demo"]) end it "removes blank items" do config = AutoTagger::Configuration.new :stages => ["ci", ""] - config.stages.should == ["ci"] + expect(config.stages).to eq(["ci"]) end it "turns stages into strings" do config = AutoTagger::Configuration.new :stages => [:ci, :production] - config.stages.should == ["ci", "production"] + expect(config.stages).to eq(["ci", "production"]) end end describe "#stage" do it "should use the stage passed in" do config = AutoTagger::Configuration.new :stage => "demo" - config.stage.should == "demo" + expect(config.stage).to eq("demo") end it "defaults to the last stage if stages is passed in" do config = AutoTagger::Configuration.new :stages => ["demo", "production"] - config.stage.should == "production" + expect(config.stage).to eq("production") end it "returns nil if stage and stages are not passed in" do config = AutoTagger::Configuration.new - config.stage.should be_nil + expect(config.stage).to be_nil end it "stringifies the passed in stage" do config = AutoTagger::Configuration.new :stage => :demo - config.stage.should == "demo" + expect(config.stage).to eq("demo") end end describe "#date_separator" do it "returns the passed in option" do config = AutoTagger::Configuration.new :date_separator => "-" - config.date_separator.should == "-" + expect(config.date_separator).to eq("-") end it "defaults to an empty string" do config = AutoTagger::Configuration.new - config.date_separator.should == "" + expect(config.date_separator).to eq("") end end describe "#dry_run?" do it "returns the passed in option" do config = AutoTagger::Configuration.new :dry_run => true - config.dry_run?.should == true + expect(config.dry_run?).to eq(true) config = AutoTagger::Configuration.new :dry_run => false - config.dry_run?.should == false + expect(config.dry_run?).to eq(false) end it "defaults to false" do config = AutoTagger::Configuration.new - config.dry_run?.should == false + expect(config.dry_run?).to eq(false) end end describe "#verbose?" do it "returns the passed in option" do config = AutoTagger::Configuration.new :verbose => true - config.verbose?.should == true + expect(config.verbose?).to eq(true) config = AutoTagger::Configuration.new :verbose => false - config.verbose?.should == false + expect(config.verbose?).to eq(false) end it "defaults to false" do config = AutoTagger::Configuration.new - config.verbose?.should == false + expect(config.verbose?).to eq(false) end end describe "#offline?" do it "returns the passed in option" do config = AutoTagger::Configuration.new :offline => true - config.offline?.should == true + expect(config.offline?).to eq(true) config = AutoTagger::Configuration.new :offline => false - config.offline?.should == false + expect(config.offline?).to eq(false) end it "defaults to false" do config = AutoTagger::Configuration.new - config.offline?.should == false + expect(config.offline?).to eq(false) end end describe "#push_refs" do it "defaults to true" do config = AutoTagger::Configuration.new - config.push_refs?.should == true + expect(config.push_refs?).to eq(true) end it "respects the passed-in option" do config = AutoTagger::Configuration.new :push_refs => true - config.push_refs?.should == true + expect(config.push_refs?).to eq(true) config = AutoTagger::Configuration.new :push_refs => false - config.push_refs?.should == false + expect(config.push_refs?).to eq(false) end it "returns false if offline is true" do config = AutoTagger::Configuration.new :offline => true, :push_refs => true - config.push_refs?.should == false + expect(config.push_refs?).to eq(false) end end describe "#fetch_refs" do it "defaults to true" do config = AutoTagger::Configuration.new - config.fetch_refs?.should == true + expect(config.fetch_refs?).to eq(true) end it "respects the passed-in option" do config = AutoTagger::Configuration.new :fetch_refs => true - config.fetch_refs?.should == true + expect(config.fetch_refs?).to eq(true) config = AutoTagger::Configuration.new :fetch_refs => false - config.fetch_refs?.should == false + expect(config.fetch_refs?).to eq(false) end it "returns false if offline is true" do config = AutoTagger::Configuration.new :offline => true, :fetch_refs => true - config.fetch_refs?.should == false + expect(config.fetch_refs?).to eq(false) end end describe "#executable" do it "returns the passed in executable" do config = AutoTagger::Configuration.new :executable => "/usr/bin/git" - config.executable.should == "/usr/bin/git" + expect(config.executable).to eq("/usr/bin/git") end it "defaults to git" do config = AutoTagger::Configuration.new - config.executable.should == "git" + expect(config.executable).to eq("git") end end describe "#refs_to_keep" do it "return the refs to keep" do config = AutoTagger::Configuration.new :refs_to_keep => 4 - config.refs_to_keep.should == 4 + expect(config.refs_to_keep).to eq(4) end it "defaults to 1" do config = AutoTagger::Configuration.new - config.refs_to_keep.should == 1 + expect(config.refs_to_keep).to eq(1) end it "always returns a FixNum" do config = AutoTagger::Configuration.new :refs_to_keep => "4" - config.refs_to_keep.should == 4 + expect(config.refs_to_keep).to eq(4) end end describe "#remote" do it "returns the passed in option" do config = AutoTagger::Configuration.new :remote => "myorigin" - config.remote.should == "myorigin" + expect(config.remote).to eq("myorigin") end it "defaults to origin" do config = AutoTagger::Configuration.new - config.remote.should == "origin" + expect(config.remote).to eq("origin") end end describe "#ref_path" do it "returns the passed in option" do config = AutoTagger::Configuration.new :ref_path => "auto_tags" - config.ref_path.should == "auto_tags" + expect(config.ref_path).to eq("auto_tags") end it "defaults to tags" do config = AutoTagger::Configuration.new - config.ref_path.should == "tags" + expect(config.ref_path).to eq("tags") end it "raises an error if you pass in heads or remotes" do - proc do + expect do config = AutoTagger::Configuration.new :ref_path => "heads" - config.ref_path.should == "tags" - end.should raise_error(AutoTagger::Configuration::InvalidRefPath) + expect(config.ref_path).to eq("tags") + end.to raise_error(AutoTagger::Configuration::InvalidRefPath) - proc do + expect do config = AutoTagger::Configuration.new :ref_path => "heads" - config.ref_path.should == "tags" - end.should raise_error(AutoTagger::Configuration::InvalidRefPath) + expect(config.ref_path).to eq("tags") + end.to raise_error(AutoTagger::Configuration::InvalidRefPath) end end diff --git a/spec/auto_tagger/git/ref_set_spec.rb b/spec/auto_tagger/git/ref_set_spec.rb index eb2953c..9cc7147 100644 --- a/spec/auto_tagger/git/ref_set_spec.rb +++ b/spec/auto_tagger/git/ref_set_spec.rb @@ -13,60 +13,60 @@ describe "#all" do it "returns an array of refs" do - @repo.should_receive(:read).with("show-ref").and_return(@refstring) + expect(@repo).to receive(:read).with("show-ref").and_return(@refstring) refs = @ref_set.all - refs.length.should == 2 - refs.first.name.should == "refs/tags/200808080808" - refs.first.sha.should == "23087241c495773c8eece1c195cc453a8055c4eb" + expect(refs.length).to eq(2) + expect(refs.first.name).to eq("refs/tags/200808080808") + expect(refs.first.sha).to eq("23087241c495773c8eece1c195cc453a8055c4eb") end end describe "#find_by_sha" do it "returns a ref by the sha" do - @repo.should_receive(:read).with("show-ref").and_return(@refstring) + expect(@repo).to receive(:read).with("show-ref").and_return(@refstring) ref = @ref_set.find_by_sha("23087241c495773b8eecr1c195cd453a8056c4eb") - ref.name.should == "refs/tags/200808080809" + expect(ref.name).to eq("refs/tags/200808080809") end it "returns nil if it's not found" do - @repo.should_receive(:read).with("show-ref").and_return(@refstring) - @ref_set.find_by_sha("abc123").should be_nil + expect(@repo).to receive(:read).with("show-ref").and_return(@refstring) + expect(@ref_set.find_by_sha("abc123")).to be_nil end end describe "#create" do it "instantiates and saves a ref" do - @repo.should_receive(:exec).with("update-ref refs/auto_tags/demo/2008 abc123") + expect(@repo).to receive(:exec).with("update-ref refs/auto_tags/demo/2008 abc123") @ref_set.create "abc123", "refs/auto_tags/demo/2008" end it "returns the ref" do ref = @ref_set.create("abc123", "refs/auto_tags/demo/2008") - ref.sha.should == "abc123" - ref.name.should == "refs/auto_tags/demo/2008" + expect(ref.sha).to eq("abc123") + expect(ref.name).to eq("refs/auto_tags/demo/2008") end end describe "#push" do it "pushes all refs to the specified remote" do - @repo.should_receive(:exec).with("push myremote refs/auto_tags/*:refs/auto_tags/*") + expect(@repo).to receive(:exec).with("push myremote refs/auto_tags/*:refs/auto_tags/*") @ref_set.push "refs/auto_tags/*", "myremote" end it "defaults to origin" do - @repo.should_receive(:exec).with("push origin refs/auto_tags/*:refs/auto_tags/*") + expect(@repo).to receive(:exec).with("push origin refs/auto_tags/*:refs/auto_tags/*") @ref_set.push "refs/auto_tags/*" end end describe "#fetch" do it "fetches all refs to the specified remote" do - @repo.should_receive(:exec).with("fetch myremote refs/auto_tags/*:refs/auto_tags/*") + expect(@repo).to receive(:exec).with("fetch myremote refs/auto_tags/*:refs/auto_tags/*") @ref_set.fetch "refs/auto_tags/*", "myremote" end it "defaults to origin" do - @repo.should_receive(:exec).with("fetch origin refs/auto_tags/*:refs/auto_tags/*") + expect(@repo).to receive(:exec).with("fetch origin refs/auto_tags/*:refs/auto_tags/*") @ref_set.fetch "refs/auto_tags/*" end end diff --git a/spec/auto_tagger/git/ref_spec.rb b/spec/auto_tagger/git/ref_spec.rb index 417273a..e8eccef 100644 --- a/spec/auto_tagger/git/ref_spec.rb +++ b/spec/auto_tagger/git/ref_spec.rb @@ -9,37 +9,37 @@ describe "#to_s" do it "returns the sha and the name" do - @ref.to_s.should == "85af4e refs/auto_tags/ci" + expect(@ref.to_s).to eq("85af4e refs/auto_tags/ci") end end describe "#delete_locally" do it "sends the update ref command" do - @repo.should_receive(:exec).with("update-ref -d refs/auto_tags/ci") + expect(@repo).to receive(:exec).with("update-ref -d refs/auto_tags/ci") @ref.delete_locally end end describe "#delete_on_remote" do it "pushes nothing to the remote ref" do - @repo.should_receive(:exec).with("push myorigin :refs/auto_tags/ci") + expect(@repo).to receive(:exec).with("push myorigin :refs/auto_tags/ci") @ref.delete_on_remote "myorigin" end it "defaults to origin" do - @repo.should_receive(:exec).with("push origin :refs/auto_tags/ci") + expect(@repo).to receive(:exec).with("push origin :refs/auto_tags/ci") @ref.delete_on_remote end end describe "#save" do it "should send the correct update-ref command" do - @repo.should_receive(:exec).with("update-ref refs/auto_tags/ci 85af4e") + expect(@repo).to receive(:exec).with("update-ref refs/auto_tags/ci 85af4e") @ref.save end it "returns the ref" do - @ref.save.should == @ref + expect(@ref.save).to eq(@ref) end end diff --git a/spec/auto_tagger/git/repo_spec.rb b/spec/auto_tagger/git/repo_spec.rb index 67c63b8..2c20a44 100644 --- a/spec/auto_tagger/git/repo_spec.rb +++ b/spec/auto_tagger/git/repo_spec.rb @@ -3,104 +3,104 @@ describe AutoTagger::Git::Repo do before do - File.stub(:exists?).and_return(true) + allow(File).to receive(:exists?).and_return(true) @commander = double(AutoTagger::Commander) end describe "#path" do it "raises an error if the path is blank" do - proc do + expect do AutoTagger::Git::Repo.new(" ").path - end.should raise_error(AutoTagger::Git::Repo::NoPathProvidedError) + end.to raise_error(AutoTagger::Git::Repo::NoPathProvidedError) - proc do + expect do AutoTagger::Git::Repo.new(nil).path - end.should raise_error(AutoTagger::Git::Repo::NoPathProvidedError) + end.to raise_error(AutoTagger::Git::Repo::NoPathProvidedError) end it "raises and error if the path does not exist" do - File.should_receive(:exists?).with("/foo").and_return(false) - proc do + expect(File).to receive(:exists?).with("/foo").and_return(false) + expect do AutoTagger::Git::Repo.new("/foo").path - end.should raise_error(AutoTagger::Git::Repo::NoSuchPathError) + end.to raise_error(AutoTagger::Git::Repo::NoSuchPathError) end it "raises and error if the path does not have a .git directory" do - File.should_receive(:exists?).with("/foo").and_return(true) - File.should_receive(:exists?).with("/foo/.git").and_return(false) - proc do + expect(File).to receive(:exists?).with("/foo").and_return(true) + expect(File).to receive(:exists?).with("/foo/.git").and_return(false) + expect do AutoTagger::Git::Repo.new("/foo").path - end.should raise_error(AutoTagger::Git::Repo::InvalidGitRepositoryError) + end.to raise_error(AutoTagger::Git::Repo::InvalidGitRepositoryError) end it "returns the path if it's a git directory" do - File.should_receive(:exists?).with("/foo").and_return(true) - File.should_receive(:exists?).with("/foo/.git").and_return(true) - AutoTagger::Git::Repo.new("/foo").path.should == "/foo" + expect(File).to receive(:exists?).with("/foo").and_return(true) + expect(File).to receive(:exists?).with("/foo/.git").and_return(true) + expect(AutoTagger::Git::Repo.new("/foo").path).to eq("/foo") end end describe "#refs" do it "returns a new refset" do - AutoTagger::Git::Repo.new("/foo").refs.should be_kind_of(AutoTagger::Git::RefSet) + expect(AutoTagger::Git::Repo.new("/foo").refs).to be_kind_of(AutoTagger::Git::RefSet) end end describe "#==" do it "returns true if the path matches" do - AutoTagger::Git::Repo.new("/foo").should == AutoTagger::Git::Repo.new("/foo") + expect(AutoTagger::Git::Repo.new("/foo")).to eq(AutoTagger::Git::Repo.new("/foo")) end it "returns false if the path does not match" do - AutoTagger::Git::Repo.new("/foo").should_not == AutoTagger::Git::Repo.new("/bar") + expect(AutoTagger::Git::Repo.new("/foo")).not_to eq(AutoTagger::Git::Repo.new("/bar")) end end describe "#latest_commit_sha" do it "returns the latest sha from HEAD" do repo = AutoTagger::Git::Repo.new("/foo") - repo.should_receive(:read).with("rev-parse HEAD").and_return(" abc123 ") - repo.latest_commit_sha.should == "abc123" + expect(repo).to receive(:read).with("rev-parse HEAD").and_return(" abc123 ") + expect(repo.latest_commit_sha).to eq("abc123") end end describe "#read" do it "formats the command and sends it to the system" do repo = AutoTagger::Git::Repo.new("/foo") - repo.stub(:commander).and_return(@commander) - @commander.should_receive(:read).with("git rev-parse HEAD").and_return("lkj") - repo.read("rev-parse HEAD").should == "lkj" + allow(repo).to receive(:commander).and_return(@commander) + expect(@commander).to receive(:read).with("git rev-parse HEAD").and_return("lkj") + expect(repo.read("rev-parse HEAD")).to eq("lkj") end it "respects the passed in executable" do repo = AutoTagger::Git::Repo.new("/foo", :executable => "/usr/bin/git") - repo.stub(:commander).and_return(@commander) - @commander.should_receive(:read).with("/usr/bin/git rev-parse HEAD").and_return("lkj") - repo.read("rev-parse HEAD").should == "lkj" + allow(repo).to receive(:commander).and_return(@commander) + expect(@commander).to receive(:read).with("/usr/bin/git rev-parse HEAD").and_return("lkj") + expect(repo.read("rev-parse HEAD")).to eq("lkj") end end describe "#exec" do it "sends the exec command to the commander" do repo = AutoTagger::Git::Repo.new("/foo") - repo.stub(:commander).and_return(@commander) - @commander.should_receive(:execute).with("git push origin master").and_return(true) + allow(repo).to receive(:commander).and_return(@commander) + expect(@commander).to receive(:execute).with("git push origin master").and_return(true) repo.exec("push origin master") end it "raises an error if the command returns false" do repo = AutoTagger::Git::Repo.new("/foo") - repo.stub(:commander).and_return(@commander) - @commander.should_receive(:execute).with("git push origin master").and_return(false) - proc do + allow(repo).to receive(:commander).and_return(@commander) + expect(@commander).to receive(:execute).with("git push origin master").and_return(false) + expect do repo.exec("push origin master") - end.should raise_error(AutoTagger::Git::Repo::GitCommandFailedError) + end.to raise_error(AutoTagger::Git::Repo::GitCommandFailedError) end it "sends the print command to the commander if execute_commands is false" do repo = AutoTagger::Git::Repo.new("/foo", :execute_commands => false) - repo.stub(:commander).and_return(@commander) - @commander.should_receive(:print).with("git push origin master") + allow(repo).to receive(:commander).and_return(@commander) + expect(@commander).to receive(:print).with("git push origin master") repo.exec("push origin master") end end diff --git a/spec/auto_tagger/options_spec.rb b/spec/auto_tagger/options_spec.rb index 5337258..e1d1967 100644 --- a/spec/auto_tagger/options_spec.rb +++ b/spec/auto_tagger/options_spec.rb @@ -5,62 +5,62 @@ shared_examples_for "common options" do it "understands --date-separator" do options = AutoTagger::Options.from_command_line ["--date-separator=-"] - options[:date_separator].should == "-" + expect(options[:date_separator]).to eq("-") end it "understands --remote" do options = AutoTagger::Options.from_command_line ["--remote=origin"] - options[:remote].should == "origin" + expect(options[:remote]).to eq("origin") end it "understands --ref-path" do options = AutoTagger::Options.from_command_line ["--ref-path=tags"] - options[:ref_path].should == "tags" + expect(options[:ref_path]).to eq("tags") end it "understands --stages" do options = AutoTagger::Options.from_command_line ["--stages=foo,bar,baz"] - options[:stages].should == "foo,bar,baz" + expect(options[:stages]).to eq("foo,bar,baz") end it "understands --refs-to-keep" do options = AutoTagger::Options.from_command_line ["--refs-to-keep=4"] - options[:refs_to_keep].should == 4 + expect(options[:refs_to_keep]).to eq(4) end it "understands --dry-run" do options = AutoTagger::Options.from_command_line ["--dry-run"] - options[:dry_run].should eq(true) + expect(options[:dry_run]).to eq(true) options = AutoTagger::Options.from_command_line ["--dry-run=true"] - options[:dry_run].should eq(true) + expect(options[:dry_run]).to eq(true) options = AutoTagger::Options.from_command_line ["--dry-run=false"] - options[:dry_run].should eq(false) + expect(options[:dry_run]).to eq(false) end it "understands --fetch-refs" do options = AutoTagger::Options.from_command_line ["--fetch-refs=true"] - options[:fetch_refs].should == true + expect(options[:fetch_refs]).to eq(true) options = AutoTagger::Options.from_command_line ["--fetch-refs=false"] - options[:fetch_refs].should == false + expect(options[:fetch_refs]).to eq(false) end it "understands --push-refs" do options = AutoTagger::Options.from_command_line ["--push-refs=true"] - options[:push_refs].should == true + expect(options[:push_refs]).to eq(true) options = AutoTagger::Options.from_command_line ["--push-refs=false"] - options[:push_refs].should == false + expect(options[:push_refs]).to eq(false) end it "understands --offline" do options = AutoTagger::Options.from_command_line ["--offline"] - options[:offline].should be_nil + expect(options[:offline]).to be_nil options = AutoTagger::Options.from_command_line ["--offline=true"] - options[:offline].should eq(true) + expect(options[:offline]).to eq(true) end end @@ -70,86 +70,86 @@ it "takes the first argument to be the stage" do options = AutoTagger::Options.from_command_line ["ci"] - options[:stage].should == "ci" + expect(options[:stage]).to eq("ci") end it "takes the second argument to be the path" do options = AutoTagger::Options.from_command_line ["ci", "../"] - options[:path].should == "../" + expect(options[:path]).to eq("../") end it "understands --opts-file" do options = AutoTagger::Options.from_command_line ["--opts-file=foo"] - options[:opts_file].should == "foo" + expect(options[:opts_file]).to eq("foo") end it "understands all help options" do options = AutoTagger::Options.from_command_line ["ci"] - options[:show_help].should be_nil + expect(options[:show_help]).to be_nil options = AutoTagger::Options.from_command_line ["help"] - options[:show_help].should == true + expect(options[:show_help]).to eq(true) options = AutoTagger::Options.from_command_line ["-h"] - options[:show_help].should == true + expect(options[:show_help]).to eq(true) options = AutoTagger::Options.from_command_line ["--help"] - options[:show_help].should == true + expect(options[:show_help]).to eq(true) options = AutoTagger::Options.from_command_line ["-?"] - options[:show_help].should == true + expect(options[:show_help]).to eq(true) options = AutoTagger::Options.from_command_line [] - options[:show_help].should == true + expect(options[:show_help]).to eq(true) end it "understands --version" do options = AutoTagger::Options.from_command_line ["ci"] - options[:show_version].should be_nil + expect(options[:show_version]).to be_nil options = AutoTagger::Options.from_command_line ["version"] - options[:show_version].should == true + expect(options[:show_version]).to eq(true) options = AutoTagger::Options.from_command_line ["--version"] - options[:show_version].should == true + expect(options[:show_version]).to eq(true) options = AutoTagger::Options.from_command_line ["-v"] - options[:show_version].should == true + expect(options[:show_version]).to eq(true) end it "chooses the right command" do options = AutoTagger::Options.from_command_line ["config"] - options[:command].should == :config + expect(options[:command]).to eq(:config) options = AutoTagger::Options.from_command_line ["version"] - options[:command].should == :version + expect(options[:command]).to eq(:version) options = AutoTagger::Options.from_command_line ["-v"] - options[:command].should == :version + expect(options[:command]).to eq(:version) options = AutoTagger::Options.from_command_line ["help"] - options[:command].should == :help + expect(options[:command]).to eq(:help) options = AutoTagger::Options.from_command_line [""] - options[:command].should == :help + expect(options[:command]).to eq(:help) options = AutoTagger::Options.from_command_line ["cleanup"] - options[:command].should == :cleanup + expect(options[:command]).to eq(:cleanup) options = AutoTagger::Options.from_command_line ["list"] - options[:command].should == :list + expect(options[:command]).to eq(:list) options = AutoTagger::Options.from_command_line ["create"] - options[:command].should == :create + expect(options[:command]).to eq(:create) options = AutoTagger::Options.from_command_line ["ci"] - options[:command].should == :create + expect(options[:command]).to eq(:create) options = AutoTagger::Options.from_command_line ["delete_locally"] - options[:command].should == :delete_locally + expect(options[:command]).to eq(:delete_locally) options = AutoTagger::Options.from_command_line ["delete_on_remote"] - options[:command].should == :delete_on_remote + expect(options[:command]).to eq(:delete_on_remote) end end diff --git a/spec/auto_tagger/recipes_spec.rb b/spec/auto_tagger/recipes_spec.rb index 8e4a26f..c0a5d25 100644 --- a/spec/auto_tagger/recipes_spec.rb +++ b/spec/auto_tagger/recipes_spec.rb @@ -6,29 +6,29 @@ describe "create_ref" do before do @auto_tagger = double(AutoTagger::Base) - AutoTagger::Base.should_receive(:new).and_return(@auto_tagger) + expect(AutoTagger::Base).to receive(:new).and_return(@auto_tagger) @config = Capistrano::Configuration.instance = Capistrano::Configuration.new @config.load "lib/auto_tagger/recipes" - @config.stub(:real_revision).and_return("REAL_REVISION") + allow(@config).to receive(:real_revision).and_return("REAL_REVISION") @ref = double(:name => "TAG", :sha => "SHA") end it "creates a tag from the real_revision when :auto_tagger_stage is set" do - @auto_tagger.should_receive(:create_ref).with("REAL_REVISION").and_return(@ref) + expect(@auto_tagger).to receive(:create_ref).with("REAL_REVISION").and_return(@ref) @config.set :auto_tagger_stage, :ci @config.auto_tagger.create_ref end it "creates a tag from the real_revision when :stage is set" do - @auto_tagger.should_receive(:create_ref).with("REAL_REVISION").and_return(@ref) + expect(@auto_tagger).to receive(:create_ref).with("REAL_REVISION").and_return(@ref) @config.set :stage, :ci @config.auto_tagger.create_ref end it "creates a tag from HEAD when neither :auto_tagger_stage nor :stage are set" do - @auto_tagger.should_receive(:create_ref).with(no_args).and_return(@ref) + expect(@auto_tagger).to receive(:create_ref).with(no_args).and_return(@ref) @config.auto_tagger.create_ref end end