fun_with_testing 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mzk5MWIxMzYyMzAzMWMzNDIyN2Y3ZTQzMWIxNGFiYTZhMzQxNWVhNA==
4
+ ODI5NWNmNjZkYzVmMTJhMTU0NjY0M2IxOGU5ZTJlMjE2OTQxODkyYQ==
5
5
  data.tar.gz: !binary |-
6
- OTA2ZDQ4MzlhZjAxNGU2ZDg1N2VkNjBiMDc3YTNkOGE3OGE4MjBhZg==
6
+ MmI0Nzg3YzUzYmRjMGE5MzUzN2ZkNmVhODMyZWJmOTM2ZGJjYmI0Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWZlNTNiZGVjZDQ5ZjllZDVhYmJjNmVlYmEyY2ZhNThjNTI5NjViZTQyMmNl
10
- YzUxOTQ5NDNmZTM4OTY1YTliZDE4ZWUzZGYzNGZhNDAyODMxMTdmMjYwNDdh
11
- ZDIyYmQ2MGM3NmQ4NTkxYmNlNmFiYjIxNmFjNWRjMWI3MGU1YjY=
9
+ NTAyMzUwYTMyOWI0MDQzY2E1OTM4NWE1ZTFlOGYxOTA4NzY3NGIzYmRmNTMw
10
+ ZGQ5ODJhMzc0NTZiYjZhNTI1NGExYzk4NDJjODkwZjQ3M2QzYzFlNDRiYTBh
11
+ NjM0YTA5NzVmMDE5YTc3ZGQ3YmQ0ZGJhMTQyMGIwM2QxY2FlNGE=
12
12
  data.tar.gz: !binary |-
13
- ZWFlYzZlNDQ4YzM5Y2JiMmJkNzJkMTUzZDQ0MDM0Y2EyMmIxZDc4OWRmNjg1
14
- N2IzYTEzNzI2MzE3MTJiNmQ1YzljMGVmMzBmZDMwY2UwYjFiNjZhOWQ1ODE4
15
- MTBkMjQwNzdjZWE2YjY5ZTAyYjA4Nzg3NWM0MzljMDM3Y2NhZGY=
13
+ MzIyZDJiMWIxNmU3MWM5NjM4Njk5NmEyYTJkOTVlZDYyMjU2NWM4Y2NhM2Nk
14
+ OWZkYTRkZjA0NGM0YzQ3MWEyMTI5NTExYzMzMGYzZTNhODc1NDkxYTIyZjk5
15
+ NmI1MTA3YjczNDJlZjAwNDc3YzBiYzg4MDVjMmFlODlkYTNkZGQ=
data/CHANGELOG.markdown CHANGED
@@ -0,0 +1,7 @@
1
+ CHANGELOG
2
+ =========
3
+
4
+ v0.0.4
5
+ ------
6
+
7
+ ?????
data/Gemfile CHANGED
@@ -20,5 +20,6 @@ gem "rdoc", "~> 3.12"
20
20
  gem "bundler", "~> 1.0"
21
21
  gem "jeweler", "~> 2.0"
22
22
  # gem "rcov", ">= 0"
23
+ gem "simplecov", "~> 0", ">= 0.8"
23
24
  gem 'debugger', "~> 1.6"
24
25
  gem 'minitest', "~> 5"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -8,7 +8,7 @@ module FunWith
8
8
  message = "Record #{record} did not save properly. "
9
9
  message += record.errors.map{ |k,v| "#{k} : #{v}"}.join(", ")
10
10
 
11
- assert_block message do
11
+ safe_assert_block message do
12
12
  result
13
13
  end
14
14
  end
@@ -16,7 +16,7 @@ module FunWith
16
16
  # Usage: get("index"); assert_response_success( :template => "index" )
17
17
  #
18
18
  def assert_response_success( opts = {} )
19
- assert_block "@response is nil" do
19
+ safe_assert_block "@response is nil" do
20
20
  !@response.nil?
21
21
  end
22
22
 
@@ -31,7 +31,7 @@ module FunWith
31
31
  end
32
32
 
33
33
  def assert_response_redirect( opts = {} )
34
- assert_block "@response is nil" do
34
+ safe_assert_block "@response is nil" do
35
35
  !@response.nil?
36
36
  end
37
37
 
@@ -55,7 +55,7 @@ module FunWith
55
55
  record.errors.map{ |k,v| "[#{k} : #{v}]"}.join(", ")
56
56
  )
57
57
 
