shoulda-matchers 1.4.1 → 1.4.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.
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shoulda-matchers (1.4.1)
4
+ shoulda-matchers (1.4.2)
5
5
  activesupport (>= 3.0.0)
6
+ bourne (~> 1.1.2)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -137,7 +138,6 @@ DEPENDENCIES
137
138
  activerecord-jdbcsqlite3-adapter
138
139
  appraisal (~> 0.4.0)
139
140
  aruba
140
- bourne (~> 1.1.2)
141
141
  bundler (~> 1.1)
142
142
  cucumber (~> 1.1.9)
143
143
  jdbc-sqlite3
data/NEWS.md CHANGED
@@ -1,3 +1,6 @@
1
+ # v1.4.2
2
+ * Added a new delegate_method matcher.
3
+
1
4
  # v1.4.1
2
5
  * Fixes an issue when used with Test::Unit on the allow value matcher.
3
6
 
data/README.md CHANGED
@@ -12,64 +12,83 @@ about using shoulda with Test::Unit.
12
12
 
13
13
  Matchers to test associations:
14
14
 
15
- describe Post do
16
- it { should belong_to(:user) }
17
- it { should have_many(:tags).through(:taggings) }
18
- end
15
+ ```ruby
16
+ describe Post do
17
+ it { should belong_to(:user) }
18
+ it { should have_many(:tags).through(:taggings) }
19
+ end
19
20
 
20
- describe User do
21
- it { should have_many(:posts) }
22
- end
21
+ describe User do
22
+ it { should have_many(:posts) }
23
+ end
24
+ ```
23
25
 
24
26
  ## ActiveModel Matchers
25
27
 
26
28
  Matchers to test validations and mass assignments:
27
29
 
28
- describe Post do
29
- it { should validate_uniqueness_of(:title) }
30
- it { should validate_presence_of(:body).with_message(/wtf/) }
31
- it { should validate_presence_of(:title) }
32
- it { should validate_numericality_of(:user_id) }
33
- it { should ensure_inclusion_of(:status).in_array(['draft', 'public']) }
34
- end
35
-
36
- describe User do
37
- it { should_not allow_value("blah").for(:email) }
38
- it { should allow_value("a@b.com").for(:email) }
39
- it { should ensure_inclusion_of(:age).in_range(1..100) }
40
- it { should_not allow_mass_assignment_of(:password) }
41
- end
30
+ ```ruby
31
+ describe Post do
32
+ it { should validate_uniqueness_of(:title) }
33
+ it { should validate_uniqueness_of(:title).scoped_to(:user_id, :category_id) }
34
+ it { should validate_presence_of(:body).with_message(/wtf/) }
35
+ it { should validate_presence_of(:title) }
36
+ it { should validate_numericality_of(:user_id) }
37
+ it { should ensure_inclusion_of(:status).in_array(['draft', 'public']) }
38
+ end
39
+
40
+ describe User do
41
+ it { should_not allow_value("blah").for(:email) }
42
+ it { should allow_value("a@b.com").for(:email) }
43
+ it { should ensure_inclusion_of(:age).in_range(1..100) }
44
+ it { should_not allow_mass_assignment_of(:password) }
45
+ end
46
+ ```
42
47
 
43
48
  ## ActionController Matchers
44
49
 
45
50
  Matchers to test common patterns:
46
51
 
47
- describe PostsController, "#show" do
48
- context "for a fictional user" do
49
- before do
50
- get :show, :id => 1
51
- end
52
-
53
- it { should assign_to(:user) }
54
- it { should respond_with(:success) }
55
- it { should render_template(:show) }
56
- it { should_not set_the_flash }
57
- end
52
+ ```ruby
53
+ describe PostsController, "#show" do
54
+ context "for a fictional user" do
55
+ before do
56
+ get :show, :id => 1
58
57
  end
59
58
 
59
+ it { should assign_to(:user) }
60
+ it { should respond_with(:success) }
61
+ it { should render_template(:show) }
62
+ it { should_not set_the_flash }
63
+ end
64
+ end
65
+ ```
66
+
67
+ ## Independent Matchers
68
+
69
+ Matchers to test non-Rails-dependent code:
70
+
71
+ ```ruby
72
+ describe Human do
73
+ it { should delegate_method(:work).to(:robot) }
74
+ end
75
+ ```
76
+
60
77
  ## Installation
61
78
 
62
79
  In Rails 3 and Bundler, add the following to your Gemfile:
63
80
 
