vignette 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vignette/object_extensions.rb +12 -6
- data/lib/vignette/version.rb +1 -1
- data/spec/lib/vignette_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e339a4120f9d2aa60652c739eefe130f89bbf1
|
4
|
+
data.tar.gz: cc3e420a4134dec09e1fe1ce5c91c2b3a5d12d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7daa2a02433d64a36e53cb0096f071c3d5b232c545af82ece0319390c4956dce75af82367261725050da19939e53fc8c528ec69d731fe81edb367c00b52cfa4d
|
7
|
+
data.tar.gz: 6c1d9144b845a1807d2e42ecfa3785a710d2cd3c3e582988f970599ad72e26fa754f6aa7e69de71bf064a3e985cc5b9ad68d79daa191a2405fbfec3cf3dbc625
|
@@ -14,14 +14,20 @@ module ObjectExtensions
|
|
14
14
|
key = "vignette_#{vignette_crc}"
|
15
15
|
test_name = nil
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
else
|
17
|
+
store = Vignette.get_store
|
18
|
+
|
19
|
+
test_name = if name.present?
|
21
20
|
name
|
22
|
-
|
21
|
+
elsif store[:vt] && original_name = JSON(store[:vt])[vignette_crc]
|
22
|
+
original_name
|
23
|
+
else
|
24
|
+
loc = caller_locations(1,1).first
|
25
|
+
new_name = "(#{Vignette::strip_path(loc.absolute_path)}:#{loc.lineno})"
|
23
26
|
|
24
|
-
|
27
|
+
store[:vt] = ( store[:vt].present? ? JSON(store[:vt]) : {} ).merge(vignette_crc => new_name).to_json
|
28
|
+
|
29
|
+
new_name
|
30
|
+
end
|
25
31
|
|
26
32
|
choice = store[key] ||= Kernel.rand(length) # Store key into storage if not available
|
27
33
|
result = self[choice.to_i]
|
data/lib/vignette/version.rb
CHANGED
data/spec/lib/vignette_spec.rb
CHANGED
@@ -20,6 +20,14 @@ describe Vignette do
|
|
20
20
|
expect(array.vignette).to eq('b'); line = __LINE__ # for tracking line number
|
21
21
|
expect(Vignette.tests).to eq({"(vignette_spec.rb:#{line})" => 'b'})
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'should store tests even if we call on different lines' do
|
25
|
+
expect(array.vignette).to eq('b'); line = __LINE__
|
26
|
+
expect(Vignette.tests).to eq({"(vignette_spec.rb:#{line})" => 'b'})
|
27
|
+
|
28
|
+
expect(array.vignette).to eq('b'); new_line = __LINE__
|
29
|
+
expect(Vignette.tests).to eq({"(vignette_spec.rb:#{line})" => 'b'})
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
context "for multiple runs" do
|