58
- assert_block message do
58
+ safe_assert_block message do
59
59
  record.valid?
60
60
  end
61
61
  end
@@ -64,20 +64,20 @@ module FunWith
64
64
  def assert_errors_on( record, message = "" )
65
65
  message = build_message( message, "#{record.class.name} record should have errors.")
66
66
 
67
- assert_block message do
67
+ safe_assert_block message do
68
68
  !record.valid?
69
69
  end
70
70
  end
71
71
 
72
72
  def assert_an_error_on( record, _field, error_says = nil )
73
73
  message = build_message( "", "<?> should have an error on the <?> field.", record, _field )
74
- assert_block message do
74
+ safe_assert_block message do
75
75
  !record.errors[_field].blank?
76
76
  end
77
77
 
78
78
  unless error_says.blank?
79
79
  message = build_message( "", "<?> should have an error on the <?> field that says <?>.", record, _field, error_says )
80
- assert_block message do
80
+ safe_assert_block message do
81
81
  # puts "Inside field error block"
82
82
  # debugger
83
83
  record.errors[_field].include?(error_says)
@@ -90,15 +90,15 @@ module FunWith
90
90
  new_record_message = build_message(message, "<?> should not be a new record in order to use assert_destroy().", record)
91
91
  full_message = build_message(message, "<?> should have been destroyed.", record)
92
92
 
93
- assert_block not_record_message do
93
+ safe_assert_block not_record_message do
94
94
  record.is_a?(ActiveRecord::Base)
95
95
  end
96
96
 
97
- assert_block new_record_message do
97
+ safe_assert_block new_record_message do
98
98
  record.new_record? == false
99
99
  end
100
100
 
101
- assert_block full_message do
101
+ safe_assert_block full_message do
102
102
  record.class.find_by_id(record.id) == nil
103
103
  end
104
104
  end
@@ -5,7 +5,7 @@ module FunWith
5
5
  def assert_not_zero( actual, message = "" )
6
6
  message = build_message(message, "should not be zero")
7
7
 
8
- assert_block message do
8
+ safe_assert_block message do
9
9
  actual != 0
10
10
  end
11
11
  end
@@ -13,7 +13,7 @@ module FunWith
13
13
  def assert_zero( actual, message = "" )
14
14
  message = build_message(message, "should be zero, not <#{actual}>")
15
15
 
16
- assert_block message do
16
+ safe_assert_block message do
17
17
  actual == 0
18
18
  end
19
19
  end
@@ -21,7 +21,7 @@ module FunWith
21
21
  def assert_one( actual, message = "" )
22
22
  message = build_message(message, "should be 1, not <#{actual}>")
23
23
 
24
- assert_block message do
24
+ safe_assert_block message do
25
25
  actual == 1
26
26
  end
27
27
  end
@@ -29,26 +29,42 @@ module FunWith
29
29
  def assert_negative( actual, message = "" )
30
30
  message = build_message(message, "should be negative, not <#{actual}>")
31
31
 
32
- assert_block message do
32
+ safe_assert_block message do
33
33
  actual < 0
34
34
  end
35
35
  end
36
36
 
37
37
  def assert_true( actual, message = "" )
38
38
  message = build_message(message, "should be true, not <#{actual}>")
39
- assert_block message do
39
+ safe_assert_block message do
40
40
  actual == true
41
41
  end
42
42
  end
43
43
 
44
44
  def assert_false( actual, message = "" )
45
45
  message = build_message(message, "should be false, not <#{actual}>")
46
- assert_block message do
46
+ safe_assert_block message do
47
47
  actual == false
48
48
  end
49
49
  end
50
50
 
51
51
 
52
+ def assert_nil( actual, message = "" )
53
+ message = build_message(message, "should be nil, not <#{actual}>")
54
+ safe_assert_block message do
55
+ actual == nil
56
+ end
57
+ end
58
+
59
+ def assert_not_nil( actual, message = "" )
60
+ message = build_message(message, "should not be nil")
61
+ safe_assert_block message do
62
+ actual != nil
63
+ end
64
+ end
65
+
66
+ alias :refute_nil :assert_not_nil
67
+
52
68
  def assert_blank( obj, message = "" )
53
69
  if obj.respond_to?(:blank?)
54
70
  full_message = build_message(message, "<?> should be blank.", obj)
@@ -56,14 +72,14 @@ module FunWith
56
72
  full_message = build_message(message, "<?> does not respond to :blank? method.", obj)
57
73
  end
58
74
 
