lib/adapter/spec/an_adapter.rb in adapter-0.7.0 vs lib/adapter/spec/an_adapter.rb in adapter-0.7.1
- old
+ new
@@ -1,8 +1,8 @@
shared_examples_for "an adapter" do
it "can read the client" do
- adapter.client.should == client
+ expect(adapter.client).to eq(client)
end
let(:key) { 'key' }
let(:key2) { 'key2' }
@@ -22,18 +22,18 @@
}
}
describe "#read" do
it "returns nil if key not available" do
- adapter.read(key).should be_nil
+ expect(adapter.read(key)).to be_nil
end
it "returns attributes if key available" do
adapter.write(key, attributes)
result = adapter.read(key)
attributes.each do |column, value|
- result[column].should eq(value)
+ expect(result[column]).to eq(value)
end
end
it "accepts options" do
expect {
@@ -50,31 +50,31 @@
it "returns Hash of keys and attributes" do
result = adapter.read_multiple([key, key2])
attributes.each do |column, value|
- result[key][column].should eq(value)
+ expect(result[key][column]).to eq(value)
end
attributes2.each do |column, value|
- result[key2][column].should eq(value)
+ expect(result[key2][column]).to eq(value)
end
end
context "with mix of keys that are and are not available" do
it "returns Hash of keys and attributes where unavailable keys are nil" do
result = adapter.read_multiple([key, key2, unavailable_key])
attributes.each do |column, value|
- result[key][column].should eq(value)
+ expect(result[key][column]).to eq(value)
end
attributes2.each do |column, value|
- result[key2][column].should eq(value)
+ expect(result[key2][column]).to eq(value)
end
- result[unavailable_key].should be_nil
+ expect(result[unavailable_key]).to be_nil
end
end
it "accepts options" do
expect {
@@ -84,15 +84,15 @@
end
describe "#key?" do
it "returns true if key available" do
adapter.write(key, attributes)
- adapter.key?(key).should be_true
+ expect(adapter.key?(key)).to be(true)
end
it "returns false if key not available" do
- adapter.key?(key).should be_false
+ expect(adapter.key?(key)).to be(false)
end
it "accepts options" do
expect {
adapter.key?(key, :something => 'else')
@@ -102,38 +102,38 @@
describe "#fetch" do
context "with key not available" do
context "with default attributes" do
it "returns default" do
- adapter.fetch(key, {}).should eq({})
+ expect(adapter.fetch(key, {})).to eq({})
end
end
context "with default block" do
it "returns value of yielded block" do
- adapter.fetch(key) { |k| {} }.should eq({})
+ expect(adapter.fetch(key) { |k| {} }).to eq({})
end
end
end
context "with key that is available" do
context "with default attributes" do
it "returns result of read instead of default" do
adapter.write(key, attributes2)
result = adapter.fetch(key, attributes)
attributes2.each do |column, value|
- result[column].should eq(value)
+ expect(result[column]).to eq(value)
end
end
end
context "with default block" do
it "does not run the block" do
adapter.write(key, attributes)
unaltered = 'unaltered'
adapter.fetch(key) { unaltered = 'altered' }
- unaltered.should eq('unaltered')
+ expect(unaltered).to eq('unaltered')
end
end
end
it "accepts options" do
@@ -146,11 +146,11 @@
describe "#write" do
it "sets key to attributes" do
adapter.write(key, attributes)
result = adapter.read(key)
attributes.each do |column, value|
- result[column].should eq(value)
+ expect(result[column]).to eq(value)
end
end
it "accepts options" do
expect {
@@ -161,21 +161,21 @@
describe "#delete" do
context "when key available" do
it "removes key" do
adapter.write(key, attributes)
- adapter.key?(key).should be_true
+ expect(adapter.key?(key)).to be(true)
adapter.delete(key)
- adapter.key?(key).should be_false
+ expect(adapter.key?(key)).to be(false)
end
end
context "when key not available" do
it "does not complain" do
- adapter.key?(key).should be_false
+ expect(adapter.key?(key)).to be(false)
adapter.delete(key)
- adapter.key?(key).should be_false
+ expect(adapter.key?(key)).to be(false)
end
end
it "accepts options" do
expect {
@@ -186,14 +186,14 @@
describe "#clear" do
it "removes all available keys" do
adapter.write(key, attributes)
adapter.write(key2, attributes2)
- adapter.key?(key).should be_true
- adapter.key?(key2).should be_true
+ expect(adapter.key?(key)).to be(true)
+ expect(adapter.key?(key2)).to be(true)
adapter.clear
- adapter.key?(key).should be_false
- adapter.key?(key2).should be_false
+ expect(adapter.key?(key)).to be(false)
+ expect(adapter.key?(key2)).to be(false)
end
it "accepts options" do
expect {
adapter.clear(:something => 'else')