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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b05a5bbcbc2c4930ea030d2a739829c1424cd7b
4
- data.tar.gz: d875cd3236486b99c4e3f485b32d7f25033a1a56
3
+ metadata.gz: f6e339a4120f9d2aa60652c739eefe130f89bbf1
4
+ data.tar.gz: cc3e420a4134dec09e1fe1ce5c91c2b3a5d12d27
5
5
  SHA512:
6
- metadata.gz: 16ff69be2435420d74535ca0bd8a6add17039a477f0b3bb23ffcede3d7dbdd01527a139d171a75ef18b662234b035062a91c59a35be9e1a970f7ed57935504ae
7
- data.tar.gz: a23a32a2da1445871d21c0060b246ecf2ca1b8650b52ab502736f7ff816019b4c113a9c6b3e2cad8bb48660a9dd93fd67ffa1dbee624e0319eeec61d576fb14d
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
- test_name = if name.blank?
18
- loc = caller_locations(1,1).first
19
- "(#{Vignette::strip_path(loc.absolute_path)}:#{loc.lineno})"
20
- else
17
+ store = Vignette.get_store
18
+
19
+ test_name = if name.present?
21
20
  name
22
- end
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
- store = Vignette.get_store
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]
@@ -1,3 +1,3 @@
1
1
  module Vignette
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vignette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Hayes