64
- group :test do
65
- gem "shoulda-matchers"
66
- end
67
-
68
- # rspec-rails needs to be in the development group so that Rails generators
69
- # work.
70
- group :development, :test do
71
- gem "rspec-rails"
72
- end
81
+ ```ruby
82
+ group :test do
83
+ gem "shoulda-matchers"
84
+ end
85
+
86
+ # rspec-rails needs to be in the development group so that Rails generators
87
+ # work.
88
+ group :development, :test do
89
+ gem "rspec-rails"
90
+ end
91
+ ```
73
92
 
74
93
  Shoulda will automatically include matchers into the appropriate example groups.
75
94
 
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: /Users/draper/Dropbox/Development/shoulda-matchers
3
3
  specs:
4
- shoulda-matchers (1.4.0)
4
+ shoulda-matchers (1.4.1)
5
5
  activesupport (>= 3.0.0)
6
+ bourne (~> 1.1.2)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -38,16 +39,15 @@ GEM
38
39
  bundler
39
40
  rake
40
41
  arel (2.0.10)
41
- aruba (0.5.0)
42
- childprocess (= 0.2.3)
42
+ aruba (0.5.1)
43
+ childprocess (~> 0.3.6)
43
44
  cucumber (>= 1.1.1)
44
- ffi (>= 1.0.11)
45
45
  rspec-expectations (>= 2.7.0)
46
46
  bourne (1.1.2)
47
47
  mocha (= 0.10.5)
48
48
  builder (2.1.2)
49
- childprocess (0.2.3)
50
- ffi (~> 1.0.6)
49
+ childprocess (0.3.6)
50
+ ffi (~> 1.0, >= 1.0.6)
51
51
  cucumber (1.1.9)
52
52
  builder (>= 2.1.2)
53
53
  diff-lcs (>= 1.1.2)
@@ -57,7 +57,7 @@ GEM
57
57
  diff-lcs (1.1.3)
58
58
  erubis (2.6.6)
59
59
  abstract (>= 1.0.0)
60
- ffi (1.0.11)
60
+ ffi (1.2.0)
61
61
  gherkin (2.9.3)
62
62
  json (>= 1.4.6)
63
63
  i18n (0.5.0)
@@ -91,7 +91,7 @@ GEM
91
91
  rake (>= 0.8.7)
92
92
  rdoc (~> 3.4)
93
93
  thor (~> 0.14.4)
94
- rake (0.9.2.2)
94
+ rake (0.9.5)
95
95
  rdoc (3.12)
96
96
  json (~> 1.4)
97
97
  rspec (2.8.0)
@@ -107,14 +107,14 @@ GEM
107
107
  activesupport (>= 3.0)
108
108
  railties (>= 3.0)
109
109
  rspec (~> 2.8.0)
110
- shoulda-context (1.0.0)
110
+ shoulda-context (1.0.1)
111
111
  sqlite3 (1.3.6)
112
112
  term-ansicolor (1.0.7)
113
113
  thor (0.14.6)
114
- treetop (1.4.11)
114
+ treetop (1.4.12)
115
115
  polyglot
116
116
  polyglot (>= 0.3.1)
117
- tzinfo (0.3.33)
117
+ tzinfo (0.3.35)
118
118
 
119
119
  PLATFORMS
120
120
  ruby
@@ -124,7 +124,6 @@ DEPENDENCIES
124
124
  activerecord-jdbcsqlite3-adapter
125
125
  appraisal (~> 0.4.0)
126
126
  aruba
127
- bourne (~> 1.1.2)
128
127
  bundler (~> 1.1)
129
128
  cucumber (~> 1.1.9)
130
129
  jdbc-sqlite3
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: /Users/draper/Dropbox/Development/shoulda-matchers
3
3
  specs:
4
- shoulda-matchers (1.4.0)
4
+ shoulda-matchers (1.4.1)
5
5
  activesupport (>= 3.0.0)
6
+ bourne (~> 1.1.2)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -39,16 +40,15 @@ GEM
39
40
  bundler
40
41
  rake
41
42
  arel (2.2.3)
42
- aruba (0.5.0)
43
- childprocess (= 0.2.3)
43
+ aruba (0.5.1)
44
+ childprocess (~> 0.3.6)
44
45
  cucumber (>= 1.1.1)
45
- ffi (>= 1.0.11)
46
46
  rspec-expectations (>= 2.7.0)
47
47
  bourne (1.1.2)
48
48
  mocha (= 0.10.5)
