rspec-expectations 2.4.0 → 2.5.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.
- data/Guardfile +3 -3
- data/features/.nav +1 -0
- data/{History.markdown → features/Changelog.md} +10 -1
- data/{Upgrade.markdown → features/Upgrade.md} +0 -0
- data/features/built_in_matchers/exist.feature +9 -4
- data/features/built_in_matchers/expect_change.feature +24 -30
- data/features/built_in_matchers/expect_error.feature +87 -26
- data/features/built_in_matchers/include.feature +1 -15
- data/features/step_definitions/additional_cli_steps.rb +9 -0
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers/block_aliases.rb +1 -0
- data/lib/rspec/matchers/exist.rb +13 -3
- data/spec/rspec/matchers/exist_spec.rb +90 -51
- data/spec/rspec/matchers/include_spec.rb +14 -20
- metadata +13 -9
data/Guardfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
guard 'rspec', :version => 2 do
|
2
|
-
watch(
|
3
|
-
watch(
|
4
|
-
watch(
|
2
|
+
watch(/^spec\/(.*)_spec.rb/)
|
3
|
+
watch(/^lib\/(.*)\.rb/) { |m| "spec/#{m[1]}_spec.rb" }
|
4
|
+
watch(/^spec\/spec_helper.rb/) { "spec" }
|
5
5
|
end
|
data/features/.nav
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
|
1
|
+
### 2.5.0 / 2011-02-05
|
2
|
+
|
3
|
+
[full changelog](http://github.com/rspec/rspec-expectations/compare/v2.4.0...v2.5.0)
|
4
|
+
|
5
|
+
* Enhancements
|
6
|
+
* `should exist` works with `exist?` or `exists?` (Myron Marston)
|
7
|
+
* `expect { ... }.not_to do_something` (in addition to `to_not`)
|
8
|
+
|
9
|
+
* Documentation
|
10
|
+
* improved docs for raise_error matcher (James Almond)
|
2
11
|
|
3
12
|
### 2.4.0 / 2011-01-02
|
4
13
|
|
File without changes
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Feature: exist matcher
|
2
2
|
|
3
3
|
The exist matcher is used to specify that something exists
|
4
|
-
(as indicated by #exist?):
|
4
|
+
(as indicated by #exist? or #exists?):
|
5
5
|
|
6
|
-
obj.should exist # passes if obj.exist?
|
6
|
+
obj.should exist # passes if obj.exist? or obj.exists?
|
7
7
|
|
8
|
-
Scenario: basic usage
|
8
|
+
Scenario Outline: basic usage
|
9
9
|
Given a file named "exist_matcher_spec.rb" with:
|
10
10
|
"""
|
11
11
|
class Planet
|
@@ -19,7 +19,7 @@ Feature: exist matcher
|
|
19
19
|
"<Planet: #{name}>"
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def <predicate_method>
|
23
23
|
%w[Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune].include?(name)
|
24
24
|
end
|
25
25
|
end
|
@@ -42,3 +42,8 @@ Feature: exist matcher
|
|
42
42
|
| expected <Planet: Earth> not to exist |
|
43
43
|
| expected <Planet: Tatooine> to exist |
|
44
44
|
|
45
|
+
Examples:
|
46
|
+
| predicate_method |
|
47
|
+
| exist? |
|
48
|
+
| exists? |
|
49
|
+
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Feature: expect change
|
2
2
|
|
3
|
-
Expect
|
4
|
-
|
5
|
-
|
6
|
-
Given a file named "
|
3
|
+
Expect the execution of a block of code to change the state of an object.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given a file named "lib/counter.rb" with:
|
7
7
|
"""
|
8
8
|
class Counter
|
9
9
|
class << self
|
@@ -17,49 +17,43 @@ Feature: expect change
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: expect change
|
23
|
+
Given a file named "spec/example_spec.rb" with:
|
24
|
+
"""
|
25
|
+
require "counter"
|
26
|
+
|
21
27
|
describe Counter, "#increment" do
|
22
28
|
it "should increment the count" do
|
23
|
-
expect{Counter.increment}.to change{Counter.count}.from(0).to(1)
|
29
|
+
expect { Counter.increment }.to change{Counter.count}.from(0).to(1)
|
24
30
|
end
|
25
31
|
|
26
32
|
# deliberate failure
|
27
33
|
it "should increment the count by 2" do
|
28
|
-
expect{Counter.increment}.to change{Counter.count}.by(2)
|
34
|
+
expect { Counter.increment }.to change{Counter.count}.by(2)
|
29
35
|
end
|
30
36
|
end
|
31
37
|
"""
|
32
|
-
When I run "rspec
|
33
|
-
Then the output should contain "
|
38
|
+
When I run "rspec spec/example_spec.rb"
|
39
|
+
Then the output should contain "1 failure"
|
34
40
|
Then the output should contain "should have been changed by 2, but was changed by 1"
|
35
41
|
|
36
|
-
Scenario:
|
37
|
-
Given a file named "
|
42
|
+
Scenario: expect no change
|
43
|
+
Given a file named "spec/example_spec.rb" with:
|
38
44
|
"""
|
39
|
-
|
40
|
-
class << self
|
41
|
-
def increment
|
42
|
-
@count ||= 0
|
43
|
-
@count += 1
|
44
|
-
end
|
45
|
-
|
46
|
-
def count
|
47
|
-
@count ||= 0
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
45
|
+
require "counter"
|
51
46
|
|
52
47
|
describe Counter, "#increment" do
|
53
|
-
it "should not increment the count by
|
54
|
-
expect{Counter.increment}.to_not change{Counter.count}
|
48
|
+
it "should not increment the count by 1 (using to_not)" do
|
49
|
+
expect { Counter.increment }.to_not change{Counter.count}
|
55
50
|
end
|
56
51
|
|
57
|
-
|
58
|
-
|
59
|
-
expect{Counter.increment}.to_not change{Counter.count}.by(1)
|
52
|
+
it "should not increment the count by 1 (using not_to)" do
|
53
|
+
expect { Counter.increment }.not_to change{Counter.count}
|
60
54
|
end
|
61
55
|
end
|
62
56
|
"""
|
63
|
-
When I run "rspec
|
64
|
-
Then the output should contain "2
|
57
|
+
When I run "rspec spec/example_spec.rb"
|
58
|
+
Then the output should contain "2 failures"
|
65
59
|
Then the output should contain "should not have changed, but did change from 1 to 2"
|
@@ -1,44 +1,105 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: raise_error matcher
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Use the `raise_error` matcher to specify that a block of code raises an
|
4
|
+
error. The most basic form passes if any error is thrown:
|
5
|
+
|
6
|
+
expect { raise StandardError }.to raise_error
|
7
|
+
|
8
|
+
You can use `raise_exception` instead if you prefer that wording:
|
9
|
+
|
10
|
+
expect { 3 / 0 }.to raise_exception
|
11
|
+
|
12
|
+
`raise_error` and `raise_exception` are functionally interchangeable, so use
|
13
|
+
the one that makes the most sense to you in any given context.
|
14
|
+
|
15
|
+
In addition to the basic form, above, there are a number of ways to specify
|
16
|
+
details of an error/exception:
|
17
|
+
|
18
|
+
Scenario: expect any error
|
6
19
|
Given a file named "expect_error_spec.rb" with:
|
7
20
|
"""
|
8
|
-
describe
|
9
|
-
it "
|
10
|
-
expect{Object.
|
21
|
+
describe "calling a method that does not exist" do
|
22
|
+
it "raises" do
|
23
|
+
expect { Object.new.foo }.to raise_error
|
11
24
|
end
|
12
25
|
end
|
26
|
+
"""
|
27
|
+
When I run "rspec expect_error_spec.rb"
|
28
|
+
Then the example should pass
|
13
29
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
30
|
+
Scenario: expect specific error
|
31
|
+
Given a file named "expect_error_spec.rb" with:
|
32
|
+
"""
|
33
|
+
describe "calling a method that does not exist" do
|
34
|
+
it "raises" do
|
35
|
+
expect { Object.new.foo }.to raise_error(NameError)
|
18
36
|
end
|
19
37
|
end
|
20
38
|
"""
|
21
|
-
When I run "rspec
|
22
|
-
Then the
|
23
|
-
Then the output should contain "expected NameError but nothing was raised"
|
39
|
+
When I run "rspec expect_error_spec.rb"
|
40
|
+
Then the example should pass
|
24
41
|
|
25
|
-
Scenario: expect
|
26
|
-
Given a file named "
|
42
|
+
Scenario: expect specific error message using a string
|
43
|
+
Given a file named "expect_error_with_message.rb" with:
|
27
44
|
"""
|
28
|
-
describe
|
29
|
-
it "
|
30
|
-
expect{
|
45
|
+
describe "matching error message with string" do
|
46
|
+
it "matches the error message" do
|
47
|
+
expect { raise StandardError, 'this message exactly'}.
|
48
|
+
to raise_error(StandardError, 'this message exactly')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
"""
|
52
|
+
When I run "rspec expect_error_with_message.rb"
|
53
|
+
Then the example should pass
|
54
|
+
|
55
|
+
Scenario: expect specific error message using a regular expression
|
56
|
+
Given a file named "expect_error_with_regex.rb" with:
|
57
|
+
"""
|
58
|
+
describe "matching error message with regex" do
|
59
|
+
it "matches the error message" do
|
60
|
+
expect { raise StandardError, "my message" }.
|
61
|
+
to raise_error(StandardError, /my mess/)
|
31
62
|
end
|
32
63
|
end
|
64
|
+
"""
|
65
|
+
When I run "rspec expect_error_with_regex.rb"
|
66
|
+
Then the example should pass
|
33
67
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
68
|
+
Scenario: set expectations on error object passed to block
|
69
|
+
Given a file named "expect_error_with_block_spec.rb" with:
|
70
|
+
"""
|
71
|
+
describe "#foo" do
|
72
|
+
it "raises NameError" do
|
73
|
+
expect { Object.new.foo }.to raise_error { |error|
|
74
|
+
error.should be_a(NameError)
|
75
|
+
}
|
38
76
|
end
|
39
77
|
end
|
40
78
|
"""
|
41
|
-
|
42
|
-
|
43
|
-
Then the output should contain "undefined method `non_existent_message'"
|
79
|
+
When I run "rspec expect_error_with_block_spec.rb"
|
80
|
+
Then the example should pass
|
44
81
|
|
82
|
+
Scenario: expect no error at all
|
83
|
+
Given a file named "expect_no_error_spec.rb" with:
|
84
|
+
"""
|
85
|
+
describe "#to_s" do
|
86
|
+
it "does not raise" do
|
87
|
+
expect { Object.new.to_s }.to_not raise_error
|
88
|
+
end
|
89
|
+
end
|
90
|
+
"""
|
91
|
+
When I run "rspec expect_no_error_spec.rb"
|
92
|
+
Then the example should pass
|
93
|
+
|
94
|
+
Scenario: expect no occurence of a specific error
|
95
|
+
Given a file named "expect_no_error_spec.rb" with:
|
96
|
+
"""
|
97
|
+
describe Object, "#public_instance_methods" do
|
98
|
+
it "does not raise" do
|
99
|
+
expect { Object.public_instance_methods }.
|
100
|
+
to_not raise_error(NameError)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
"""
|
104
|
+
When I run "rspec expect_no_error_spec.rb"
|
105
|
+
Then the example should pass
|
@@ -118,18 +118,4 @@ Feature: include matcher
|
|
118
118
|
end
|
119
119
|
"""
|
120
120
|
When I run "rspec hash_include_matcher_spec.rb"
|
121
|
-
Then the output should contain
|
122
|
-
| 22 examples, 13 failures |
|
123
|
-
| expected {:a=>7, :b=>5} not to include :a |
|
124
|
-
| expected {:a=>7, :b=>5} not to include :b and :a |
|
125
|
-
| expected {:a=>7, :b=>5} not to include {:a=>7} |
|
126
|
-
| expected {:a=>7, :b=>5} not to include {:a=>7, :b=>5} |
|
127
|
-
| expected {:a=>7, :b=>5} to include :c |
|
128
|
-
| expected {:a=>7, :b=>5} to include :c and :d |
|
129
|
-
| expected {:a=>7, :b=>5} to include {:d=>2} |
|
130
|
-
| expected {:a=>7, :b=>5} to include {:a=>5} |
|
131
|
-
| expected {:a=>7, :b=>5} to include {:a=>5, :b=>7} |
|
132
|
-
| expected {:a=>7, :b=>5} to include :a and :d |
|
133
|
-
| expected {:a=>7, :b=>5} not to include :a and :d |
|
134
|
-
And the output should match /expected \{:a=>7, :b=>5\} to include \{(?::a=>7, :d=>3)|(?::d=>3, :a=>7)\}/
|
135
|
-
And the output should match /expected \{:a=>7, :b=>5\} not to include \{(?::a=>7, :d=>3)|(?::d=>3, :a=>7)\}/
|
121
|
+
Then the output should contain "13 failure"
|
@@ -11,3 +11,12 @@ Then /^the output should contain all of these:$/ do |table|
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
Then /^the example(?:s)? should(?: all)? pass$/ do
|
15
|
+
Then %q{the output should contain "0 failures"}
|
16
|
+
Then %q{the exit status should be 0}
|
17
|
+
end
|
18
|
+
|
19
|
+
Then /^the example should fail$/ do
|
20
|
+
Then %q{the output should contain "1 failure"}
|
21
|
+
Then %q{the exit status should not be 0}
|
22
|
+
end
|
data/lib/rspec/matchers/exist.rb
CHANGED
@@ -4,11 +4,21 @@ module RSpec
|
|
4
4
|
# should exist
|
5
5
|
# should_not exist
|
6
6
|
#
|
7
|
-
# Passes if actual.exist?
|
8
|
-
def exist(
|
7
|
+
# Passes if actual.exist? or actual.exists?
|
8
|
+
def exist(*args)
|
9
9
|
Matcher.new :exist do
|
10
10
|
match do |actual|
|
11
|
-
|
11
|
+
predicates = [:exist?, :exists?].select { |p| actual.respond_to?(p) }
|
12
|
+
existance_values = predicates.map { |p| actual.send(p, *args) }
|
13
|
+
uniq_truthy_values = existance_values.map { |v| !!v }.uniq
|
14
|
+
|
15
|
+
case uniq_truthy_values.size
|
16
|
+
when 0; raise NoMethodError.new("#{actual.inspect} does not respond to either #exist? or #exists?")
|
17
|
+
when 1; existance_values.first
|
18
|
+
else raise "#exist? and #exists? returned different values:\n\n" +
|
19
|
+
" exist?: #{existance_values.first}\n" +
|
20
|
+
"exists?: #{existance_values.last}"
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -1,65 +1,104 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@description = description
|
7
|
-
end
|
8
|
-
def exist?(arg=nil)
|
9
|
-
@exists
|
10
|
-
end
|
11
|
-
def inspect
|
12
|
-
@description
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class SubstanceTester
|
17
|
-
include RSpec::Matchers
|
18
|
-
def initialize substance
|
19
|
-
@substance = substance
|
20
|
-
end
|
21
|
-
def should_exist
|
22
|
-
@substance.should exist
|
23
|
-
end
|
24
|
-
end
|
3
|
+
describe "exist matcher" do
|
4
|
+
context "when the object does not respond to #exist? or #exists?" do
|
5
|
+
subject { mock }
|
25
6
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
7
|
+
[:should, :should_not].each do |should_method|
|
8
|
+
describe "#{should_method} exist" do
|
9
|
+
it "raises an error" do
|
10
|
+
expect {
|
11
|
+
subject.send(should_method, exist)
|
12
|
+
}.to raise_error(NoMethodError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
31
16
|
end
|
32
17
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
18
|
+
[:exist?, :exists?].each do |predicate|
|
19
|
+
context "when the object responds to ##{predicate}" do
|
20
|
+
describe "should exist" do
|
21
|
+
it "passes if #{predicate}" do
|
22
|
+
mock(predicate => true).should exist
|
23
|
+
end
|
24
|
+
|
25
|
+
it "fails if not #{predicate}" do
|
26
|
+
expect {
|
27
|
+
mock(predicate => false).should exist
|
28
|
+
}.to fail_with(/expected .* to exist/)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "should not exist" do
|
33
|
+
it "passes if not #{predicate}" do
|
34
|
+
mock(predicate => false).should_not exist
|
35
|
+
end
|
36
|
+
|
37
|
+
it "fails if #{predicate}" do
|
38
|
+
expect {
|
39
|
+
mock(predicate => true).should_not exist
|
40
|
+
}.to fail_with(/expected .* not to exist/)
|
41
|
+
end
|
42
|
+
end
|
53
43
|
end
|
54
44
|
end
|
55
45
|
|
56
|
-
|
46
|
+
context "when the object responds to #exist? and #exists?" do
|
47
|
+
context "when they both return falsey values" do
|
48
|
+
subject { mock(:exist? => false, :exists? => nil) }
|
49
|
+
|
50
|
+
describe "should_not exist" do
|
51
|
+
it "passes" do
|
52
|
+
subject.should_not exist
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "should exist" do
|
57
|
+
it "fails" do
|
58
|
+
expect {
|
59
|
+
subject.should exist
|
60
|
+
}.to fail_with(/expected .* to exist/)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when they both return truthy values" do
|
66
|
+
subject { mock(:exist? => true, :exists? => "something true") }
|
67
|
+
|
68
|
+
describe "should_not exist" do
|
69
|
+
it "fails" do
|
70
|
+
expect {
|
71
|
+
subject.should_not exist
|
72
|
+
}.to fail_with(/expected .* not to exist/)
|
73
|
+
end
|
74
|
+
end
|
57
75
|
|
58
|
-
|
59
|
-
|
60
|
-
|
76
|
+
describe "should exist" do
|
77
|
+
it "passes" do
|
78
|
+
subject.should exist
|
79
|
+
end
|
80
|
+
end
|
61
81
|
end
|
62
82
|
|
83
|
+
context "when they return values with different truthiness" do
|
84
|
+
subject { mock(:exist? => true, :exists? => false) }
|
85
|
+
|
86
|
+
[:should, :should_not].each do |should_method|
|
87
|
+
describe "#{should_method} exist" do
|
88
|
+
it "raises an error" do
|
89
|
+
expect {
|
90
|
+
subject.send(should_method, exist)
|
91
|
+
}.to raise_error(/#exist\? and #exists\? returned different values/)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
63
96
|
end
|
64
97
|
|
98
|
+
it 'passes any provided arguments to the call to #exist?' do
|
99
|
+
object = mock
|
100
|
+
object.should_receive(:exist?).with(:foo, :bar) { true }
|
101
|
+
|
102
|
+
object.should exist(:foo, :bar)
|
103
|
+
end
|
65
104
|
end
|
@@ -142,13 +142,13 @@ describe "should_not include(with, multiple, args)" do
|
|
142
142
|
it "fails if the target includes all of the expected keys" do
|
143
143
|
expect {
|
144
144
|
{ :a => 1, :b => 2 }.should_not include(:a, :b)
|
145
|
-
}.to fail_matching(%Q|expected {:a=>1, :b=>2} not to include :a and :b|)
|
145
|
+
}.to fail_matching(%Q|expected #{{:a=>1, :b=>2}.inspect} not to include :a and :b|)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "fails if the target includes some (but not all) of the expected keys" do
|
149
149
|
expect {
|
150
150
|
{ :a => 1, :b => 2 }.should_not include(:d, :b)
|
151
|
-
}.to fail_matching(%Q|expected {:a=>1, :b=>2} not to include :d and :b|)
|
151
|
+
}.to fail_matching(%Q|expected #{{:a=>1, :b=>2}.inspect} not to include :d and :b|)
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -218,7 +218,7 @@ describe "should_not include(:key => value)" do
|
|
218
218
|
it "fails if target includes the key/value pair among others" do
|
219
219
|
lambda {
|
220
220
|
{:key => 'value', :other => 'different'}.should_not include(:key => 'value')
|
221
|
-
}.should fail_matching(%Q|expected {:key=>"value", :other=>"different"} not to include {:key=>"value"}|)
|
221
|
+
}.should fail_matching(%Q|expected #{{:key=>"value", :other=>"different"}.inspect} not to include {:key=>"value"}|)
|
222
222
|
end
|
223
223
|
|
224
224
|
it "passes if target has a different value for key" do
|
@@ -256,31 +256,25 @@ describe "should include(:key1 => value1, :key2 => value2)" do
|
|
256
256
|
it "fails if target has a different value for one of the keys" do
|
257
257
|
lambda {
|
258
258
|
{:a => 1, :b => 2}.should include(:a => 2, :b => 2)
|
259
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>2} to include {:a=>2, :b=>2}|)
|
259
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>2}.inspect} to include #{{:a=>2, :b=>2}.inspect}|)
|
260
260
|
end
|
261
261
|
|
262
262
|
it "fails if target has a different value for both of the keys" do
|
263
263
|
lambda {
|
264
264
|
{:a => 1, :b => 1}.should include(:a => 2, :b => 2)
|
265
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>1} to include {:a=>2, :b=>2}|)
|
265
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>1}.inspect} to include #{{:a=>2, :b=>2}.inspect}|)
|
266
266
|
end
|
267
267
|
|
268
268
|
it "fails if target lacks one of the keys" do
|
269
269
|
lambda {
|
270
270
|
{:a => 1, :b => 1}.should include(:a => 1, :c => 1)
|
271
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>1} to include {:a=>1, :c=>1}|)
|
271
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>1}.inspect} to include #{{:a=>1, :c=>1}.inspect}|)
|
272
272
|
end
|
273
273
|
|
274
274
|
it "fails if target lacks both of the keys" do
|
275
|
-
|
275
|
+
lambda {
|
276
276
|
{:a => 1, :b => 1}.should include(:c => 1, :d => 1)
|
277
|
-
|
278
|
-
ensure
|
279
|
-
e.message.should match(/expected \{:a=>1, :b=>1\} to include/)
|
280
|
-
e.message.match(/include (.*)$/) do |m|
|
281
|
-
eval(m[1]).should eq({:c=>1,:d=>1})
|
282
|
-
end
|
283
|
-
end
|
277
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>1}.inspect} to include #{{:c=>1, :d=>1}.inspect}|)
|
284
278
|
end
|
285
279
|
end
|
286
280
|
|
@@ -288,7 +282,7 @@ describe "should include(:key1 => value1, :key2 => value2)" do
|
|
288
282
|
it "fails if the target does not contain the given hash" do
|
289
283
|
lambda {
|
290
284
|
['a', 'b'].should include(:a => 1, :b => 1)
|
291
|
-
}.should fail_matching(%Q|expected ["a", "b"] to include {:a=>1, :b=>1}|)
|
285
|
+
}.should fail_matching(%Q|expected ["a", "b"] to include #{{:a=>1, :b=>1}.inspect}|)
|
292
286
|
end
|
293
287
|
|
294
288
|
it "passes if the target contains the given hash" do
|
@@ -302,20 +296,20 @@ describe "should_not include(:key1 => value1, :key2 => value2)" do
|
|
302
296
|
it "fails if target includes the key/value pairs" do
|
303
297
|
lambda {
|
304
298
|
{:a => 1, :b => 2}.should_not include(:a => 1, :b => 2)
|
305
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>2} not to include {:a=>1, :b=>2}|)
|
299
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>2}.inspect} not to include #{{:a=>1, :b=>2}.inspect}|)
|
306
300
|
end
|
307
301
|
|
308
302
|
it "fails if target includes the key/value pairs among others" do
|
309
303
|
hash = {:a => 1, :b => 2, :c => 3}
|
310
304
|
lambda {
|
311
305
|
hash.should_not include(:a => 1, :b => 2)
|
312
|
-
}.should fail_matching(%Q|expected #{hash.inspect} not to include {:a=>1, :b=>2}|)
|
306
|
+
}.should fail_matching(%Q|expected #{hash.inspect} not to include #{{:a=>1, :b=>2}.inspect}|)
|
313
307
|
end
|
314
308
|
|
315
309
|
it "fails if target has a different value for one of the keys" do
|
316
310
|
lambda {
|
317
311
|
{:a => 1, :b => 2}.should_not include(:a => 2, :b => 2)
|
318
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>2} not to include {:a=>2, :b=>2}|)
|
312
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>2}.inspect} not to include #{{:a=>2, :b=>2}.inspect}|)
|
319
313
|
end
|
320
314
|
|
321
315
|
it "passes if target has a different value for both of the keys" do
|
@@ -325,7 +319,7 @@ describe "should_not include(:key1 => value1, :key2 => value2)" do
|
|
325
319
|
it "fails if target lacks one of the keys" do
|
326
320
|
lambda {
|
327
321
|
{:a => 1, :b => 1}.should_not include(:a => 1, :c => 1)
|
328
|
-
}.should fail_matching(%Q|expected {:a=>1, :b=>1} not to include {:a=>1, :c=>1}|)
|
322
|
+
}.should fail_matching(%Q|expected #{{:a=>1, :b=>1}.inspect} not to include #{{:a=>1, :c=>1}.inspect}|)
|
329
323
|
end
|
330
324
|
|
331
325
|
it "passes if target lacks both of the keys" do
|
@@ -341,7 +335,7 @@ describe "should_not include(:key1 => value1, :key2 => value2)" do
|
|
341
335
|
it "fails if the target contains the given hash" do
|
342
336
|
lambda {
|
343
337
|
['a', { :a => 1, :b => 2 } ].should_not include(:a => 1, :b => 2)
|
344
|
-
}.should fail_matching(%Q|expected ["a", {:a=>1, :b=>2}] not to include {:a=>1, :b=>2}|)
|
338
|
+
}.should fail_matching(%Q|expected #{["a", {:a=>1, :b=>2}].inspect} not to include #{{:a=>1, :b=>2}.inspect}|)
|
345
339
|
end
|
346
340
|
end
|
347
341
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-expectations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 2
|
7
|
-
-
|
8
|
+
- 5
|
8
9
|
- 0
|
9
|
-
version: 2.
|
10
|
+
version: 2.5.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- David Chelimsky
|
@@ -15,22 +16,23 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2011-
|
19
|
+
date: 2011-02-05 00:00:00 -06:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: diff-lcs
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
28
29
|
segments:
|
29
30
|
- 1
|
30
31
|
- 1
|
31
32
|
- 2
|
32
33
|
version: 1.1.2
|
33
34
|
type: :runtime
|
35
|
+
name: diff-lcs
|
34
36
|
prerelease: false
|
35
37
|
version_requirements: *id001
|
36
38
|
description: rspec expectations (should[_not] and matchers)
|
@@ -46,14 +48,14 @@ files:
|
|
46
48
|
- .gitignore
|
47
49
|
- Gemfile
|
48
50
|
- Guardfile
|
49
|
-
- History.markdown
|
50
51
|
- License.txt
|
51
52
|
- README.md
|
52
53
|
- Rakefile
|
53
|
-
- Upgrade.markdown
|
54
54
|
- cucumber.yml
|
55
55
|
- features/.nav
|
56
|
+
- features/Changelog.md
|
56
57
|
- features/README.markdown
|
58
|
+
- features/Upgrade.md
|
57
59
|
- features/built_in_matchers/be.feature
|
58
60
|
- features/built_in_matchers/be_within.feature
|
59
61
|
- features/built_in_matchers/equality.feature
|
@@ -172,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
174
|
requirements:
|
173
175
|
- - ">="
|
174
176
|
- !ruby/object:Gem::Version
|
175
|
-
hash:
|
177
|
+
hash: 3
|
176
178
|
segments:
|
177
179
|
- 0
|
178
180
|
version: "0"
|
@@ -181,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
183
|
requirements:
|
182
184
|
- - ">="
|
183
185
|
- !ruby/object:Gem::Version
|
184
|
-
hash:
|
186
|
+
hash: 3
|
185
187
|
segments:
|
186
188
|
- 0
|
187
189
|
version: "0"
|
@@ -191,9 +193,11 @@ rubyforge_project: rspec
|
|
191
193
|
rubygems_version: 1.3.7
|
192
194
|
signing_key:
|
193
195
|
specification_version: 3
|
194
|
-
summary: rspec-expectations-2.
|
196
|
+
summary: rspec-expectations-2.5.0
|
195
197
|
test_files:
|
198
|
+
- features/Changelog.md
|
196
199
|
- features/README.markdown
|
200
|
+
- features/Upgrade.md
|
197
201
|
- features/built_in_matchers/be.feature
|
198
202
|
- features/built_in_matchers/be_within.feature
|
199
203
|
- features/built_in_matchers/equality.feature
|