diff options
author | Claire McQuin <claire@getchef.com> | 2014-10-29 15:14:22 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-10-29 15:59:04 -0700 |
commit | 5fed7a65a2f024d964ecf2de1bcf2911cf8a600c (patch) | |
tree | 14cc6968e4fe4fd2485c0211088b25c645a80a4b /spec/unit/file_cache_spec.rb | |
parent | b92c309b0f1aa0837f76ab89d6c81c36076ceca9 (diff) | |
download | chef-5fed7a65a2f024d964ecf2de1bcf2911cf8a600c.tar.gz |
Update to RSpec 3.
Diffstat (limited to 'spec/unit/file_cache_spec.rb')
-rw-r--r-- | spec/unit/file_cache_spec.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/spec/unit/file_cache_spec.rb b/spec/unit/file_cache_spec.rb index f57f11dcc2..a24c3d3b97 100644 --- a/spec/unit/file_cache_spec.rb +++ b/spec/unit/file_cache_spec.rb @@ -32,11 +32,11 @@ describe Chef::FileCache do describe "when the relative path to the cache file doesn't exist" do it "creates intermediate directories as needed" do Chef::FileCache.store("whiz/bang", "I found a poop") - File.should exist(File.join(@file_cache_path, 'whiz')) + expect(File).to exist(File.join(@file_cache_path, 'whiz')) end it "creates the cached file at the correct relative path" do - File.should_receive(:open).with(File.join(@file_cache_path, 'whiz', 'bang'), "w",416).and_yield(@io) + expect(File).to receive(:open).with(File.join(@file_cache_path, 'whiz', 'bang'), "w",416).and_yield(@io) Chef::FileCache.store("whiz/bang", "borkborkbork") end @@ -44,12 +44,12 @@ describe Chef::FileCache do describe "when storing a file" do before do - File.stub(:open).and_yield(@io) + allow(File).to receive(:open).and_yield(@io) end it "should print the contents to the file" do Chef::FileCache.store("whiz/bang", "borkborkbork") - @io.string.should == "borkborkbork" + expect(@io.string).to eq("borkborkbork") end end @@ -58,11 +58,11 @@ describe Chef::FileCache do it "finds and reads the cached file" do FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz')) File.open(File.join(@file_cache_path, 'whiz', 'bang'), 'w') { |f| f.print("borkborkbork") } - Chef::FileCache.load('whiz/bang').should == 'borkborkbork' + expect(Chef::FileCache.load('whiz/bang')).to eq('borkborkbork') end it "should raise a Chef::Exceptions::FileNotFound if the file doesn't exist" do - lambda { Chef::FileCache.load('whiz/bang') }.should raise_error(Chef::Exceptions::FileNotFound) + expect { Chef::FileCache.load('whiz/bang') }.to raise_error(Chef::Exceptions::FileNotFound) end end @@ -74,7 +74,7 @@ describe Chef::FileCache do it "unlinks the file" do Chef::FileCache.delete("whiz/bang") - File.should_not exist(File.join(@file_cache_path, 'whiz', 'bang')) + expect(File).not_to exist(File.join(@file_cache_path, 'whiz', 'bang')) end end @@ -88,11 +88,11 @@ describe Chef::FileCache do end it "should return the relative paths" do - Chef::FileCache.list.sort.should == %w{snappy/patter whiz/bang} + expect(Chef::FileCache.list.sort).to eq(%w{snappy/patter whiz/bang}) end it "searches for cached files by globbing" do - Chef::FileCache.find('snappy/**/*').should == %w{snappy/patter} + expect(Chef::FileCache.find('snappy/**/*')).to eq(%w{snappy/patter}) end end @@ -104,11 +104,11 @@ describe Chef::FileCache do it "has a key if the corresponding cache file exists" do FileUtils.touch(File.join(@file_cache_path, 'whiz', 'bang')) - Chef::FileCache.should have_key("whiz/bang") + expect(Chef::FileCache).to have_key("whiz/bang") end it "doesn't have a key if the corresponding cache file doesn't exist" do - Chef::FileCache.should_not have_key("whiz/bang") + expect(Chef::FileCache).not_to have_key("whiz/bang") end end end |