Browse files

More flexible shared adapter spec.

By defining the unavailable key for the get_multiple check, it can be overridden in a block when testing the shared behavior, which means people can override keys.
  • Loading branch information...
1 parent b74c4d5 commit 6cff21fc7890c7e5332ad7d7106eefebe1fd4d72 @jnunemaker committed Nov 8, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/adapter/spec/an_adapter.rb
View
12 lib/adapter/spec/an_adapter.rb
@@ -6,6 +6,8 @@
let(:key) { 'key' }
let(:key2) { 'key2' }
+ let(:unavailable_key) { 'foo' }
+
let(:attributes) {
{
'one' => 'one',
@@ -82,7 +84,7 @@
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, 'foo', 'bar')
+ result = adapter.read_multiple(key, key2, unavailable_key)
attributes.each do |column, value|
result[key][column].should eq(value)
@@ -92,8 +94,7 @@
result[key2][column].should eq(value)
end
- result['foo'].should be_nil
- result['bar'].should be_nil
+ result[unavailable_key].should be_nil
end
end
end
@@ -118,7 +119,7 @@
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.get_multiple(key, key2, 'foo', 'bar')
+ result = adapter.get_multiple(key, key2, unavailable_key)
attributes.each do |column, value|
result[key][column].should eq(value)
@@ -128,8 +129,7 @@
result[key2][column].should eq(value)
end
- result['foo'].should be_nil
- result['bar'].should be_nil
+ result[unavailable_key].should be_nil
end
end
end

0 comments on commit 6cff21f

Please sign in to comment.