spec/storage_spec.rb in storage-0.1.5 vs spec/storage_spec.rb in storage-0.2.0
- old
+ new
@@ -1,46 +1,53 @@
require "spec_helper"
describe Storage do
it "should return the strategy" do
- @strategy = mock("strategy")
+ @strategy = double("strategy")
Storage::Config.strategy_class = @strategy
- Storage.strategy.should be(@strategy)
+ expect(Storage.strategy).to be(@strategy)
end
it "should return the config" do
- Storage::Strategies::S3.stub :prepare!
+ allow(Storage::Strategies::S3).to receive :prepare!
Storage.setup do |config|
config.strategy = :s3
- config.should be(Storage::Config)
+ expect(config).to be(Storage::Config)
end
end
+ it "should set strategy class based on its name" do
+ Storage::Config.strategy_class = nil
+ Storage::Config.strategy = :s3
+
+ expect(Storage::Config.strategy_class).to eq(Storage::Strategies::S3)
+ end
+
it "prepare strategy after setting its configuration" do
- Storage::Strategies::S3.should_receive(:prepare!).once
+ expect(Storage::Strategies::S3).to receive(:prepare!).once
Storage.setup {|config| config.strategy = :s3}
end
context "delegation" do
before do
- @strategy = mock("strategy")
- Storage.should_receive(:strategy).and_return(@strategy)
+ @strategy = double("strategy")
+ expect(Storage).to receive(:strategy).and_return(@strategy)
end
it "should delegate save method" do
- @strategy.should_receive(:store).with("some/file")
+ expect(@strategy).to receive(:store).with("some/file")
Storage.store "some/file"
end
it "should delegate destroy method" do
- @strategy.should_receive(:remove).with("some/file")
+ expect(@strategy).to receive(:remove).with("some/file")
Storage.remove "some/file"
end
it "should delegate get method" do
- @strategy.should_receive(:get).with("some/file")
+ expect(@strategy).to receive(:get).with("some/file")
Storage.get "some/file"
end
end
end