assert_difference 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["J. Pablo Fernández"]
12
12
  s.email = ["pupeno@pupeno.com"]
13
- s.homepage = "http://github.com/pupeno/assert_difference"
13
+ s.homepage = "http://pupeno.github.com/assert_difference/"
14
14
  s.summary = "An improved assert_difference"
15
15
  s.description = "Better assert_difference than Rails by providing a more compact and readable syntax through hashes. For some more information read http://pupeno.com/blog/better-assert-difference."
16
16
 
@@ -2,7 +2,7 @@
2
2
  # Copyright © 2010, 2011, 2012 José Pablo Fernández
3
3
 
4
4
  module AssertDifference
5
- VERSION = "0.4.0" unless defined?(::AssertDifference::VERSION)
5
+ VERSION = "0.4.1" unless defined?(::AssertDifference::VERSION)
6
6
 
7
7
  # Test numeric difference between the return value of an expression as a result of what is evaluated
8
8
  # in the yielded block.
@@ -76,10 +76,19 @@ module AssertDifference
76
76
 
77
77
  result = yield
78
78
 
79
+ error_messages = []
79
80
  expressions.each do |exp, diff|
80
- error = "#{exp.inspect} didn't change by #{diff}"
81
- error = "#{message}.\n#{error}" if message
82
- assert_equal(before[exp] + diff, eval(exp, b), error)
81
+ expected = before[exp] + diff
82
+ actual = eval(exp, b)
83
+ if expected != actual
84
+ error = "#{exp.inspect} didn't change by #{diff} (expecting #{expected}, but got #{actual})"
85
+ error = "#{message}.\n#{error}" if message
86
+ error_messages << error
87
+ end
88
+ end
89
+
90
+ if error_messages.any?
91
+ fail error_messages.join(error_message.any? { |m| m.includes? "\n" } ? "\n\n" : ". ").strip
83
92
  end
84
93
 
85
94
  return result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_difference
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-21 00:00:00.000000000Z
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
16
- requirement: &70228130478420 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70228130478420
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Better assert_difference than Rails by providing a more compact and readable
26
31
  syntax through hashes. For some more information read http://pupeno.com/blog/better-assert-difference.
27
32
  email:
@@ -39,7 +44,7 @@ files:
39
44
  - lib/assert_difference.rb
40
45
  - test/helper.rb
41
46
  - test/test_assert_difference.rb
42
- homepage: http://github.com/pupeno/assert_difference
47
+ homepage: http://pupeno.github.com/assert_difference/
43
48
  licenses: []
44
49
  post_install_message:
45
50
  rdoc_options: []
@@ -59,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
64
  version: 1.3.6
60
65
  requirements: []
61
66
  rubyforge_project: assert_difference
62
- rubygems_version: 1.8.10
67
+ rubygems_version: 1.8.24
63
68
  signing_key:
64
69
  specification_version: 3
65
70
  summary: An improved assert_difference