jakewendt-test_with_verbosity 0.0.1 → 0.0.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 +4 -4
- data/lib/test_with_verbosity.rb +77 -1
- 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: db357c276871f0d9e45ad6c78e89d16b32967026
|
4
|
+
data.tar.gz: 4b1309f750a5d0aeb1833ebff719eb0f4f127408
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e76935c02273942ded046967530510dc5c45822abbc09e83a3a77fade71cbdc5554657206a23624aaf81bb409f5bb037c761373430fa8112f4b3c0f8b2eafcf3
|
7
|
+
data.tar.gz: 24a400dbedac181401cab6bcda1f473b7d7164c5a05c5456fac4b8d172e864ef115afccd2590e4630da03b37d8c867f35de2f2134792e112d44b91484ed2a685
|
data/lib/test_with_verbosity.rb
CHANGED
@@ -14,9 +14,32 @@ module JakeWendt::TestWithVerbosity
|
|
14
14
|
|
15
15
|
module ClassMethods
|
16
16
|
|
17
|
+
# activesupport-4.1.4/lib/active_support/testing/declarative.rb
|
18
|
+
def test(name, &block)
|
19
|
+
#test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
20
|
+
test_name = "test_#{name.gsub(/\W+/,'_')}".to_sym # NEED THIS
|
21
|
+
defined = instance_method(test_name) rescue false
|
22
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
23
|
+
if block_given?
|
24
|
+
define_method(test_name, &block)
|
25
|
+
|
26
|
+
#
|
27
|
+
# could possibly do something like this, but I can't seem to figure out
|
28
|
+
# how to call a passed block correctly.
|
29
|
+
#
|
30
|
+
# define_method(test_name) do
|
31
|
+
# print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
|
32
|
+
# block.call # FAIL
|
33
|
+
# end
|
34
|
+
else
|
35
|
+
define_method(test_name) do
|
36
|
+
flunk "No implementation provided for #{name}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
17
41
|
def test_with_verbosity(name,&block)
|
18
42
|
test_without_verbosity(name,&block)
|
19
|
-
|
20
43
|
test_name = "test_#{name.gsub(/\W+/,'_')}".to_sym
|
21
44
|
define_method("_#{test_name}_with_verbosity") do
|
22
45
|
print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
|
@@ -34,6 +57,59 @@ module JakeWendt::TestWithVerbosity
|
|
34
57
|
"_#{test_name}_with_verbosity".to_sym
|
35
58
|
end
|
36
59
|
|
60
|
+
#
|
61
|
+
#
|
62
|
+
# test names with punctuation aren't found when autotest tries to rerun them
|
63
|
+
#
|
64
|
+
# def test_with_verbosity(name,&block)
|
65
|
+
# test_without_verbosity(name,&block)
|
66
|
+
# test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
67
|
+
# define_method("_#{test_name}_with_verbosity") do
|
68
|
+
# print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
|
69
|
+
# send("_#{test_name}_without_verbosity")
|
70
|
+
# end
|
71
|
+
# #
|
72
|
+
# # can't do this...
|
73
|
+
# # alias_method_chain test_name, :verbosity
|
74
|
+
# # end up with 2 methods that begin
|
75
|
+
# # with 'test_' so they both get run
|
76
|
+
# #
|
77
|
+
# alias_method "_#{test_name}_without_verbosity".to_sym,
|
78
|
+
# test_name
|
79
|
+
# alias_method test_name,
|
80
|
+
# "_#{test_name}_with_verbosity".to_sym
|
81
|
+
# end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Trying to fix
|
85
|
+
#
|
86
|
+
# def test_with_verbosity(name,&block)
|
87
|
+
# test_without_verbosity(name,&block)
|
88
|
+
#
|
89
|
+
#
|
90
|
+
# # need to keep the \s+ regex as that is what rails' test_without_verbosity will create
|
91
|
+
# # ( could just rewrite that too )
|
92
|
+
# # seems I'm gonna hafta
|
93
|
+
# rails_test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
94
|
+
#
|
95
|
+
#
|
96
|
+
# test_name = "test_#{name.gsub(/\W+/,'_')}".to_sym
|
97
|
+
# define_method("_#{test_name}_with_verbosity") do
|
98
|
+
# print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
|
99
|
+
# send("_#{test_name}_without_verbosity")
|
100
|
+
# end
|
101
|
+
# #
|
102
|
+
# # can't do this...
|
103
|
+
# # alias_method_chain test_name, :verbosity
|
104
|
+
# # end up with 2 methods that begin
|
105
|
+
# # with 'test_' so they both get run
|
106
|
+
# #
|
107
|
+
# alias_method "_#{test_name}_without_verbosity".to_sym,
|
108
|
+
# rails_test_name
|
109
|
+
# alias_method rails_test_name,
|
110
|
+
# "_#{test_name}_with_verbosity".to_sym
|
111
|
+
# end
|
112
|
+
|
37
113
|
end # ClassMethods
|
38
114
|
|
39
115
|
end # JakeWendt::TestWithVerbosity
|