jakewendt-test_with_verbosity 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/test_with_verbosity.rb +63 -32
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75bb8b7110c6822f8dd1d56b8d9e6661687055fe
4
- data.tar.gz: 01057b6454d2dc28443e20f5b8ba4200e2021601
3
+ metadata.gz: d0d01ad45aa02b869c69d0158eebbd9d2f4e4855
4
+ data.tar.gz: 5b1f40af682e43a5d90733fac1b27d7bb6ad7628
5
5
  SHA512:
6
- metadata.gz: 1b7938cbeec4ff82fc5cd4fa3bc34860eae5da1c75caddde6d260ac07ddff2d8391ee25e8fec102b9bd8adb9eebba704133fe4b99ef7e00bf99479036c35e398
7
- data.tar.gz: 03df2e9f606fbe1b19c71f23840db3825cf11e42c9e9c7828eb39deb038f0bca55d05d1ff2be7d5652b9b652b7e9d0bcf92dd2c7f32937d19bbddbeb841a48d2
6
+ metadata.gz: 0347b201d1362727d7271689d615ae4d71fde647ffdab1ef7ada6f101e2da865339237df6f2391045ff66649d29d43b5fa98e2110a75d909c6a648f1f9d51087
7
+ data.tar.gz: 8bb2373ea9e3b619a591f5016a80b499b1e7a9e259f3bb989687fbde4458a4d1c1a192ec4cbecdce46428f29511734068fa3fc3b4f3d12ea08b9ef6feb5b7f61
@@ -4,33 +4,40 @@ module JakeWendt::TestWithVerbosity
4
4
  def self.included(base)
5
5
  base.extend(ClassMethods)
6
6
 
7
- base.class_eval do
8
- class << self
9
- alias_method_chain( :test, :verbosity
10
- ) unless method_defined?(:test_without_verbosity)
11
- end
12
- end #unless base.respond_to?(:test_without_verbosity)
7
+ # base.class_eval do
8
+ # class << self
9
+ # alias_method_chain( :test, :verbosity
10
+ # ) unless method_defined?(:test_without_verbosity)
11
+ # end
12
+ # end #unless base.respond_to?(:test_without_verbosity)
13
13
  end
14
14
 
15
15
  module ClassMethods
16
16
 
17
17
  # activesupport-4.1.4/lib/active_support/testing/declarative.rb
18
+ # my modified version
18
19
  def test(name, &block)
19
20
  #test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
20
21
  test_name = "test_#{name.gsub(/\W/,'_')}".to_sym # NEED THIS
21
22
  defined = instance_method(test_name) rescue false
22
23
  raise "#{test_name} is already defined in #{self}" if defined
23
24
  if block_given?
24
- define_method(test_name, &block)
25
+ # define_method(test_name, &block)
25
26
 
26
27
  #
27
28
  # could possibly do something like this, but I can't seem to figure out
28
29
  # how to call a passed block correctly.
29
30
  #
30
- # define_method(test_name) do
31
- # print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
32
- # block.call # FAIL
33
- # end
31
+ # lots of the like ....
32
+ # NoMethodError: undefined method `assert' for InterviewAssignmentTest:Class
33
+ #
34
+ define_method(test_name) do
35
+ print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
36
+ # block.call # FAIL
37
+ # self.block.call # FAIL
38
+ # yield # FAIL
39
+ instance_exec(&block) # SUCCESS!
40
+ end
34
41
  else
35
42
  define_method(test_name) do
36
43
  flunk "No implementation provided for #{name}"
@@ -39,29 +46,53 @@ module JakeWendt::TestWithVerbosity
39
46
  end
40
47
 
41
48
 
42
- # rails used \s+ and converted groups of whitespace to a single underscore
43
- # I then used \W+ and converted groups of non-word chars to a single underscore
44
49
 
45
- # NOW I use \W and converted non-word chars to a underscores (no more groups)
46
50
 
47
- def test_with_verbosity(name,&block)
48
- test_without_verbosity(name,&block)
49
- test_name = "test_#{name.gsub(/\W/,'_')}".to_sym
50
- define_method("_#{test_name}_with_verbosity") do
51
- print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
52
- send("_#{test_name}_without_verbosity")
53
- end
54
- #
55
- # can't do this...
56
- # alias_method_chain test_name, :verbosity
57
- # end up with 2 methods that begin
58
- # with 'test_' so they both get run
59
- #
60
- alias_method "_#{test_name}_without_verbosity".to_sym,
61
- test_name
62
- alias_method test_name,
63
- "_#{test_name}_with_verbosity".to_sym
64
- end
51
+ # # activesupport-4.1.4/lib/active_support/testing/declarative.rb
52
+ # def test(name, &block)
53
+ # #test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
54
+ # test_name = "test_#{name.gsub(/\W/,'_')}".to_sym # NEED THIS
55
+ # defined = instance_method(test_name) rescue false
56
+ # raise "#{test_name} is already defined in #{self}" if defined
57
+ # if block_given?
58
+ # define_method(test_name, &block)
59
+ # else
60
+ # define_method(test_name) do
61
+ # flunk "No implementation provided for #{name}"
62
+ # end
63
+ # end
64
+ # end
65
+ #
66
+ ## rails used \s+ and converted groups of whitespace to a single underscore
67
+ ## I then used \W+ and converted groups of non-word chars to a single underscore
68
+ #
69
+ ## NOW I use \W and converted non-word chars to a underscores (no more groups)
70
+ #
71
+ # def test_with_verbosity(name,&block)
72
+ # test_without_verbosity(name,&block)
73
+ # test_name = "test_#{name.gsub(/\W/,'_')}".to_sym
74
+ # define_method("_#{test_name}_with_verbosity") do
75
+ # print "\n#{self.class.name.gsub(/Test$/,'').titleize} #{name}: "
76
+ # send("_#{test_name}_without_verbosity")
77
+ # end
78
+ # #
79
+ # # can't do this...
80
+ # # alias_method_chain test_name, :verbosity
81
+ # # end up with 2 methods that begin
82
+ # # with 'test_' so they both get run
83
+ # #
84
+ # alias_method "_#{test_name}_without_verbosity".to_sym,
85
+ # test_name
86
+ # alias_method test_name,
87
+ # "_#{test_name}_with_verbosity".to_sym
88
+ # end
89
+
90
+
91
+
92
+
93
+
94
+
95
+
65
96
 
66
97
  #
67
98
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jakewendt-test_with_verbosity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - George 'Jake' Wendt