59
- assert_block full_message do
75
+ safe_assert_block full_message do
60
76
  obj.respond_to?(:blank?) && obj.blank?
61
77
  end
62
78
  end
63
79
 
64
80
  def assert_matches( string, regexp_or_string, message = "")
65
81
  full_message = build_message(message, "<?> should match regex <?>", string, regexp_or_string)
66
- assert_block full_message do
82
+ safe_assert_block full_message do
67
83
  if regexp_or_string.is_a?(Regexp)
68
84
  string.match(regexp_or_string) ? true : false
69
85
  elsif regexp_or_string.is_a?(String)
@@ -74,7 +90,7 @@ module FunWith
74
90
 
75
91
  def assert_doesnt_match( string, regexp, message = "")
76
92
  full_message = build_message(message, "<?> should not match regex <?>", string, regexp)
77
- assert_block full_message do
93
+ safe_assert_block full_message do
78
94
  string.match(regexp) ? false : true
79
95
  end
80
96
  end
@@ -98,7 +114,7 @@ module FunWith
98
114
 
99
115
  message = build_message("", "The following variables should have been assigned values by the controller: <?>", symbols_not_assigned.map{|s| "@#{s.to_s}"}.join(", "))
100
116
 
101
- assert_block message do
117
+ safe_assert_block message do
102
118
  symbols_not_assigned.length == 0
103
119
  end
104
120
 
@@ -114,7 +130,7 @@ module FunWith
114
130
  def assert_greater_than( reference_value, amount, message = "" )
115
131
  message = build_message("", "second argument <?> should be greater than reference value <?>", amount, reference_value)
116
132
 
117
- assert_block message do
133
+ safe_assert_block message do
118
134
  amount > reference_value
119
135
  end
120
136
  end
@@ -123,7 +139,7 @@ module FunWith
123
139
  def assert_less_than( reference_value, amount, message = "" )
124
140
  message = build_message("", "second argument <?> should be less than reference value <?>", amount, reference_value)
125
141
 
126
- assert_block message do
142
+ safe_assert_block message do
127
143
  amount < reference_value
128
144
  end
129
145
  end
@@ -132,7 +148,7 @@ module FunWith
132
148
  def assert_times_are_close( t1, t2, window = 1, message = "")
133
149
  message = build_message(message, "times should be within ? second of each other.", window)
134
150
 
135
- assert_block message do
151
+ safe_assert_block message do
136
152
  (t1 - t2).abs < window
137
153
  end
138
154
  end
@@ -140,7 +156,7 @@ module FunWith
140
156
  def assert_equal_length( expected, actual, message = "" )
141
157
  message = build_message( message, "items should be of equal length: expected: <?>, actual: <?>", expected.length, actual.length )
142
158
 
143
- assert_block message do
159
+ safe_assert_block message do
144
160
  expected.length == actual.length
145
161
  end
146
162
  end
@@ -162,16 +178,23 @@ module FunWith
162
178
  end
163
179
  end
164
180
 
165
- assert_block message do
181
+ safe_assert_block message do
166
182
  unequal.blank?
167
183
  end
168
184
  end
169
185
 
170
186
  def assert_has_instance_method( object, instance_method, message = "object #{object} should respond to #{instance_method.inspect}" )
171
- assert_block( message ) do
187
+ safe_assert_block( message ) do
172
188
  object.instance_methods.include?( instance_method )
173
189
  end
174
190
  end
191
+
192
+ def assert_nothing_raised( message = "", &block )
193
+ safe_assert_block( message ) do
194
+ result = true
195
+ result
196
+ end
197
+ end
175
198
  end
176
199
  end
177
200
  end
@@ -5,7 +5,7 @@ module FunWith
5
5
  def assert_fwf_filepath( file, message = "" )
6
6
  message = build_message( message, "File <#{file}> should be a FunWith::Files::FilePath")
7
7
 
8
- assert_block message do
8
+ safe_assert_block message do
9
9
  file.is_a?( FunWith::Files::FilePath )
10
10
  end
11
11
  end
@@ -15,7 +15,7 @@ module FunWith
15
15
 
16
16
  message = build_message( message, "File should exist at <#{file}>." )
17
17
 
18
- assert_block message do
18
+ safe_assert_block message do
19
19
  file.exist?
20
20
  end
21
21
  end
@@ -25,7 +25,7 @@ module FunWith
25
25
 
26
26
  message = build_message( message, "No file/directory should exist at <#{file}>." )
27
27
 