49
- builder (3.0.3)
50
- childprocess (0.2.3)
51
- ffi (~> 1.0.6)
49
+ builder (3.0.4)
50
+ childprocess (0.3.6)
51
+ ffi (~> 1.0, >= 1.0.6)
52
52
  cucumber (1.1.9)
53
53
  builder (>= 2.1.2)
54
54
  diff-lcs (>= 1.1.2)
@@ -57,14 +57,14 @@ GEM
57
57
  term-ansicolor (>= 1.0.6)
58
58
  diff-lcs (1.1.3)
59
59
  erubis (2.7.0)
60
- ffi (1.0.11)
60
+ ffi (1.2.0)
61
61
  gherkin (2.9.3)
62
62
  json (>= 1.4.6)
63
63
  hike (1.2.1)
64
64
  i18n (0.6.1)
65
- jquery-rails (2.1.3)
66
- railties (>= 3.1.0, < 5.0)
67
- thor (~> 0.14)
65
+ jquery-rails (2.1.4)
66
+ railties (>= 3.0, < 5.0)
67
+ thor (>= 0.14, < 2.0)
68
68
  json (1.7.5)
69
69
  mail (2.3.3)
70
70
  i18n (>= 0.4.0)
@@ -100,7 +100,7 @@ GEM
100
100
  rake (>= 0.8.7)
101
101
  rdoc (~> 3.4)
102
102
  thor (~> 0.14.6)
103
- rake (0.9.2.2)
103
+ rake (0.9.5)
104
104
  rdoc (3.12)
105
105
  json (~> 1.4)
106
106
  rspec (2.8.0)
@@ -116,13 +116,13 @@ GEM
116
116
  activesupport (>= 3.0)
117
117
  railties (>= 3.0)
118
118
  rspec (~> 2.8.0)
119
- sass (3.2.1)
119
+ sass (3.2.3)
120
120
  sass-rails (3.1.6)
121
121
  actionpack (~> 3.1.0)
122
122
  railties (~> 3.1.0)
123
123
  sass (>= 3.1.10)
124
124
  tilt (~> 1.3.2)
125
- shoulda-context (1.0.0)
125
+ shoulda-context (1.0.1)
126
126
  sprockets (2.0.4)
127
127
  hike (~> 1.2)
128
128
  rack (~> 1.0)
@@ -131,10 +131,10 @@ GEM
131
131
  term-ansicolor (1.0.7)
132
132
  thor (0.14.6)
133
133
  tilt (1.3.3)
134
- treetop (1.4.11)
134
+ treetop (1.4.12)
135
135
  polyglot
136
136
  polyglot (>= 0.3.1)
137
- tzinfo (0.3.33)
137
+ tzinfo (0.3.35)
138
138
 
139
139
  PLATFORMS
140
140
  ruby
@@ -144,7 +144,6 @@ DEPENDENCIES
144
144
  activerecord-jdbcsqlite3-adapter
145
145
  appraisal (~> 0.4.0)
146
146
  aruba
147
- bourne (~> 1.1.2)
148
147
  bundler (~> 1.1)
149
148
  cucumber (~> 1.1.9)
150
149
  jdbc-sqlite3
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: /Users/draper/Dropbox/Development/shoulda-matchers
3
3
  specs:
4
- shoulda-matchers (1.4.0)
4
+ shoulda-matchers (1.4.1)
5
5
  activesupport (>= 3.0.0)
6
+ bourne (~> 1.1.2)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
@@ -38,16 +39,15 @@ GEM
38
39
  bundler
39
40
  rake
40
41
  arel (3.0.2)
41
- aruba (0.5.0)
42
- childprocess (= 0.2.3)
42
+ aruba (0.5.1)
43
+ childprocess (~> 0.3.6)
43
44
  cucumber (>= 1.1.1)
44
- ffi (>= 1.0.11)
45
45
  rspec-expectations (>= 2.7.0)
46
46
  bourne (1.1.2)
47
47
  mocha (= 0.10.5)
48
- builder (3.0.3)
49
- childprocess (0.2.3)
50
- ffi (~> 1.0.6)
48
+ builder (3.0.4)
49
+ childprocess (0.3.6)
50
+ ffi (~> 1.0, >= 1.0.6)
51
51
  cucumber (1.1.9)
52
52
  builder (>= 2.1.2)
53
53
  diff-lcs (>= 1.1.2)
@@ -56,15 +56,15 @@ GEM
56
56
  term-ansicolor (>= 1.0.6)
57
57
  diff-lcs (1.1.3)
58
58
  erubis (2.7.0)
