sequel_spec 0.1.1 → 0.2.0

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 (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sequel_spec/association/association_matcher.rb +8 -2
  3. data/lib/sequel_spec/base.rb +1 -1
  4. data/lib/sequel_spec/validation/validate_length_matcher.rb +6 -6
  5. data/lib/sequel_spec/version.rb +1 -1
  6. data/sequel_spec.gemspec +2 -2
  7. data/spec/sequel_spec/association/have_many_through_many_matcher_spec.rb +8 -8
  8. data/spec/sequel_spec/association/have_many_to_many_matcher_spec.rb +8 -8
  9. data/spec/sequel_spec/association/have_many_to_one_matcher_spec.rb +8 -8
  10. data/spec/sequel_spec/association/have_one_through_one_matcher_spec.rb +8 -8
  11. data/spec/sequel_spec/association/have_one_to_many_matcher_spec.rb +8 -8
  12. data/spec/sequel_spec/association/have_one_to_one_matcher_spec.rb +8 -8
  13. data/spec/sequel_spec/validation/validate_format_matcher_spec.rb +16 -16
  14. data/spec/sequel_spec/validation/validate_includes_matcher_spec.rb +16 -16
  15. data/spec/sequel_spec/validation/validate_integer_matcher_spec.rb +13 -13
  16. data/spec/sequel_spec/validation/validate_length_matcher_spec.rb +49 -49
  17. data/spec/sequel_spec/validation/validate_not_null_matcher_spec.rb +15 -15
  18. data/spec/sequel_spec/validation/validate_numeric_matcher_spec.rb +13 -13
  19. data/spec/sequel_spec/validation/validate_presence_matcher_spec.rb +13 -13
  20. data/spec/sequel_spec/validation/validate_schema_types_matcher_spec.rb +15 -15
  21. data/spec/sequel_spec/validation/validate_type_matcher_spec.rb +16 -16
  22. data/spec/sequel_spec/validation/validate_unique_matcher_spec.rb +15 -15
  23. data/spec/spec_helper.rb +0 -1
  24. metadata +11 -11
@@ -15,73 +15,73 @@ describe "validate_includes_matcher" do
15
15
 
16
16
  it "should require an attribute" do
17
17
  expect {
18
- subject.should ensure_inclusion_of
18
+ expect(subject).to ensure_inclusion_of
19
19
  }.to raise_error(ArgumentError)
20
20
  end
21
21
 
22
22
  it "should require additionnal parameters" do
23
23
  expect {
24
- subject.should ensure_inclusion_of(:name)
24
+ expect(subject).to ensure_inclusion_of(:name)
25
25
  }.to raise_error(ArgumentError)
26
26
  end
27
27
 
28
28
  it "should accept with valid parameters" do
29
29
  expect {
30
- subject.should ensure_inclusion_of(:name).in(["Joseph", "Jonathan"])
30
+ expect(subject).to ensure_inclusion_of(:name).in(["Joseph", "Jonathan"])
31
31
  }.not_to raise_error
32
32
  end
33
33
 
34
34
  it "should reject with invalid parameters" do
35
35
  expect {
36
- subject.should ensure_inclusion_of(:name).in(["Adrià", "Jonathan"])
37
- }.to raise_error
36
+ expect(subject).to ensure_inclusion_of(:name).in(["Adrià", "Jonathan"])
37
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
38
38
  end
39
39
 
40
40
  it "should accept with valid parameters and options" do
41
41
  expect {
42
- subject.should ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_nil
42
+ expect(subject).to ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_nil
43
43
  }.not_to raise_error
44
44
  end
45
45
 
46
46
  it "should reject with valid parameters but invalid options" do
47
47
  expect {
48
- subject.should ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_blank
49
- }.to raise_error
48
+ expect(subject).to ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_blank
49
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
50
50
  end
51
51
 
52
52
  describe "messages" do
53
53
  describe "without option" do
54
54
  it "should contain a description" do
55
55
  @matcher = ensure_inclusion_of(:name).in ["Joseph", "Jonathan"]
56
- @matcher.description.should == 'validate that :name is included in ["Joseph", "Jonathan"]'
56
+ expect(@matcher.description).to eq 'validate that :name is included in ["Joseph", "Jonathan"]'
57
57
  end
58
58
 
59
59
  it "should set failure messages" do
60
60
  @matcher = ensure_inclusion_of(:name).in ["Joseph", "Jonathan"]
61
61
  @matcher.matches? subject
62
- @matcher.failure_message.should == "expected Item to " + @matcher.description
63
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
62
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
63
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
64
64
  end
65
65
  end
66
66
  describe "with options" do
67
67
  it "should contain a description" do
68
68
  @matcher = ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_nil
69
- @matcher.description.should == 'validate that :name is included in ["Joseph", "Jonathan"] with option(s) :allow_nil => true'
69
+ expect(@matcher.description).to eq 'validate that :name is included in ["Joseph", "Jonathan"] with option(s) :allow_nil => true'
70
70
  end
71
71
 
72
72
  it "should set failure messages" do
73
73
  @matcher = ensure_inclusion_of(:price).in(["Joseph", "Jonathan"]).allowing_nil
74
74
  @matcher.matches? subject
75
- @matcher.failure_message.should == "expected Item to " + @matcher.description
76
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
75
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
76
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
77
77
  end
78
78
 
79
79
  it "should explicit used options if different than expected" do
80
80
  @matcher = ensure_inclusion_of(:name).in(["Joseph", "Jonathan"]).allowing_blank
81
81
  @matcher.matches? subject
82
82
  explanation = " but called with option(s) :allow_nil => true instead"
83
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
84
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
83
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
84
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
85
85
  end
86
86
  end
87
87
  end
@@ -15,61 +15,61 @@ describe "validate_integer_matcher" do
15
15
 
16
16
  it "should require an attribute" do
17
17
  expect {
18
- subject.should validate_integer
18
+ expect(subject).to validate_integer
19
19
  }.to raise_error(ArgumentError)
20
20
  end
21
21
 
22
22
  it "should accept with an attribute" do
23
23
  expect {
24
- subject.should validate_integer(:name)
24
+ expect(subject).to validate_integer(:name)
25
25
  }.not_to raise_error
26
26
  end
27
27
 
28
28
  it "should accept with valid options" do
29
29
  expect {
30
- subject.should validate_integer(:name).allowing_nil
30
+ expect(subject).to validate_integer(:name).allowing_nil
31
31
  }.not_to raise_error
32
32
  end
33
33
 
34
34
  it "should reject with invalid options" do
35
35
  expect {
36
- subject.should validate_integer(:name).allowing_blank
37
- }.to raise_error
36
+ expect(subject).to validate_integer(:name).allowing_blank
37
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
38
38
  end
39
39
 
40
40
  describe "messages" do
41
41
  describe "without option" do
42
42
  it "should contain a description" do
43
43
  @matcher = validate_integer :name
44
- @matcher.description.should == "validate that :name is a valid integer"
44
+ expect(@matcher.description).to eq "validate that :name is a valid integer"
45
45
  end
46
46
 
47
47
  it "should set failure messages" do
48
48
  @matcher = validate_integer :name
49
49
  @matcher.matches? subject
50
- @matcher.failure_message.should == "expected Item to " + @matcher.description
51
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
50
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
51
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
52
52
  end
53
53
  end
54
54
  describe "with options" do
55
55
  it "should contain a description" do
56
56
  @matcher = validate_integer(:name).allowing_nil
57
- @matcher.description.should == "validate that :name is a valid integer with option(s) :allow_nil => true"
57
+ expect(@matcher.description).to eq "validate that :name is a valid integer with option(s) :allow_nil => true"
58
58
  end
59
59
 
60
60
  it "should set failure messages" do
61
61
  @matcher = validate_integer(:price).allowing_nil
62
62
  @matcher.matches? subject
63
- @matcher.failure_message.should == "expected Item to " + @matcher.description
64
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
63
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
64
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
65
65
  end
66
66
 
67
67
  it "should explicit used options if different than expected" do
68
68
  @matcher = validate_integer(:name).allowing_blank
69
69
  @matcher.matches? subject
70
70
  explanation = " but called with option(s) :allow_nil => true instead"
71
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
72
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
71
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
72
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
73
73
  end
74
74
  end
75
75
  end
@@ -18,81 +18,81 @@ describe "validate_length_matcher" do
18
18
 
19
19
  it "should require an attribute" do
20
20
  expect {
21
- subject.should validate_length_of
21
+ expect(subject).to validate_length_of
22
22
  }.to raise_error(ArgumentError)
23
23
  end
24
24
 
25
25
  it "should require additionnal parameters" do
26
26
  expect {
27
- subject.should validate_length_of(:name)
27
+ expect(subject).to validate_length_of(:name)
28
28
  }.to raise_error(ArgumentError)
29
29
  end
30
30
 
31
31
  it "should accept with valid parameters and options" do
32
32
  expect {
33
- subject.should validate_length_of(:name).is(4).allowing_nil
33
+ expect(subject).to validate_length_of(:name).is(4).allowing_nil
34
34
  }.not_to raise_error
35
35
  end
36
36
 
37
37
  it "should reject with valid parameters but invalid options" do
38
38
  expect {
39
- subject.should validate_length_of(:name).is(4).allowing_blank
40
- }.to raise_error
39
+ expect(subject).to validate_length_of(:name).is(4).allowing_blank
40
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
41
41
  end
42
42
 
43
43
  context "with exact length" do
44
44
  it "should accept with valid parameters" do
45
45
  expect {
46
- subject.should validate_length_of(:name).is(4)
46
+ expect(subject).to validate_length_of(:name).is(4)
47
47
  }.not_to raise_error
48
48
  end
49
49
 
50
50
  it "should reject with invalid parameters" do
51
51
  expect {
52
- subject.should validate_length_of(:name).is(5)
53
- }.to raise_error
52
+ expect(subject).to validate_length_of(:name).is(5)
53
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
54
54
  end
55
55
  end
56
56
 
57
57
  context "with length range" do
58
58
  it "should accept with valid parameters" do
59
59
  expect {
60
- subject.should validate_length_of(:manufacturer).is_between(1..10)
60
+ expect(subject).to validate_length_of(:manufacturer).is_between(1..10)
61
61
  }.not_to raise_error
62
62
  end
63
63
 
64
64
  it "should reject with invalid parameters" do
65
65
  expect {
66
- subject.should validate_length_of(:manufacturer).is_between(1..20)
67
- }.to raise_error
66
+ expect(subject).to validate_length_of(:manufacturer).is_between(1..20)
67
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
68
68
  end
69
69
  end
70
70
 
71
71
  context "with minimum length" do
72
72
  it "should accept with valid parameters" do
73
73
  expect {
74
- subject.should validate_length_of(:owner).is_at_least(4)
74
+ expect(subject).to validate_length_of(:owner).is_at_least(4)
75
75
  }.not_to raise_error
76
76
  end
77
77
 
78
78
  it "should reject with invalid parameters" do
79
79
  expect {
80
- subject.should validate_length_of(:owner).is_at_least(8)
81
- }.to raise_error
80
+ expect(subject).to validate_length_of(:owner).is_at_least(8)
81
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
82
82
  end
83
83
  end
84
84
 
85
85
  context "with maximum length" do
86
86
  it "should accept with valid parameters" do
87
87
  expect {
88
- subject.should validate_length_of(:origin).is_at_most(4)
88
+ expect(subject).to validate_length_of(:origin).is_at_most(4)
89
89
  }.not_to raise_error
90
90
  end
91
91
 
92
92
  it "should reject with invalid parameters" do
93
93
  expect {
94
- subject.should validate_length_of(:origin).is_at_most(8)
95
- }.to raise_error
94
+ expect(subject).to validate_length_of(:origin).is_at_most(8)
95
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
96
96
  end
97
97
  end
98
98
 
@@ -101,36 +101,36 @@ describe "validate_length_matcher" do
101
101
  describe "without option" do
102
102
  it "should contain a description" do
103
103
  @matcher = validate_length_of(:name).is(4)
104
- @matcher.description.should == "validate that length of :name is exactly 4"
104
+ expect(@matcher.description).to eq "validate that length of :name is exactly 4"
105
105
  end
106
106
 
107
107
  it "should set failure messages" do
108
108
  @matcher = validate_length_of(:name).is(4)
109
109
  @matcher.matches? subject
110
- @matcher.failure_message.should == "expected Item to " + @matcher.description
111
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
110
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
111
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
112
112
  end
113
113
  end
114
114
 
115
115
  describe "with options" do
116
116
  it "should contain a description" do
117
117
  @matcher = validate_length_of(:name).is(4).allowing_nil
118
- @matcher.description.should == "validate that length of :name is exactly 4 with option(s) :allow_nil => true"
118
+ expect(@matcher.description).to eq "validate that length of :name is exactly 4 with option(s) :allow_nil => true"
119
119
  end
120
120
 
121
121
  it "should set failure messages" do
122
122
  @matcher = validate_length_of(:price).is(4).allowing_nil
123
123
  @matcher.matches? subject
124
- @matcher.failure_message.should == "expected Item to " + @matcher.description
125
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
124
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
125
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
126
126
  end
127
127
 
128
128
  it "should explicit used options if different than expected" do
129
129
  @matcher = validate_length_of(:name).is(4).allowing_blank
130
130
  @matcher.matches? subject
131
131
  explanation = " but called with option(s) :allow_nil => true instead"
132
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
133
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
132
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
133
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
134
134
  end
135
135
  end
136
136
  end
@@ -139,36 +139,36 @@ describe "validate_length_matcher" do
139
139
  describe "without option" do
140
140
  it "should contain a description" do
141
141
  @matcher = validate_length_of(:manufacturer).is_between(1..10)
142
- @matcher.description.should == "validate that length of :manufacturer is included in 1..10"
142
+ expect(@matcher.description).to eq "validate that length of :manufacturer is included in 1..10"
143
143
  end
144
144
 
145
145
  it "should set failure messages" do
146
146
  @matcher = validate_length_of(:manufacturer).is_between(1..10)
147
147
  @matcher.matches? subject
148
- @matcher.failure_message.should == "expected Item to " + @matcher.description
149
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
148
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
149
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
150
150
  end
151
151
  end
152
152
 
153
153
  describe "with options" do
154
154
  it "should contain a description" do
155
155
  @matcher = validate_length_of(:manufacturer).is_between(1..10).allowing_nil
156
- @matcher.description.should == "validate that length of :manufacturer is included in 1..10 with option(s) :allow_nil => true"
156
+ expect(@matcher.description).to eq "validate that length of :manufacturer is included in 1..10 with option(s) :allow_nil => true"
157
157
  end
158
158
 
159
159
  it "should set failure messages" do
160
160
  @matcher = validate_length_of(:price).is_between(1..10).allowing_nil
161
161
  @matcher.matches? subject
162
- @matcher.failure_message.should == "expected Item to " + @matcher.description
163
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
162
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
163
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
164
164
  end
165
165
 
166
166
  it "should explicit used options if different than expected" do
167
167
  @matcher = validate_length_of(:manufacturer).is_between(1..10).allowing_blank
168
168
  @matcher.matches? subject
169
169
  explanation = " but called with option(s) :allow_nil => true instead"
170
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
171
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
170
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
171
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
172
172
  end
173
173
  end
174
174
  end
@@ -177,36 +177,36 @@ describe "validate_length_matcher" do
177
177
  describe "without option" do
178
178
  it "should contain a description" do
179
179
  @matcher = validate_length_of(:owner).is_at_least(4)
180
- @matcher.description.should == "validate that length of :owner is greater than or equal to 4"
180
+ expect(@matcher.description).to eq "validate that length of :owner is greater than or equal to 4"
181
181
  end
182
182
 
183
183
  it "should set failure messages" do
184
184
  @matcher = validate_length_of(:owner).is_at_least(4)
185
185
  @matcher.matches? subject
186
- @matcher.failure_message.should == "expected Item to " + @matcher.description
187
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
186
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
187
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
188
188
  end
189
189
  end
190
190
 
191
191
  describe "with options" do
192
192
  it "should contain a description" do
193
193
  @matcher = validate_length_of(:owner).is_at_least(4).allowing_nil
194
- @matcher.description.should == "validate that length of :owner is greater than or equal to 4 with option(s) :allow_nil => true"
194
+ expect(@matcher.description).to eq "validate that length of :owner is greater than or equal to 4 with option(s) :allow_nil => true"
195
195
  end
196
196
 
197
197
  it "should set failure messages" do
198
198
  @matcher = validate_length_of(:price).is_at_least(4).allowing_nil
199
199
  @matcher.matches? subject
200
- @matcher.failure_message.should == "expected Item to " + @matcher.description
201
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
200
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
201
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
202
202
  end
203
203
 
204
204
  it "should explicit used options if different than expected" do
205
205
  @matcher = validate_length_of(:owner).is_at_least(4).allowing_blank
206
206
  @matcher.matches? subject
207
207
  explanation = " but called with option(s) :allow_nil => true instead"
208
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
209
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
208
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
209
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
210
210
  end
211
211
  end
212
212
  end
@@ -215,36 +215,36 @@ describe "validate_length_matcher" do
215
215
  describe "without option" do
216
216
  it "should contain a description" do
217
217
  @matcher = validate_length_of(:origin).is_at_most(4)
218
- @matcher.description.should == "validate that length of :origin is less than or equal to 4"
218
+ expect(@matcher.description).to eq "validate that length of :origin is less than or equal to 4"
219
219
  end
220
220
 
221
221
  it "should set failure messages" do
222
222
  @matcher = validate_length_of(:origin).is_at_most(4)
223
223
  @matcher.matches? subject
224
- @matcher.failure_message.should == "expected Item to " + @matcher.description
225
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
224
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
225
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
226
226
  end
227
227
  end
228
228
 
229
229
  describe "with options" do
230
230
  it "should contain a description" do
231
231
  @matcher = validate_length_of(:origin).is_at_most(4).allowing_nil
232
- @matcher.description.should == "validate that length of :origin is less than or equal to 4 with option(s) :allow_nil => true"
232
+ expect(@matcher.description).to eq "validate that length of :origin is less than or equal to 4 with option(s) :allow_nil => true"
233
233
  end
234
234
 
235
235
  it "should set failure messages" do
236
236
  @matcher = validate_length_of(:price).is_at_most(4).allowing_nil
237
237
  @matcher.matches? subject
238
- @matcher.failure_message.should == "expected Item to " + @matcher.description
239
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
238
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
239
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
240
240
  end
241
241
 
242
242
  it "should explicit used options if different than expected" do
243
243
  @matcher = validate_length_of(:origin).is_at_most(4).allowing_blank
244
244
  @matcher.matches? subject
245
245
  explanation = " but called with option(s) :allow_nil => true instead"
246
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
247
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
246
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
247
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
248
248
  end
249
249
  end
250
250
  end
@@ -15,68 +15,68 @@ describe "validate_not_null_matcher" do
15
15
 
16
16
  it "should require an attribute" do
17
17
  expect {
18
- subject.should validate_not_null
18
+ expect(subject).to validate_not_null
19
19
  }.to raise_error(ArgumentError)
20
20
  end
21
21
 
22
22
  it "should accept with an attribute" do
23
23
  expect {
24
- subject.should validate_not_null(:name)
24
+ expect(subject).to validate_not_null(:name)
25
25
  }.not_to raise_error
26
26
  end
27
27
 
28
28
  it "should accept with valid options" do
29
29
  expect {
30
- subject.should validate_not_null(:name).with_message "Hello"
30
+ expect(subject).to validate_not_null(:name).with_message "Hello"
31
31
  }.not_to raise_error
32
32
  end
33
33
 
34
34
  it "should reject with options with invalid values" do
35
35
  expect {
36
- subject.should validate_not_null(:name).with_message "Bye"
37
- }.to raise_error
36
+ expect(subject).to validate_not_null(:name).with_message "Bye"
37
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
38
38
  end
39
39
 
40
40
  it "should reject with invalid options" do
41
41
  expect {
42
- subject.should validate_not_null(:name).allowing_nil
43
- }.to raise_error
42
+ expect(subject).to validate_not_null(:name).allowing_nil
43
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
44
44
  end
45
45
 
46
46
  describe "messages" do
47
47
  describe "without option" do
48
48
  it "should contain a description" do
49
49
  @matcher = validate_not_null :name
50
- @matcher.description.should == "validate that :name is not null"
50
+ expect(@matcher.description).to eq "validate that :name is not null"
51
51
  end
52
52
 
53
53
  it "should set failure messages" do
54
54
  @matcher = validate_not_null :name
55
55
  @matcher.matches? subject
56
- @matcher.failure_message.should == "expected Item to " + @matcher.description
57
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
56
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
57
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
58
58
  end
59
59
  end
60
60
 
61
61
  describe "with options" do
62
62
  it "should contain a description" do
63
63
  @matcher = validate_not_null(:name).with_message("Hello")
64
- @matcher.description.should == 'validate that :name is not null with option(s) :message => "Hello"'
64
+ expect(@matcher.description).to eq 'validate that :name is not null with option(s) :message => "Hello"'
65
65
  end
66
66
 
67
67
  it "should set failure messages" do
68
68
  @matcher = validate_not_null(:price).with_message("Hello")
69
69
  @matcher.matches? subject
70
- @matcher.failure_message.should == "expected Item to " + @matcher.description
71
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description
70
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description
71
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description
72
72
  end
73
73
 
74
74
  it "should explicit used options if different than expected" do
75
75
  @matcher = validate_not_null(:name).with_message("Hello world")
76
76
  @matcher.matches? subject
77
77
  explanation = ' but called with option(s) :message => "Hello" instead'
78
- @matcher.failure_message.should == "expected Item to " + @matcher.description + explanation
79
- @matcher.negative_failure_message.should == "expected Item to not " + @matcher.description + explanation
78
+ expect(@matcher.failure_message).to eq "expected Item to " + @matcher.description + explanation
79
+ expect(@matcher.failure_message_when_negated).to eq "expected Item to not " + @matcher.description + explanation
80
80
  end
81
81
  end
82
82
  end