cartman 2.1.1 → 2.1.2
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.
- checksums.yaml +7 -0
- data/.travis.yml +2 -0
- data/cartman.gemspec +1 -1
- data/lib/cartman/cart.rb +1 -1
- data/lib/cartman/item.rb +8 -2
- data/lib/cartman/version.rb +1 -1
- data/spec/cart_spec.rb +66 -62
- data/spec/item_collection_spec.rb +2 -2
- data/spec/item_spec.rb +23 -14
- metadata +15 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f8970cd6c3e345a3149d132f149a9b7c87961346
|
4
|
+
data.tar.gz: 35fa2ab61ce928ceae66b7f0ccd40db9eb30a95b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49a16516e74c510e7454269397259b7b9af119f7e1d63cc2d3efe8cfc0f7e9c2e206e1ebd6bc132920ffdeb94136f9e7e8002060cc542aa577ddc1926ae5fc80
|
7
|
+
data.tar.gz: b95aa0e012bde84807f2dcfb6b8792aceeb4ec831412385f219831d9a08490b21624aa4ac9a99498f0f1d8399bade7ce541237fcbb5c144a1f1517da00a1f85a
|
data/.travis.yml
CHANGED
data/cartman.gemspec
CHANGED
data/lib/cartman/cart.rb
CHANGED
data/lib/cartman/item.rb
CHANGED
@@ -46,16 +46,22 @@ module Cartman
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def method_missing(method, *args, &block)
|
49
|
-
if method.to_s
|
49
|
+
if method.to_s.end_with?("=")
|
50
50
|
redis.hset _key, method[0..-2], args[0].to_s
|
51
51
|
@data.store(method[0..-2].to_sym, args[0].to_s)
|
52
52
|
version = touch
|
53
53
|
@data.store(:_version, version)
|
54
|
-
|
54
|
+
elsif @data.keys.include?(method)
|
55
55
|
@data.fetch(method)
|
56
|
+
else
|
57
|
+
super
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
61
|
+
def respond_to_missing?(method, include_private = false)
|
62
|
+
method.to_s.end_with?("=") || @data.keys.include?(method) || super
|
63
|
+
end
|
64
|
+
|
59
65
|
private
|
60
66
|
|
61
67
|
def redis
|
data/lib/cartman/version.rb
CHANGED
data/spec/cart_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe Cartman do
|
|
11
11
|
|
12
12
|
describe "#key" do
|
13
13
|
it "should return a proper key string" do
|
14
|
-
cart.send(:key).
|
14
|
+
expect(cart.send(:key)).to eq("cartman:cart:1")
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -21,21 +21,21 @@ describe Cartman do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "creates a line item key" do
|
24
|
-
Cartman.config.redis.exists("cartman:line_item:1").
|
24
|
+
expect(Cartman.config.redis.exists("cartman:line_item:1")).to be true
|
25
25
|
end
|
26
26
|
|
27
27
|
it "adds that line item key's id to the cart set" do
|
28
|
-
Cartman.config.redis.sismember(cart.send(:key), 1).
|
28
|
+
expect(Cartman.config.redis.sismember(cart.send(:key), 1)).to be true
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should expire the line_item_keys in the amount of time specified" do
|
32
|
-
cart.ttl.
|
33
|
-
Cartman.config.redis.ttl("cartman:line_item:1").
|
32
|
+
expect(cart.ttl).to eq(Cartman.config.cart_expires_in)
|
33
|
+
expect(Cartman.config.redis.ttl("cartman:line_item:1")).to eq(Cartman.config.cart_expires_in)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should add an index key to be able to look up by type and ID" do
|
37
|
-
Cartman.config.redis.exists("cartman:cart:1:index").
|
38
|
-
Cartman.config.redis.sismember("cartman:cart:1:index", "Bottle:17").
|
37
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index")).to be true
|
38
|
+
expect(Cartman.config.redis.sismember("cartman:cart:1:index", "Bottle:17")).to be true
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should squack if type and/or ID are not set" do
|
@@ -46,7 +46,7 @@ describe Cartman do
|
|
46
46
|
|
47
47
|
it "should return an Item" do
|
48
48
|
item = cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, quantity: 2)
|
49
|
-
item.class.
|
49
|
+
expect(item.class).to eq(Cartman::Item)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -55,18 +55,18 @@ describe Cartman do
|
|
55
55
|
item = cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
56
56
|
item_id = item._id
|
57
57
|
cart.remove_item(item)
|
58
|
-
Cartman.config.redis.sismember(cart.send(:key), item_id).
|
59
|
-
Cartman.config.redis.exists("cartman:line_item:#{item_id}").
|
58
|
+
expect(Cartman.config.redis.sismember(cart.send(:key), item_id)).to be false
|
59
|
+
expect(Cartman.config.redis.exists("cartman:line_item:#{item_id}")).to be false
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should not delete the indecies for other items" do
|
63
63
|
item = cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
64
64
|
item2 = cart.add_item(id: 18, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
65
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17").
|
66
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:18").
|
65
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17")).to be true
|
66
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:18")).to be true
|
67
67
|
cart.remove_item(item)
|
68
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17").
|
69
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:18").
|
68
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17")).to be false
|
69
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:18")).to be true
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -78,20 +78,20 @@ describe Cartman do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should return an ItemCollection of Items" do
|
81
|
-
cart.items.class.
|
82
|
-
cart.items.first.class.
|
83
|
-
cart.items.first.id.
|
84
|
-
cart.items.first.name.
|
81
|
+
expect(cart.items.class).to be(Cartman::ItemCollection)
|
82
|
+
expect(cart.items.first.class).to be(Cartman::Item)
|
83
|
+
expect(cart.items.first.id).to eq("17")
|
84
|
+
expect(cart.items.first.name).to eq("Bordeux")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should return all items in cart if no filter is given" do
|
88
|
-
cart.items.size.
|
88
|
+
expect(cart.items.size).to eq(3)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should return a subset of the items if a filter is given" do
|
92
|
-
cart.items("Bottle").size.
|
93
|
-
cart.items("GiftCard").size.
|
94
|
-
cart.items("SomethingElse").size.
|
92
|
+
expect(cart.items("Bottle").size).to eq(2)
|
93
|
+
expect(cart.items("GiftCard").size).to eq(1)
|
94
|
+
expect(cart.items("SomethingElse").size).to eq(0)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -106,18 +106,18 @@ describe Cartman do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should be able to tell you that an item in the cart is present" do
|
109
|
-
cart.contains?(Bottle.new(17)).
|
109
|
+
expect(cart.contains?(Bottle.new(17))).to be true
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should be able to tell you that an item in the cart is absent" do
|
113
|
-
cart.contains?(Bottle.new(20)).
|
113
|
+
expect(cart.contains?(Bottle.new(20))).to be false
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should be able to tell you that an item in the cart is absent if it's been removed" do
|
117
117
|
cart.remove_item(cart.items.first)
|
118
|
-
cart.contains?(Bottle.new(17)).
|
118
|
+
expect(cart.contains?(Bottle.new(17))).to be false
|
119
119
|
cart.remove_item(cart.items.last)
|
120
|
-
cart.contains?(Bottle.new(34)).
|
120
|
+
expect(cart.contains?(Bottle.new(34))).to be false
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -129,13 +129,13 @@ describe Cartman do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should take some object, and return the Item that corresponds to it" do
|
132
|
-
cart.find(Bottle.new(17)).quantity.
|
133
|
-
cart.find(Bottle.new(17)).name.
|
134
|
-
cart.find(Bottle.new(34)).name.
|
132
|
+
expect(cart.find(Bottle.new(17)).quantity).to eq("2")
|
133
|
+
expect(cart.find(Bottle.new(17)).name).to eq("Bordeux")
|
134
|
+
expect(cart.find(Bottle.new(34)).name).to eq("Cabernet")
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should return nil if the Item is not in the cart" do
|
138
|
-
cart.find(Bottle.new(23)).
|
138
|
+
expect(cart.find(Bottle.new(23))).to be(nil)
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -143,7 +143,7 @@ describe Cartman do
|
|
143
143
|
it "should return the number of items in the cart" do
|
144
144
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
145
145
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, quantity: 2)
|
146
|
-
cart.count.
|
146
|
+
expect(cart.count).to eq(2)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
@@ -151,7 +151,7 @@ describe Cartman do
|
|
151
151
|
it "should return the sum of the default quantity field" do
|
152
152
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
153
153
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, quantity: 2)
|
154
|
-
cart.quantity.
|
154
|
+
expect(cart.quantity).to eq(4)
|
155
155
|
end
|
156
156
|
|
157
157
|
it "should return the sum of the defined quantity field" do
|
@@ -160,7 +160,7 @@ describe Cartman do
|
|
160
160
|
end
|
161
161
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, qty: 2)
|
162
162
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, qty: 2)
|
163
|
-
cart.quantity.
|
163
|
+
expect(cart.quantity).to eq(4)
|
164
164
|
Cartman.config do |c|
|
165
165
|
c.quantity_field = :quantity
|
166
166
|
end
|
@@ -168,10 +168,14 @@ describe Cartman do
|
|
168
168
|
end
|
169
169
|
|
170
170
|
describe "#total" do
|
171
|
+
it "should return 0 when no items are in the cart" do
|
172
|
+
expect(cart.total).to eq(0)
|
173
|
+
end
|
174
|
+
|
171
175
|
it "should total the default costs field" do
|
172
176
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2)
|
173
177
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, quantity: 2)
|
174
|
-
cart.total.
|
178
|
+
expect(cart.total).to eq(368.48)
|
175
179
|
end
|
176
180
|
|
177
181
|
it "should total whatever cost field the user sets" do
|
@@ -180,7 +184,7 @@ describe Cartman do
|
|
180
184
|
end
|
181
185
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost_in_cents: 9212, quantity: 2)
|
182
186
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost_in_cents: 9212, quantity: 2)
|
183
|
-
cart.total.
|
187
|
+
expect(cart.total).to eq(36848)
|
184
188
|
Cartman.config do |c|
|
185
189
|
c.unit_cost_field = :unit_cost
|
186
190
|
end
|
@@ -192,11 +196,11 @@ describe Cartman do
|
|
192
196
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost_in_cents: 18424, quantity: 2)
|
193
197
|
cart.add_item(id: 34, type: "Bottle", name: "Cabernet", unit_cost: 92.12, cost_in_cents: 18424, quantity: 2)
|
194
198
|
cart.destroy!
|
195
|
-
Cartman.config.redis.exists("cartman:cart:1").
|
196
|
-
Cartman.config.redis.exists("cartman:line_item:1").
|
197
|
-
Cartman.config.redis.exists("cartman:line_item:2").
|
198
|
-
Cartman.config.redis.exists("cartman:cart:1:index").
|
199
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17").
|
199
|
+
expect(Cartman.config.redis.exists("cartman:cart:1")).to be false
|
200
|
+
expect(Cartman.config.redis.exists("cartman:line_item:1")).to be false
|
201
|
+
expect(Cartman.config.redis.exists("cartman:line_item:2")).to be false
|
202
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index")).to be false
|
203
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17")).to be false
|
200
204
|
end
|
201
205
|
end
|
202
206
|
|
@@ -204,52 +208,52 @@ describe Cartman do
|
|
204
208
|
it "should reset the TTL" do
|
205
209
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost_in_cents: 18424, quantity: 2)
|
206
210
|
cart.touch
|
207
|
-
cart.ttl.
|
208
|
-
Cartman.config.redis.ttl("cartman:cart:1:index").
|
209
|
-
Cartman.config.redis.ttl("cartman:cart:1:index:Bottle:17").
|
211
|
+
expect(cart.ttl).to eq(Cartman.config.cart_expires_in)
|
212
|
+
expect(Cartman.config.redis.ttl("cartman:cart:1:index")).to eq(Cartman.config.cart_expires_in)
|
213
|
+
expect(Cartman.config.redis.ttl("cartman:cart:1:index:Bottle:17")).to eq(Cartman.config.cart_expires_in)
|
210
214
|
end
|
211
215
|
|
212
216
|
it "should record that the cart was updated" do
|
213
217
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost_in_cents: 18424, quantity: 2)
|
214
218
|
cart.touch
|
215
|
-
cart.version.
|
219
|
+
expect(cart.version).to eq(2)
|
216
220
|
end
|
217
221
|
end
|
218
222
|
|
219
223
|
describe "#reassign" do
|
220
224
|
it "should only change the @uid if no key exists" do
|
221
225
|
cart.reassign(2)
|
222
|
-
cart.send(:key)[-1].
|
226
|
+
expect(cart.send(:key)[-1]).to eq("2")
|
223
227
|
end
|
224
228
|
|
225
229
|
it "should rename the key, and index_key if it exists" do
|
226
230
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost_in_cents: 18424, quantity: 1)
|
227
231
|
cart.add_item(id: 18, type: "Bottle", name: "Merlot", unit_cost: 92.12, cost_in_cents: 18424, quantity: 3)
|
228
|
-
cart.quantity.
|
232
|
+
expect(cart.quantity).to be(4)
|
229
233
|
cart.reassign(2)
|
230
|
-
cart.items.size.
|
231
|
-
Cartman::Cart.new(2).quantity.
|
232
|
-
Cartman.config.redis.exists("cartman:cart:1").
|
233
|
-
Cartman.config.redis.exists("cartman:cart:1:index").
|
234
|
-
Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17").
|
235
|
-
Cartman.config.redis.exists("cartman:cart:2").
|
236
|
-
Cartman.config.redis.exists("cartman:cart:2:index").
|
237
|
-
Cartman.config.redis.exists("cartman:cart:2:index:Bottle:17").
|
238
|
-
cart.send(:key)[-1].
|
234
|
+
expect(cart.items.size).to be(2)
|
235
|
+
expect(Cartman::Cart.new(2).quantity).to be(4)
|
236
|
+
expect(Cartman.config.redis.exists("cartman:cart:1")).to be false
|
237
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index")).to be false
|
238
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index:Bottle:17")).to be false
|
239
|
+
expect(Cartman.config.redis.exists("cartman:cart:2")).to be true
|
240
|
+
expect(Cartman.config.redis.exists("cartman:cart:2:index")).to be true
|
241
|
+
expect(Cartman.config.redis.exists("cartman:cart:2:index:Bottle:17")).to be true
|
242
|
+
expect(cart.send(:key)[-1]).to eq("2")
|
239
243
|
cart.add_item(id: 19, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost_in_cents: 18424, quantity: 2)
|
240
244
|
cart.reassign(1)
|
241
|
-
cart.items.size.
|
242
|
-
Cartman.config.redis.exists("cartman:cart:2").
|
243
|
-
Cartman.config.redis.exists("cartman:cart:2:index").
|
244
|
-
Cartman.config.redis.exists("cartman:cart:1").
|
245
|
-
Cartman.config.redis.exists("cartman:cart:1:index").
|
246
|
-
cart.send(:key)[-1].
|
245
|
+
expect(cart.items.size).to be(3)
|
246
|
+
expect(Cartman.config.redis.exists("cartman:cart:2")).to be false
|
247
|
+
expect(Cartman.config.redis.exists("cartman:cart:2:index")).to be false
|
248
|
+
expect(Cartman.config.redis.exists("cartman:cart:1")).to be true
|
249
|
+
expect(Cartman.config.redis.exists("cartman:cart:1:index")).to be true
|
250
|
+
expect(cart.send(:key)[-1]).to eq("1")
|
247
251
|
end
|
248
252
|
end
|
249
253
|
|
250
254
|
describe "#cache_key" do
|
251
255
|
it "should return /cart/{cart_id}-{version}/" do
|
252
|
-
cart.cache_key.
|
256
|
+
expect(cart.cache_key).to eq("cart/#{cart.instance_variable_get(:@uid)}-#{cart.version}")
|
253
257
|
end
|
254
258
|
end
|
255
259
|
end
|
@@ -8,7 +8,7 @@ describe Cartman do
|
|
8
8
|
Cartman.config.redis.flushdb
|
9
9
|
Object.send(:remove_const, :Bottle) if defined?(Bottle)
|
10
10
|
Bottle = double
|
11
|
-
Bottle.
|
11
|
+
allow(Bottle).to receive(:find).and_return(bottle)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#each_with_object" do
|
@@ -22,7 +22,7 @@ describe Cartman do
|
|
22
22
|
it "should work with items('Type')" do
|
23
23
|
cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, cost: 184.24, quantity: 2)
|
24
24
|
cart.add_item(id: 27, type: "UserGiftCard", unit_cost: 25, quantity: 1)
|
25
|
-
expect {
|
25
|
+
expect { cart.items("Bottle").each_with_object{}}.not_to raise_error
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
data/spec/item_spec.rb
CHANGED
@@ -4,37 +4,46 @@ describe Cartman do
|
|
4
4
|
describe Cartman::Item do
|
5
5
|
let(:cart) { Cartman::Cart.new(1) }
|
6
6
|
let(:item) { cart.add_item(id: 17, type: "Bottle", name: "Bordeux", unit_cost: 92.12, quantity: 2) }
|
7
|
-
|
7
|
+
|
8
8
|
describe "data getters and setters" do
|
9
9
|
it "should let me get data stored for the item" do
|
10
|
-
item.id.
|
11
|
-
item.type.
|
12
|
-
item.cost.
|
10
|
+
expect(item.id).to eq("17")
|
11
|
+
expect(item.type).to eq("Bottle")
|
12
|
+
expect(item.cost).to eq(184.24)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should let me modify data stored for the item" do
|
16
|
-
item.quantity.
|
16
|
+
expect(item.quantity).to eq("2")
|
17
17
|
item.quantity = 3
|
18
|
-
item.quantity.
|
18
|
+
expect(item.quantity).to eq("3")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should immediately save data back to redis" do
|
22
|
-
item.quantity.
|
22
|
+
expect(item.quantity).to eq("2")
|
23
23
|
item.quantity = 3
|
24
24
|
new_item = cart.send(:get_item, item._id)
|
25
|
-
new_item.quantity.
|
25
|
+
expect(new_item.quantity).to eq("3")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should touch the item and cart" do
|
29
29
|
expect{item.quantity = 4}.to change{item._version}.by(1)
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should raise NoMethodError if you use a getter that there isn't a key for" do
|
33
|
+
expect{ item.weight }.to raise_error(NoMethodError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should respond_to the getters and setters" do
|
37
|
+
expect(item.respond_to?(:name)).to be true
|
38
|
+
expect(item.respond_to?(:name=)).to be true
|
39
|
+
end
|
31
40
|
end
|
32
41
|
|
33
42
|
describe "#cost" do
|
34
43
|
it "should be equal to the unit_cost multiplied by the quantity" do
|
35
|
-
item.cost.
|
44
|
+
expect(item.cost).to eq(184.24)
|
36
45
|
item.quantity = 3
|
37
|
-
item.cost.
|
46
|
+
expect(item.cost).to eq(276.36)
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
@@ -42,21 +51,21 @@ describe Cartman do
|
|
42
51
|
it "should remove the item from the cart" do
|
43
52
|
item_id = item._id
|
44
53
|
item.destroy
|
45
|
-
Cartman.config.redis.sismember(cart.send(:key), item_id).
|
46
|
-
Cartman.config.redis.exists("cartman:line_item:#{item_id}").
|
54
|
+
expect(Cartman.config.redis.sismember(cart.send(:key), item_id)).to be false
|
55
|
+
expect(Cartman.config.redis.exists("cartman:line_item:#{item_id}")).to be false
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
50
59
|
describe "#touch" do
|
51
60
|
it "should record that the record was changed" do
|
52
61
|
item.touch
|
53
|
-
item._version.
|
62
|
+
expect(item._version).to eq(1)
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
57
66
|
describe "#cache_key" do
|
58
67
|
it "should return item/{id}-{version}" do
|
59
|
-
item.cache_key.
|
68
|
+
expect(item.cache_key).to eq("item/#{item._id}-#{item._version}")
|
60
69
|
end
|
61
70
|
end
|
62
71
|
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Will Cosgrove
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: redis
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 3.0.0
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: 3.0.0
|
46
41
|
description: Cartman is a frameworke agnostic, redis-backed, shopping cart system
|
47
42
|
email:
|
48
43
|
- will@willcosgrove.com
|
@@ -50,8 +45,8 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
54
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
55
50
|
- Gemfile
|
56
51
|
- LICENSE.txt
|
57
52
|
- README.md
|
@@ -69,31 +64,29 @@ files:
|
|
69
64
|
- spec/spec_helper.rb
|
70
65
|
homepage: http://github.com/willcosgrove/cartman
|
71
66
|
licenses: []
|
67
|
+
metadata: {}
|
72
68
|
post_install_message:
|
73
69
|
rdoc_options: []
|
74
70
|
require_paths:
|
75
71
|
- lib
|
76
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
73
|
requirements:
|
79
|
-
- -
|
74
|
+
- - ">="
|
80
75
|
- !ruby/object:Gem::Version
|
81
76
|
version: '0'
|
82
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
78
|
requirements:
|
85
|
-
- -
|
79
|
+
- - ">="
|
86
80
|
- !ruby/object:Gem::Version
|
87
81
|
version: '0'
|
88
82
|
requirements: []
|
89
83
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
84
|
+
rubygems_version: 2.2.2
|
91
85
|
signing_key:
|
92
|
-
specification_version:
|
86
|
+
specification_version: 4
|
93
87
|
summary: Doing shopping carts like a boss since 2012
|
94
88
|
test_files:
|
95
89
|
- spec/cart_spec.rb
|
96
90
|
- spec/item_collection_spec.rb
|
97
91
|
- spec/item_spec.rb
|
98
92
|
- spec/spec_helper.rb
|
99
|
-
has_rdoc:
|