mince_dynamo_db 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -244,7 +244,7 @@ module MinceDynamoDb # :nodoc:
|
|
244
244
|
|
245
245
|
# Takes a DynamoDB item and returns the attributes of that item as a hash
|
246
246
|
def to_hash(item)
|
247
|
-
item.attributes
|
247
|
+
item.attributes if item
|
248
248
|
end
|
249
249
|
|
250
250
|
# Takes an array of DynamoDB items and returns the attributes of each item as a hash.
|
data/spec/lib/data_store_spec.rb
CHANGED
@@ -14,8 +14,7 @@ describe MinceDynamoDb::DataStore do
|
|
14
14
|
let(:sanitized_time) { mock 'sanitized time' }
|
15
15
|
let(:sanitized_id) { mock 'sanitized id' }
|
16
16
|
let(:return_data) { mock 'return data', attributes: attributes }
|
17
|
-
let(:attributes) { mock 'attributes'
|
18
|
-
let(:hash) { mock 'hash' }
|
17
|
+
let(:attributes) { mock 'attributes' }
|
19
18
|
let(:items) { mock 'items' }
|
20
19
|
|
21
20
|
before do
|
@@ -55,12 +54,11 @@ describe MinceDynamoDb::DataStore do
|
|
55
54
|
end
|
56
55
|
|
57
56
|
it 'can read from the collection' do
|
58
|
-
|
59
|
-
item_attributes = mock 'attributes for an item', to_h: item_hash
|
57
|
+
item_attributes = mock 'attributes for an item'
|
60
58
|
item = mock 'item', attributes: item_attributes
|
61
59
|
collection.stub(items: [item])
|
62
60
|
|
63
|
-
subject.find_all(collection_name).should == [
|
61
|
+
subject.find_all(collection_name).should == [item_attributes]
|
64
62
|
end
|
65
63
|
|
66
64
|
it 'can replace a record' do
|
@@ -75,7 +73,7 @@ describe MinceDynamoDb::DataStore do
|
|
75
73
|
|
76
74
|
items.should_receive(:where).with(field => value).and_return([return_data])
|
77
75
|
|
78
|
-
subject.find(collection_name, field, value).should ==
|
76
|
+
subject.find(collection_name, field, value).should == attributes
|
79
77
|
end
|
80
78
|
|
81
79
|
it 'can delete a record that matches a criteria' do
|
@@ -104,13 +102,13 @@ describe MinceDynamoDb::DataStore do
|
|
104
102
|
it 'can get all records of a specific key value' do
|
105
103
|
items.should_receive(:where).with("key" => "value").and_return([return_data])
|
106
104
|
|
107
|
-
subject.get_all_for_key_with_value(collection_name, "key", "value").should == [
|
105
|
+
subject.get_all_for_key_with_value(collection_name, "key", "value").should == [attributes]
|
108
106
|
end
|
109
107
|
|
110
108
|
it 'can get a record of a specific key value' do
|
111
109
|
items.should_receive(:where).with({"key" => "value"}).and_return([return_data])
|
112
110
|
|
113
|
-
subject.get_for_key_with_value(collection_name, "key", "value").should ==
|
111
|
+
subject.get_for_key_with_value(collection_name, "key", "value").should == attributes
|
114
112
|
end
|
115
113
|
|
116
114
|
it 'can get all records where a value includes any of a set of values' do
|
@@ -118,7 +116,7 @@ describe MinceDynamoDb::DataStore do
|
|
118
116
|
items.should_receive(:where).with(:key1).and_return(filter)
|
119
117
|
filter.should_receive(:in).with([1,2,4]).and_return([return_data])
|
120
118
|
|
121
|
-
subject.containing_any(collection_name, "key1", [1,2,4]).should == [
|
119
|
+
subject.containing_any(collection_name, "key1", [1,2,4]).should == [attributes]
|
122
120
|
end
|
123
121
|
|
124
122
|
it 'can get all records where the array includes a value' do
|
@@ -126,7 +124,7 @@ describe MinceDynamoDb::DataStore do
|
|
126
124
|
items.should_receive(:where).with(:key).and_return(filter)
|
127
125
|
filter.should_receive(:contains).with('value').and_return([return_data])
|
128
126
|
|
129
|
-
subject.array_contains(collection_name, "key", "value").should == [
|
127
|
+
subject.array_contains(collection_name, "key", "value").should == [attributes]
|
130
128
|
end
|
131
129
|
|
132
130
|
it 'can push a value to an array for a specific record' do
|