28
- assert_block message do
28
+ safe_assert_block message do
29
29
  ! file.exist?
30
30
  end
31
31
  end
@@ -36,7 +36,7 @@ module FunWith
36
36
  message = build_message( message, "<#{file}> should be a directory." )
37
37
 
38
38
 
39
- assert_block message do
39
+ safe_assert_block message do
40
40
  file.directory?
41
41
  end
42
42
  end
@@ -47,7 +47,7 @@ module FunWith
47
47
  message = build_message( message, "<#{file}> shouldn't be a directory." )
48
48
 
49
49
 
50
- assert_block message do
50
+ safe_assert_block message do
51
51
  ! file.directory?
52
52
  end
53
53
  end
@@ -57,7 +57,7 @@ module FunWith
57
57
 
58
58
  message = build_message( message, "Empty file should exist at <#{file}>." )
59
59
 
60
- assert_block message do
60
+ safe_assert_block message do
61
61
  file.exist? && file.empty?
62
62
  end
63
63
  end
@@ -67,7 +67,7 @@ module FunWith
67
67
 
68
68
  message = build_message( message, "Empty directory should exist at <#{file}>." )
69
69
 
70
- assert_block message do
70
+ safe_assert_block message do
71
71
  file.directory? && file.empty?
72
72
  end
73
73
  end
@@ -77,7 +77,7 @@ module FunWith
77
77
 
78
78
  message = build_message( message, "File should exist at <#{file}>, and have content." )
79
79
 
80
- assert_block message do
80
+ safe_assert_block message do
81
81
  file.exist? && !file.empty?
82
82
  end
83
83
  end
@@ -64,10 +64,14 @@ module FunWith
64
64
  end
65
65
 
66
66
  def test_gem_validity
67
- if self.class.gem_to_test
68
- assert self.class.gem_to_test.gem_valid?
67
+ if jem = self.class.gem_to_test
68
+ assert_equal [], jem.validate_gem
69
69
  end
70
70
  end
71
+
72
+ def build_message( *args )
73
+ args.map(&:inspect).join(" ")
74
+ end
71
75
  end
72
76
  end
73
77
  end
@@ -1,4 +1,18 @@
1
- # require 'test/unit'
1
+ require 'bundler'
2
+ require 'debugger'
3
+ require 'minitest'
4
+ require 'minitest/autorun'
5
+ require 'shoulda'
6
+ require 'jeweler'
7
+
8
+ begin
9
+ Bundler.setup(:default, :development)
10
+ rescue Bundler::BundlerError => e
11
+ $stderr.puts e.message
12
+ $stderr.puts "Run `bundle install` to install missing gems"
13
+ exit e.status_code
14
+ end
15
+
2
16
 
3
17
  files = Dir.glob( File.join( File.dirname(__FILE__), "fun_with", "testing", "**", "*.rb" ) )
4
18
 
@@ -11,5 +25,5 @@ end
11
25
  # FunWith::Testing.assertion_modules << FunWith::Testing::Assertions::ActiveRecord
12
26
  # FunWith::Testing.assertion_modules << FunWith::Testing::Assertions::Basics
13
27
 
14
- FunWith::Testing.send(:include, FunWith::Testing::Assertions::Basics)
15
- FunWith::Testing.send(:include, FunWith::Testing::Assertions::ActiveRecord)
28
+ FunWith::Testing.send( :include, FunWith::Testing::Assertions::Basics )
29
+ FunWith::Testing.send( :include, FunWith::Testing::Assertions::ActiveRecord )
data/test/helper.rb CHANGED
@@ -11,9 +11,9 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
 
13
13
  # require 'test/unit'
14
- require 'minitest'
15
- require 'minitest/autorun'
16
- require 'shoulda'
14
+ # require 'minitest'
15
+ # require 'minitest/autorun'
16
+ # require 'shoulda'
17
17
 
18
18
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
19
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -33,7 +33,7 @@ class MockUnitTest < FunWith::Testing::TestCase
33
33
  "#{m} #{m2} #{obj}"
34
34
  end
35
35
 
36
- def assert_block( *args, &block )
36
+ def safe_assert_block( *args, &block )
37
37
  yield
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_with_testing
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
  - Bryce Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda
@@ -72,6 +72,26 @@ dependencies:
72
72
  - - ~>
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0.8'
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0.8'
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
75
95
  - !ruby/object:Gem::Dependency
76
96
  name: debugger
77
97
  requirement: !ruby/object:Gem::Requirement