59
- ffi (1.0.11)
59
+ ffi (1.2.0)
60
60
  gherkin (2.9.3)
61
61
  json (>= 1.4.6)
62
62
  hike (1.2.1)
63
63
  i18n (0.6.1)
64
64
  journey (1.0.4)
65
- jquery-rails (2.1.3)
66
- railties (>= 3.1.0, < 5.0)
67
- thor (~> 0.14)
65
+ jquery-rails (2.1.4)
66
+ railties (>= 3.0, < 5.0)
67
+ thor (>= 0.14, < 2.0)
68
68
  json (1.7.5)
69
69
  mail (2.4.4)
70
70
  i18n (>= 0.4.0)
@@ -74,7 +74,7 @@ GEM
74
74
  mime-types (1.19)
75
75
  mocha (0.10.5)
76
76
  metaclass (~> 0.0.1)
77
- multi_json (1.3.6)
77
+ multi_json (1.3.7)
78
78
  polyglot (0.3.3)
79
79
  rack (1.4.1)
80
80
  rack-cache (1.2)
@@ -98,7 +98,7 @@ GEM
98
98
  rake (>= 0.8.7)
99
99
  rdoc (~> 3.4)
100
100
  thor (>= 0.14.6, < 2.0)
101
- rake (0.9.2.2)
101
+ rake (0.9.5)
102
102
  rdoc (3.12)
103
103
  json (~> 1.4)
104
104
  rspec (2.8.0)
@@ -114,12 +114,12 @@ GEM
114
114
  activesupport (>= 3.0)
115
115
  railties (>= 3.0)
116
116
  rspec (~> 2.8.0)
117
- sass (3.2.1)
117
+ sass (3.2.3)
118
118
  sass-rails (3.2.5)
119
119
  railties (~> 3.2.0)
120
120
  sass (>= 3.1.10)
121
121
  tilt (~> 1.3)
122
- shoulda-context (1.0.0)
122
+ shoulda-context (1.0.1)
123
123
  sprockets (2.1.3)
124
124
  hike (~> 1.2)
125
125
  rack (~> 1.0)
@@ -128,10 +128,10 @@ GEM
128
128
  term-ansicolor (1.0.7)
129
129
  thor (0.16.0)
130
130
  tilt (1.3.3)
131
- treetop (1.4.11)
131
+ treetop (1.4.12)
132
132
  polyglot
133
133
  polyglot (>= 0.3.1)
134
- tzinfo (0.3.33)
134
+ tzinfo (0.3.35)
135
135
 
136
136
  PLATFORMS
137
137
  ruby
@@ -141,7 +141,6 @@ DEPENDENCIES
141
141
  activerecord-jdbcsqlite3-adapter
142
142
  appraisal (~> 0.4.0)
143
143
  aruba
144
- bourne (~> 1.1.2)
145
144
  bundler (~> 1.1)
146
145
  cucumber (~> 1.1.9)
147
146
  jdbc-sqlite3
@@ -3,6 +3,8 @@ require 'shoulda/matchers/active_model/validation_matcher'
3
3
  require 'shoulda/matchers/active_model/validation_message_finder'
4
4
  require 'shoulda/matchers/active_model/exception_message_finder'
5
5
  require 'shoulda/matchers/active_model/allow_value_matcher'
6
+ require 'shoulda/matchers/active_model/disallow_value_matcher'
7
+ require 'shoulda/matchers/active_model/only_integer_matcher'
6
8
  require 'shoulda/matchers/active_model/ensure_length_of_matcher'
7
9
  require 'shoulda/matchers/active_model/ensure_inclusion_of_matcher'
8
10
  require 'shoulda/matchers/active_model/ensure_exclusion_of_matcher'
@@ -0,0 +1,33 @@
1
+ module Shoulda # :nodoc:
2
+ module Matchers
3
+ module ActiveModel # :nodoc:
4
+ class DisallowValueMatcher # :nodoc:
5
+ def initialize(value)
6
+ @allow_matcher = AllowValueMatcher.new(value)
7
+ end
8
+
9
+ def matches?(subject)
10
+ !@allow_matcher.matches?(subject)
11
+ end
12
+
13
+ def for(attribute)
14
+ @allow_matcher.for(attribute)
15
+ self
16
+ end
17
+
18
+ def with_message(message)
19
+ @allow_matcher.with_message(message)
20
+ self
21
+ end
22
+
23
+ def failure_message
24
+ @allow_matcher.negative_failure_message
25
+ end
26
+
27
+ def allowed_types
28
+ ""
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end