summaryrefslogtreecommitdiff
path: root/spec/unit/provider/deploy
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-10-24 18:12:50 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-10-24 18:12:50 -0700
commitbd0b0a34e4dbb60fe61bbc8716df90e8f7c7d19a (patch)
treeacc7a2d09b2cec8eed863218c0400cd15cd27854 /spec/unit/provider/deploy
parentbdce1c5619fde7d277262df9336e06f73e4fc3f8 (diff)
downloadchef-bd0b0a34e4dbb60fe61bbc8716df90e8f7c7d19a.tar.gz
updating resources/providers unit tests to rpsec3
mechanically generated patch using transpec 2.3.7 gem
Diffstat (limited to 'spec/unit/provider/deploy')
-rw-r--r--spec/unit/provider/deploy/revision_spec.rb44
-rw-r--r--spec/unit/provider/deploy/timestamped_spec.rb6
2 files changed, 25 insertions, 25 deletions
diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb
index 9fa8bdf826..4ca64e3445 100644
--- a/spec/unit/provider/deploy/revision_spec.rb
+++ b/spec/unit/provider/deploy/revision_spec.rb
@@ -21,7 +21,7 @@ require 'spec_helper'
describe Chef::Provider::Deploy::Revision do
before do
- Chef::Platform.stub(:windows?) { false }
+ allow(Chef::Platform).to receive(:windows?) { false }
@temp_dir = Dir.mktmpdir
Chef::Config[:file_cache_path] = @temp_dir
@resource = Chef::Resource::Deploy.new("/my/deploy/dir")
@@ -32,7 +32,7 @@ describe Chef::Provider::Deploy::Revision do
@provider = Chef::Provider::Deploy::Revision.new(@resource, @run_context)
@provider.load_current_resource
@runner = double("runnah")
- Chef::Runner.stub(:new).and_return(@runner)
+ allow(Chef::Runner).to receive(:new).and_return(@runner)
@expected_release_dir = "/my/deploy/dir/releases/8a3195bf3efa246f743c5dfa83683201880f935c"
end
@@ -43,41 +43,41 @@ describe Chef::Provider::Deploy::Revision do
it "uses the resolved revision from the SCM as the release slug" do
- @provider.scm_provider.stub(:revision_slug).and_return("uglySlugly")
- @provider.send(:release_slug).should == "uglySlugly"
+ allow(@provider.scm_provider).to receive(:revision_slug).and_return("uglySlugly")
+ expect(@provider.send(:release_slug)).to eq("uglySlugly")
end
it "deploys to a dir named after the revision" do
- @provider.release_path.should == @expected_release_dir
+ expect(@provider.release_path).to eq(@expected_release_dir)
end
it "stores the release dir in the file cache in the cleanup step" do
- FileUtils.stub(:mkdir_p)
- FileUtils.stub(:cp_r)
+ allow(FileUtils).to receive(:mkdir_p)
+ allow(FileUtils).to receive(:cp_r)
@provider.cleanup!
- @provider.stub(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
+ allow(@provider).to receive(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
- @provider.all_releases.should == [@expected_release_dir,second_release]
+ expect(@provider.all_releases).to eq([@expected_release_dir,second_release])
end
it "removes a release from the file cache when it's used again in another release and append it to the end" do
- FileUtils.stub(:mkdir_p)
- FileUtils.stub(:cp_r)
+ allow(FileUtils).to receive(:mkdir_p)
+ allow(FileUtils).to receive(:cp_r)
@provider.cleanup!
- @provider.stub(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
+ allow(@provider).to receive(:release_slug).and_return("73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2")
@provider.load_current_resource
@provider.cleanup!
second_release = "/my/deploy/dir/releases/73219b87e977d9c7ba1aa57e9ad1d88fa91a0ec2"
- @provider.all_releases.should == [@expected_release_dir,second_release]
+ expect(@provider.all_releases).to eq([@expected_release_dir,second_release])
@provider.cleanup!
- @provider.stub(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
+ allow(@provider).to receive(:release_slug).and_return("8a3195bf3efa246f743c5dfa83683201880f935c")
@provider.load_current_resource
@provider.cleanup!
- @provider.all_releases.should == [second_release, @expected_release_dir]
+ expect(@provider.all_releases).to eq([second_release, @expected_release_dir])
end
it "removes a release from the file cache when it's deleted by :cleanup!" do
@@ -87,25 +87,25 @@ describe Chef::Provider::Deploy::Revision do
release_paths.each do |release_path|
@provider.send(:release_created, release_path)
end
- @provider.all_releases.should == release_paths
+ expect(@provider.all_releases).to eq(release_paths)
- FileUtils.stub(:rm_rf)
+ allow(FileUtils).to receive(:rm_rf)
@provider.cleanup!
expected_release_paths = (%w{second third fourth fifth} << @resource.revision).map do |release_name|
"/my/deploy/dir/releases/#{release_name}"
end
- @provider.all_releases.should == expected_release_paths
+ expect(@provider.all_releases).to eq(expected_release_paths)
end
it "regenerates the file cache if it's not available" do
oldest = "/my/deploy/dir/releases/oldest"
latest = "/my/deploy/dir/releases/latest"
- Dir.should_receive(:glob).with("/my/deploy/dir/releases/*").and_return([latest, oldest])
- ::File.should_receive(:ctime).with(oldest).and_return(Time.now - 10)
- ::File.should_receive(:ctime).with(latest).and_return(Time.now - 1)
- @provider.all_releases.should == [oldest, latest]
+ expect(Dir).to receive(:glob).with("/my/deploy/dir/releases/*").and_return([latest, oldest])
+ expect(::File).to receive(:ctime).with(oldest).and_return(Time.now - 10)
+ expect(::File).to receive(:ctime).with(latest).and_return(Time.now - 1)
+ expect(@provider.all_releases).to eq([oldest, latest])
end
end
diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb
index 1d42abfc05..b189d33502 100644
--- a/spec/unit/provider/deploy/timestamped_spec.rb
+++ b/spec/unit/provider/deploy/timestamped_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Provider::Deploy::Timestamped do
before do
@release_time = Time.utc( 2004, 8, 15, 16, 23, 42)
- Time.stub(:now).and_return(@release_time)
+ allow(Time).to receive(:now).and_return(@release_time)
@expected_release_dir = "/my/deploy/dir/releases/20040815162342"
@resource = Chef::Resource::Deploy.new("/my/deploy/dir")
@node = Chef::Node.new
@@ -30,11 +30,11 @@ describe Chef::Provider::Deploy::Timestamped do
@run_context = Chef::RunContext.new(@node, {}, @events)
@timestamped_deploy = Chef::Provider::Deploy::Timestamped.new(@resource, @run_context)
@runner = double("runnah")
- Chef::Runner.stub(:new).and_return(@runner)
+ allow(Chef::Runner).to receive(:new).and_return(@runner)
end
it "gives a timestamp for release_slug" do
- @timestamped_deploy.send(:release_slug).should == "20040815162342"
+ expect(@timestamped_deploy.send(:release_slug)).to eq("20040815162342")
end
end