vignette 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vignette/object_extensions.rb +19 -4
- data/lib/vignette/version.rb +1 -1
- metadata +1 -1
@@ -5,12 +5,27 @@ module ObjectExtensions
|
|
5
5
|
|
6
6
|
# Test will select a random object from the Array
|
7
7
|
def vignette(name=nil)
|
8
|
-
key = "vignette_#{name || hash}"
|
9
|
-
test_name =
|
8
|
+
key = "vignette_#{name || hash.abs.to_s(16)}"
|
9
|
+
test_name = nil
|
10
|
+
|
11
|
+
if name.blank?
|
10
12
|
if caller[0].include?('filter.rb')
|
11
|
-
|
13
|
+
# E.g /Users/hayesgm/animals/shadow/app/views/landing/family.html.haml:11:in `_app_views_landing_family_html_haml__3008026497873467685_70232967999960'
|
14
|
+
# -> app/views/landing/family.html.haml:313c7f3a472883ba
|
15
|
+
filename = caller[1].split(':')[0].gsub(Rails.root.to_s+'/','') # Take the view name
|
16
|
+
test_name = "#{filename}:#{hash.abs.to_s(16)}"
|
12
17
|
else
|
13
|
-
|
18
|
+
# E.g /Users/hayesgm/animals/shadow/app/controllers/home_controller.rb:27:in `home'
|
19
|
+
# -> app/controllers/home_controller:home:313c7f3a472883ba
|
20
|
+
line = caller[0].gsub(Rails.root.to_s+'/','') # Take everything but the Rails root portion
|
21
|
+
|
22
|
+
m = /(?<filename>[\w.\/]+):(?<line>\d+):in `(?<function>\w+)'/.match(line)
|
23
|
+
|
24
|
+
if m && !m[:filename].blank? && !m[:function].blank?
|
25
|
+
test_name = "#{m[:filename]}:#{m[:function]}:#{hash.abs.to_s(16)}"
|
26
|
+
else # Fallback
|
27
|
+
test_name = key
|
28
|
+
end
|
14
29
|
end
|
15
30
|
else
|
16
31
|
name
|
data/lib/vignette/version.rb
CHANGED