shoulda-matchers 1.0.0.beta1 → 1.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -7
- data/Gemfile.lock +42 -24
- data/lib/shoulda-matchers.rb +1 -8
- data/lib/shoulda/matchers.rb +8 -0
- data/lib/shoulda/matchers/action_controller/assign_to_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/helpers.rb +2 -7
- data/lib/shoulda/matchers/active_record/validate_format_of_matcher.rb +2 -2
- data/lib/shoulda/matchers/active_record/validate_presence_of_matcher.rb +2 -1
- data/lib/shoulda/matchers/assertion_error.rb +11 -0
- data/lib/shoulda/matchers/integrations/rspec.rb +12 -4
- data/lib/shoulda/matchers/version.rb +1 -1
- metadata +85 -16
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shoulda-matchers (1.0.0.beta2)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
@@ -28,12 +33,15 @@ GEM
|
|
28
33
|
activemodel (= 3.0.3)
|
29
34
|
activesupport (= 3.0.3)
|
30
35
|
activesupport (3.0.3)
|
31
|
-
|
32
|
-
|
33
|
-
|
36
|
+
archive-tar-minitar (0.5.2)
|
37
|
+
arel (2.0.8)
|
38
|
+
aruba (0.2.8)
|
39
|
+
childprocess (~> 0.1.6)
|
34
40
|
cucumber (~> 0.10.0)
|
35
|
-
|
41
|
+
rspec (~> 2.3.0)
|
36
42
|
builder (2.1.2)
|
43
|
+
childprocess (0.1.6)
|
44
|
+
ffi (~> 0.6.3)
|
37
45
|
columnize (0.3.2)
|
38
46
|
cucumber (0.10.0)
|
39
47
|
builder (>= 2.1.2)
|
@@ -44,13 +52,15 @@ GEM
|
|
44
52
|
diff-lcs (1.1.2)
|
45
53
|
erubis (2.6.6)
|
46
54
|
abstract (>= 1.0.0)
|
47
|
-
|
55
|
+
ffi (0.6.3)
|
56
|
+
rake (>= 0.8.7)
|
57
|
+
gherkin (2.3.3)
|
48
58
|
json (~> 1.4.6)
|
49
|
-
term-ansicolor (~> 1.0.5)
|
50
59
|
i18n (0.5.0)
|
51
60
|
json (1.4.6)
|
52
|
-
|
53
|
-
|
61
|
+
linecache19 (0.5.11)
|
62
|
+
ruby_core_source (>= 0.1.4)
|
63
|
+
mail (2.2.15)
|
54
64
|
activesupport (>= 2.3.6)
|
55
65
|
i18n (>= 0.4.0)
|
56
66
|
mime-types (~> 1.16)
|
@@ -62,7 +72,7 @@ GEM
|
|
62
72
|
rack (1.2.1)
|
63
73
|
rack-mount (0.6.13)
|
64
74
|
rack (>= 1.0.0)
|
65
|
-
rack-test (0.5.
|
75
|
+
rack-test (0.5.7)
|
66
76
|
rack (>= 1.0)
|
67
77
|
rails (3.0.3)
|
68
78
|
actionmailer (= 3.0.3)
|
@@ -82,35 +92,43 @@ GEM
|
|
82
92
|
rspec-core (~> 2.3.0)
|
83
93
|
rspec-expectations (~> 2.3.0)
|
84
94
|
rspec-mocks (~> 2.3.0)
|
85
|
-
rspec-core (2.3.
|
95
|
+
rspec-core (2.3.1)
|
86
96
|
rspec-expectations (2.3.0)
|
87
97
|
diff-lcs (~> 1.1.2)
|
88
98
|
rspec-mocks (2.3.0)
|
89
|
-
rspec-rails (2.3.
|
99
|
+
rspec-rails (2.3.1)
|
90
100
|
actionpack (~> 3.0)
|
91
101
|
activesupport (~> 3.0)
|
92
102
|
railties (~> 3.0)
|
93
103
|
rspec (~> 2.3.0)
|
94
|
-
ruby-debug (0.
|
95
|
-
columnize (>= 0.1)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
104
|
+
ruby-debug-base19 (0.11.24)
|
105
|
+
columnize (>= 0.3.1)
|
106
|
+
linecache19 (>= 0.5.11)
|
107
|
+
ruby_core_source (>= 0.1.4)
|
108
|
+
ruby-debug19 (0.11.6)
|
109
|
+
columnize (>= 0.3.1)
|
110
|
+
linecache19 (>= 0.5.11)
|
111
|
+
ruby-debug-base19 (>= 0.11.19)
|
112
|
+
ruby_core_source (0.1.4)
|
113
|
+
archive-tar-minitar (>= 0.5.2)
|
114
|
+
sqlite3 (1.3.3)
|
115
|
+
sqlite3-ruby (1.3.3)
|
116
|
+
sqlite3 (>= 1.3.3)
|
100
117
|
term-ansicolor (1.0.5)
|
101
118
|
thor (0.14.6)
|
102
119
|
treetop (1.4.9)
|
103
120
|
polyglot (>= 0.3.1)
|
104
|
-
tzinfo (0.3.
|
121
|
+
tzinfo (0.3.24)
|
105
122
|
|
106
123
|
PLATFORMS
|
107
124
|
ruby
|
108
125
|
|
109
126
|
DEPENDENCIES
|
110
|
-
aruba
|
111
|
-
cucumber
|
112
|
-
mocha
|
127
|
+
aruba (~> 0.2.7)
|
128
|
+
cucumber (~> 0.10.0)
|
129
|
+
mocha (~> 0.9.10)
|
113
130
|
rails (= 3.0.3)
|
114
|
-
rspec-rails
|
115
|
-
ruby-
|
116
|
-
|
131
|
+
rspec-rails (~> 2.3.0)
|
132
|
+
ruby-debug19 (~> 0.11.6)
|
133
|
+
shoulda-matchers!
|
134
|
+
sqlite3-ruby (~> 1.3.2)
|
data/lib/shoulda-matchers.rb
CHANGED
@@ -60,7 +60,7 @@ module Shoulda # :nodoc:
|
|
60
60
|
private
|
61
61
|
|
62
62
|
def assigned_value?
|
63
|
-
if !@controller.instance_variables.include?("@#{@variable}")
|
63
|
+
if !@controller.instance_variables.map(&:to_s).include?("@#{@variable}")
|
64
64
|
@failure_message =
|
65
65
|
"Expected action to assign a value for @#{@variable}"
|
66
66
|
false
|
@@ -49,7 +49,7 @@ module Shoulda # :nodoc:
|
|
49
49
|
@context.send(:assert_redirected_to, @url)
|
50
50
|
@negative_failure_message = "Didn't expect to redirect to #{@url}"
|
51
51
|
true
|
52
|
-
rescue
|
52
|
+
rescue Shoulda::Matchers::AssertionError => error
|
53
53
|
@failure_message = error.message
|
54
54
|
false
|
55
55
|
end
|
@@ -41,7 +41,7 @@ module Shoulda # :nodoc:
|
|
41
41
|
@context.send(:assert_template, @template)
|
42
42
|
@negative_failure_message = "Didn't expect to render #{@template}"
|
43
43
|
true
|
44
|
-
rescue
|
44
|
+
rescue Shoulda::Matchers::AssertionError => error
|
45
45
|
@failure_message = error.message
|
46
46
|
false
|
47
47
|
end
|
@@ -80,7 +80,7 @@ module Shoulda # :nodoc:
|
|
80
80
|
rescue ::ActionController::RoutingError => error
|
81
81
|
@failure_message = error.message
|
82
82
|
false
|
83
|
-
rescue
|
83
|
+
rescue Shoulda::Matchers::AssertionError => error
|
84
84
|
@failure_message = error.message
|
85
85
|
false
|
86
86
|
end
|
@@ -17,13 +17,8 @@ module Shoulda # :nodoc:
|
|
17
17
|
# default_error_message(:too_short, :count => 5)
|
18
18
|
# default_error_message(:too_long, :count => 60)
|
19
19
|
def default_error_message(key, values = {})
|
20
|
-
if Object.const_defined?(:I18n) # Rails >= 2.2
|
21
|
-
|
22
|
-
if result =~ /^translation missing/
|
23
|
-
I18n.translate("errors.messages.#{key}", values)
|
24
|
-
else
|
25
|
-
result
|
26
|
-
end
|
20
|
+
if Object.const_defined?(:I18n) # Rails >= 2.2
|
21
|
+
I18n.translate(:"activerecord.errors.messages.#{key}", {:default => :"errors.messages.#{key}"}.merge(values))
|
27
22
|
else # Rails <= 2.1.x
|
28
23
|
::ActiveRecord::Errors.default_error_messages[key] % values[:count]
|
29
24
|
end
|
@@ -8,7 +8,7 @@ module Shoulda # :nodoc:
|
|
8
8
|
# Options:
|
9
9
|
# * <tt>with_message</tt> - value the test expects to find in
|
10
10
|
# <tt>errors.on(:attribute)</tt>. <tt>Regexp</tt> or <tt>String</tt>.
|
11
|
-
# Defaults to the translation for <tt>:
|
11
|
+
# Defaults to the translation for <tt>:invalid</tt>.
|
12
12
|
# * <tt>with(string to test against)</tt>
|
13
13
|
# * <tt>not_with(string to test against)</tt>
|
14
14
|
#
|
@@ -49,7 +49,7 @@ module Shoulda # :nodoc:
|
|
49
49
|
|
50
50
|
def matches?(subject)
|
51
51
|
super(subject)
|
52
|
-
@expected_message ||= :
|
52
|
+
@expected_message ||= :invalid
|
53
53
|
return disallows_value_of(@value_to_fail, @expected_message) if @value_to_fail
|
54
54
|
allows_value_of(@value_to_pass, @expected_message) if @value_to_pass
|
55
55
|
end
|
@@ -47,7 +47,8 @@ module Shoulda # :nodoc:
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def collection?
|
50
|
-
if
|
50
|
+
if @subject.class.respond_to?(:reflect_on_association) &&
|
51
|
+
reflection = @subject.class.reflect_on_association(@attribute)
|
51
52
|
[:has_many, :has_and_belongs_to_many].include?(reflection.macro)
|
52
53
|
else
|
53
54
|
false
|
@@ -9,15 +9,23 @@ end
|
|
9
9
|
|
10
10
|
if defined?(::ActionController)
|
11
11
|
require 'shoulda/matchers/action_controller'
|
12
|
-
module RSpec
|
13
|
-
|
12
|
+
module RSpec
|
13
|
+
module Rails
|
14
|
+
module ControllerExampleGroup
|
15
|
+
include Shoulda::Matchers::ActionController
|
16
|
+
end
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
21
|
if defined?(::ActionMailer)
|
18
22
|
require 'shoulda/matchers/action_mailer'
|
19
|
-
module RSpec
|
20
|
-
|
23
|
+
module RSpec
|
24
|
+
module Rails
|
25
|
+
module MailerExampleGroup
|
26
|
+
include Shoulda::Matchers::ActionMailer
|
27
|
+
end
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
metadata
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
- beta1
|
11
|
-
version: 1.0.0.beta1
|
4
|
+
prerelease: 6
|
5
|
+
version: 1.0.0.beta2
|
12
6
|
platform: ruby
|
13
7
|
authors:
|
14
8
|
- Tammer Saleh
|
@@ -20,10 +14,86 @@ autorequire:
|
|
20
14
|
bindir: bin
|
21
15
|
cert_chain: []
|
22
16
|
|
23
|
-
date: 2011-
|
17
|
+
date: 2011-03-17 00:00:00 -04:00
|
24
18
|
default_executable:
|
25
|
-
dependencies:
|
26
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - "="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.3
|
28
|
+
type: :development
|
29
|
+
prerelease: false
|
30
|
+
version_requirements: *id001
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: sqlite3-ruby
|
33
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.3.2
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: *id002
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: mocha
|
44
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.9.10
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: *id003
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec-rails
|
55
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.3.0
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *id004
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: cucumber
|
66
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.10.0
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: *id005
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: aruba
|
77
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.7
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: *id006
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: ruby-debug19
|
88
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.11.6
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: *id007
|
27
97
|
description: Making tests easy on the fingers and eyes
|
28
98
|
email: support@thoughtbot.com
|
29
99
|
executables: []
|
@@ -69,9 +139,11 @@ files:
|
|
69
139
|
- lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb
|
70
140
|
- lib/shoulda/matchers/active_record/validation_matcher.rb
|
71
141
|
- lib/shoulda/matchers/active_record.rb
|
142
|
+
- lib/shoulda/matchers/assertion_error.rb
|
72
143
|
- lib/shoulda/matchers/integrations/rspec.rb
|
73
144
|
- lib/shoulda/matchers/integrations/test_unit.rb
|
74
145
|
- lib/shoulda/matchers/version.rb
|
146
|
+
- lib/shoulda/matchers.rb
|
75
147
|
- lib/shoulda-matchers.rb
|
76
148
|
has_rdoc: true
|
77
149
|
homepage: http://thoughtbot.com/community/
|
@@ -89,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
161
|
requirements:
|
90
162
|
- - ">="
|
91
163
|
- !ruby/object:Gem::Version
|
92
|
-
hash:
|
164
|
+
hash: 3667913558593923355
|
93
165
|
segments:
|
94
166
|
- 0
|
95
167
|
version: "0"
|
@@ -98,14 +170,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
170
|
requirements:
|
99
171
|
- - ">="
|
100
172
|
- !ruby/object:Gem::Version
|
101
|
-
hash: 3
|
102
|
-
segments:
|
103
|
-
- 0
|
104
173
|
version: "0"
|
105
174
|
requirements: []
|
106
175
|
|
107
176
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.
|
177
|
+
rubygems_version: 1.6.1
|
109
178
|
signing_key:
|
110
179
|
specification_version: 3
|
111
180
|
summary: Making tests easy on the fingers and eyes
|