rspec-expectations 2.0.0.beta.20 → 2.0.0.beta.22
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/Gemfile +7 -1
- data/History.md +16 -0
- data/Rakefile +3 -40
- data/features/expectations/diffing.feature +85 -0
- data/features/matchers/equality.feature +142 -0
- data/lib/rspec/expectations/differ.rb +4 -2
- data/lib/rspec/expectations/fail_with.rb +5 -1
- data/lib/rspec/expectations/version.rb +1 -1
- data/lib/rspec/matchers/be.rb +1 -28
- data/lib/rspec/matchers/change.rb +47 -18
- data/lib/rspec/matchers/eq.rb +3 -0
- data/lib/rspec/matchers/eql.rb +3 -0
- data/rspec-expectations.gemspec +23 -171
- data/spec/rspec/expectations/fail_with_spec.rb +46 -19
- data/spec/rspec/matchers/be_spec.rb +5 -15
- data/spec/rspec/matchers/change_spec.rb +96 -40
- data/spec/rspec/matchers/eq_spec.rb +4 -0
- data/spec/rspec/matchers/eql_spec.rb +4 -0
- data/spec/rspec/matchers/have_spec.rb +13 -20
- metadata +27 -11
- data/VERSION +0 -1
data/Gemfile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gem "rake"
|
4
|
-
gem "jeweler"
|
5
4
|
gem "cucumber"
|
6
5
|
gem "aruba", ">= 0.2.0"
|
7
6
|
gem "autotest"
|
@@ -10,3 +9,10 @@ gem "rspec-expectations", :path => "."
|
|
10
9
|
gem "rspec-core", :path => "../rspec-core"
|
11
10
|
gem "rspec-mocks", :path => "../rspec-mocks"
|
12
11
|
gem "watchr"
|
12
|
+
|
13
|
+
case RUBY_VERSION
|
14
|
+
when '1.9.2'
|
15
|
+
gem 'ruby-debug19'
|
16
|
+
when /^1\.8/
|
17
|
+
gem 'ruby-debug'
|
18
|
+
end
|
data/History.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## rspec-expectations release history (incomplete)
|
2
|
+
|
3
|
+
### 2.0.0.beta.22 / 2010-09-12
|
4
|
+
|
5
|
+
[full changelog](http://github.com/rspec/rspec-expectations/compare/v2.0.0.beta.20...v2.0.0.beta.22)
|
6
|
+
|
7
|
+
* Enhancements
|
8
|
+
* diffing improvements
|
9
|
+
* diff multiline strings
|
10
|
+
* don't diff single line strings
|
11
|
+
* don't diff numbers (silly)
|
12
|
+
* diff regexp + multiline string
|
13
|
+
|
14
|
+
* Bug fixes
|
15
|
+
* should[_not] change now handles boolean values correctly
|
16
|
+
|
data/Rakefile
CHANGED
@@ -1,41 +1,12 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler.setup
|
3
|
+
Bundler::GemHelper.install_tasks
|
3
4
|
|
4
|
-
$LOAD_PATH << File.expand_path("../lib", __FILE__)
|
5
5
|
require 'rake'
|
6
6
|
require 'rake/rdoctask'
|
7
|
-
require 'rspec/expectations/version'
|
8
7
|
require 'rspec/core/rake_task'
|
9
8
|
require 'cucumber/rake/task'
|
10
9
|
|
11
|
-
begin
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
gem.name = "rspec-expectations"
|
15
|
-
gem.version = RSpec::Expectations::Version::STRING
|
16
|
-
gem.summary = "rspec-expectations-#{RSpec::Expectations::Version::STRING}"
|
17
|
-
gem.description = "rspec expectations (should[_not] and matchers)"
|
18
|
-
gem.rubyforge_project = "rspec"
|
19
|
-
gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
|
20
|
-
gem.homepage = "http://github.com/rspec/expectations"
|
21
|
-
gem.authors = ["David Chelimsky", "Chad Humphries"]
|
22
|
-
gem.add_dependency('diff-lcs', ">= 1.1.2")
|
23
|
-
gem.add_development_dependency('cucumber', ">= 0.6.2")
|
24
|
-
gem.add_development_dependency('aruba', ">= 0.1.1")
|
25
|
-
gem.add_development_dependency('rspec-core', ">= #{RSpec::Expectations::Version::STRING}")
|
26
|
-
gem.add_development_dependency('rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}")
|
27
|
-
end
|
28
|
-
rescue LoadError
|
29
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
30
|
-
end
|
31
|
-
|
32
|
-
namespace :gem do
|
33
|
-
desc "push to gemcutter"
|
34
|
-
task :push => :build do
|
35
|
-
system "gem push pkg/rspec-expectations-#{RSpec::Expectations::Version::STRING}.gem"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
10
|
RSpec::Core::RakeTask.new(:spec)
|
40
11
|
|
41
12
|
class Cucumber::Rake::Task::ForkedCucumberRunner
|
@@ -50,18 +21,11 @@ Cucumber::Rake::Task.new do |t|
|
|
50
21
|
t.cucumber_opts = %w{--format progress}
|
51
22
|
end
|
52
23
|
|
53
|
-
task :default => [:
|
24
|
+
task :default => [:spec, :cucumber]
|
54
25
|
|
55
26
|
Rake::RDocTask.new do |rdoc|
|
56
|
-
if File.exist?('VERSION.yml')
|
57
|
-
config = YAML.load(File.read('VERSION.yml'))
|
58
|
-
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
59
|
-
else
|
60
|
-
version = ""
|
61
|
-
end
|
62
|
-
|
63
27
|
rdoc.rdoc_dir = 'rdoc'
|
64
|
-
rdoc.title = "rspec-expectations #{
|
28
|
+
rdoc.title = "rspec-expectations #{RSpec::Expectations::Version::STRING}"
|
65
29
|
rdoc.rdoc_files.include('README*')
|
66
30
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
67
31
|
end
|
@@ -73,4 +37,3 @@ task :clobber do
|
|
73
37
|
rm_rf 'coverage'
|
74
38
|
end
|
75
39
|
|
76
|
-
|
@@ -0,0 +1,85 @@
|
|
1
|
+
Feature: diffing
|
2
|
+
|
3
|
+
When appropriate, failure messages will automatically include a diff.
|
4
|
+
|
5
|
+
Scenario: diff for a multiline string
|
6
|
+
Given a file named "example_spec.rb" with:
|
7
|
+
"""
|
8
|
+
describe "a multiline string" do
|
9
|
+
it "is like another string" do
|
10
|
+
expected = <<-EXPECTED
|
11
|
+
this is the
|
12
|
+
expected
|
13
|
+
string
|
14
|
+
EXPECTED
|
15
|
+
actual = <<-ACTUAL
|
16
|
+
this is the
|
17
|
+
actual
|
18
|
+
string
|
19
|
+
ACTUAL
|
20
|
+
actual.should eq(expected)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
"""
|
24
|
+
When I run "rspec example_spec.rb"
|
25
|
+
Then the output should contain:
|
26
|
+
"""
|
27
|
+
Diff:
|
28
|
+
@@ -1,4 +1,4 @@
|
29
|
+
this is the
|
30
|
+
- expected
|
31
|
+
+ actual
|
32
|
+
string
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario: diff for a multiline string and a regexp
|
36
|
+
Given a file named "example_spec.rb" with:
|
37
|
+
"""
|
38
|
+
describe "a multiline string" do
|
39
|
+
it "is like another string" do
|
40
|
+
expected = /expected/m
|
41
|
+
actual = <<-ACTUAL
|
42
|
+
this is the
|
43
|
+
actual
|
44
|
+
string
|
45
|
+
ACTUAL
|
46
|
+
actual.should =~ expected
|
47
|
+
end
|
48
|
+
end
|
49
|
+
"""
|
50
|
+
When I run "rspec example_spec.rb"
|
51
|
+
Then the output should contain:
|
52
|
+
"""
|
53
|
+
Diff:
|
54
|
+
@@ -1,2 +1,4 @@
|
55
|
+
-/expected/m
|
56
|
+
+this is the
|
57
|
+
+ actual
|
58
|
+
+ string
|
59
|
+
"""
|
60
|
+
|
61
|
+
Scenario: no diff for a single line strings
|
62
|
+
Given a file named "example_spec.rb" with:
|
63
|
+
"""
|
64
|
+
describe "a single line string" do
|
65
|
+
it "is like another string" do
|
66
|
+
expected = "this string"
|
67
|
+
actual = "that string"
|
68
|
+
actual.should eq(expected)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
"""
|
72
|
+
When I run "rspec example_spec.rb"
|
73
|
+
Then the output should not contain "Diff:"
|
74
|
+
|
75
|
+
Scenario: no diff for numbers
|
76
|
+
Given a file named "example_spec.rb" with:
|
77
|
+
"""
|
78
|
+
describe "a number" do
|
79
|
+
it "is like another number" do
|
80
|
+
1.should eq(2)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
"""
|
84
|
+
When I run "rspec example_spec.rb"
|
85
|
+
Then the output should not contain "Diff:"
|
@@ -0,0 +1,142 @@
|
|
1
|
+
Feature: equality matchers
|
2
|
+
|
3
|
+
Ruby exposes several different methods for handling equality:
|
4
|
+
|
5
|
+
a.equal?(b) # object identity - a and b refer to the same object
|
6
|
+
a.eql?(b) # object equivalence - a and b have the same value
|
7
|
+
a == b # object equivalence - a and b have the same value with type conversions
|
8
|
+
|
9
|
+
Note that these descriptions are guidelines but are not forced by the
|
10
|
+
language. Any object can implement any of these methods with its own
|
11
|
+
semantics.
|
12
|
+
|
13
|
+
rspec-expectations ships with matchers that align with each of these methods:
|
14
|
+
|
15
|
+
a.should equal(b) # passes if a.equal?(b)
|
16
|
+
a.should eql(b) # passes if a.eql?(b)
|
17
|
+
a.should == b # passes if a == b
|
18
|
+
|
19
|
+
It also ships with two matchers that have more of a DSL feel to them:
|
20
|
+
|
21
|
+
a.should be(b) # passes if a.equal?(b)
|
22
|
+
a.should eq(b) # passes if a == b
|
23
|
+
|
24
|
+
Scenario: compare using eq (==)
|
25
|
+
Given a file named "compare_using_eq.rb" with:
|
26
|
+
"""
|
27
|
+
require 'spec_helper'
|
28
|
+
|
29
|
+
describe "a string" do
|
30
|
+
it "is equal to another string of the same value" do
|
31
|
+
"this string".should eq("this string")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "is not equal to another string of a different value" do
|
35
|
+
"this string".should_not eq("a different string")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "an integer" do
|
40
|
+
it "is equal to a float of the same value" do
|
41
|
+
5.should eq(5.0)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
"""
|
45
|
+
When I run "rspec compare_using_eq.rb"
|
46
|
+
Then the output should contain "3 examples, 0 failures"
|
47
|
+
|
48
|
+
Scenario: compare using ==
|
49
|
+
Given a file named "compare_using_==.rb" with:
|
50
|
+
"""
|
51
|
+
require 'spec_helper'
|
52
|
+
|
53
|
+
describe "a string" do
|
54
|
+
it "is equal to another string of the same value" do
|
55
|
+
"this string".should == "this string"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "is not equal to another string of a different value" do
|
59
|
+
"this string".should_not == "a different string"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "an integer" do
|
64
|
+
it "is equal to a float of the same value" do
|
65
|
+
5.should == 5.0
|
66
|
+
end
|
67
|
+
end
|
68
|
+
"""
|
69
|
+
When I run "rspec compare_using_==.rb"
|
70
|
+
Then the output should contain "3 examples, 0 failures"
|
71
|
+
|
72
|
+
Scenario: compare using eql (eql?)
|
73
|
+
Given a file named "compare_using_eql.rb" with:
|
74
|
+
"""
|
75
|
+
require 'spec_helper'
|
76
|
+
|
77
|
+
describe "an integer" do
|
78
|
+
it "is equal to another integer of the same value" do
|
79
|
+
5.should eql(5)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "is not equal to another integer of a different value" do
|
83
|
+
5.should_not eql(6)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "is not equal to a float of the same value" do
|
87
|
+
5.should_not eql(5.0)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
"""
|
92
|
+
When I run "rspec compare_using_eql.rb"
|
93
|
+
Then the output should contain "3 examples, 0 failures"
|
94
|
+
|
95
|
+
Scenario: compare using equal (equal?)
|
96
|
+
Given a file named "compare_using_equal.rb" with:
|
97
|
+
"""
|
98
|
+
require 'spec_helper'
|
99
|
+
|
100
|
+
describe "a string" do
|
101
|
+
it "is equal to itself" do
|
102
|
+
string = "this string"
|
103
|
+
string.should equal(string)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "is not equal to another string of the same value" do
|
107
|
+
"this string".should_not equal("this string")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "is not equal to another string of a different value" do
|
111
|
+
"this string".should_not equal("a different string")
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
"""
|
116
|
+
When I run "rspec compare_using_equal.rb"
|
117
|
+
Then the output should contain "3 examples, 0 failures"
|
118
|
+
|
119
|
+
Scenario: compare using be (equal?)
|
120
|
+
Given a file named "compare_using_be.rb" with:
|
121
|
+
"""
|
122
|
+
require 'spec_helper'
|
123
|
+
|
124
|
+
describe "a string" do
|
125
|
+
it "is equal to itself" do
|
126
|
+
string = "this string"
|
127
|
+
string.should be(string)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "is not equal to another string of the same value" do
|
131
|
+
"this string".should_not be("this string")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "is not equal to another string of a different value" do
|
135
|
+
"this string".should_not be("a different string")
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
"""
|
140
|
+
When I run "rspec compare_using_be.rb"
|
141
|
+
Then the output should contain "3 examples, 0 failures"
|
142
|
+
|
@@ -41,8 +41,10 @@ module RSpec
|
|
41
41
|
output << oldhunk.diff(format) << "\n"
|
42
42
|
end
|
43
43
|
|
44
|
-
def diff_as_object(
|
45
|
-
|
44
|
+
def diff_as_object(actual,expected)
|
45
|
+
actual = String === actual ? actual : PP.pp(actual,"")
|
46
|
+
expected = String === expected ? expected : PP.pp(expected,"")
|
47
|
+
diff_as_string(actual, expected)
|
46
48
|
end
|
47
49
|
|
48
50
|
protected
|
@@ -21,7 +21,7 @@ module RSpec
|
|
21
21
|
if any_multiline_strings?(actual, expected)
|
22
22
|
message << "\nDiff:" << self.differ.diff_as_string(actual, expected)
|
23
23
|
end
|
24
|
-
elsif no_procs?(actual, expected)
|
24
|
+
elsif no_procs?(actual, expected) && no_numbers?(actual, expected)
|
25
25
|
message << "\nDiff:" << self.differ.diff_as_object(actual, expected)
|
26
26
|
end
|
27
27
|
end
|
@@ -42,6 +42,10 @@ module RSpec
|
|
42
42
|
def any_multiline_strings?(*args)
|
43
43
|
all_strings?(*args) && args.any? {|a| a =~ /\n/}
|
44
44
|
end
|
45
|
+
|
46
|
+
def no_numbers?(*args)
|
47
|
+
args.none? {|a| Numeric === a}
|
48
|
+
end
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
data/lib/rspec/matchers/be.rb
CHANGED
@@ -177,32 +177,6 @@ it is a bit confusing.
|
|
177
177
|
|
178
178
|
end
|
179
179
|
|
180
|
-
class BeSameAs < Be
|
181
|
-
|
182
|
-
def initialize(*args, &block)
|
183
|
-
@expected = args.shift
|
184
|
-
@args = args
|
185
|
-
end
|
186
|
-
|
187
|
-
def matches?(actual)
|
188
|
-
@actual = actual
|
189
|
-
@actual.equal?(@expected)
|
190
|
-
end
|
191
|
-
|
192
|
-
def failure_message_for_should
|
193
|
-
"expected #{@expected}, got #{@actual.inspect}"
|
194
|
-
end
|
195
|
-
|
196
|
-
def failure_message_for_should_not
|
197
|
-
"expected not #{@expected}, got #{@actual.inspect}"
|
198
|
-
end
|
199
|
-
|
200
|
-
def description
|
201
|
-
"be #{expected_to_sentence}#{args_to_sentence}"
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
180
|
# :call-seq:
|
207
181
|
# should be_true
|
208
182
|
# should be_false
|
@@ -235,8 +209,7 @@ it is a bit confusing.
|
|
235
209
|
# target.should_not be_old_enough(16) #passes unless target.old_enough?(16)
|
236
210
|
def be(*args)
|
237
211
|
args.empty? ?
|
238
|
-
Matchers::Be.new :
|
239
|
-
Matchers::BeSameAs.new(*args)
|
212
|
+
Matchers::Be.new : equal(*args)
|
240
213
|
end
|
241
214
|
|
242
215
|
# passes if target.kind_of?(klass)
|
@@ -4,9 +4,10 @@ module RSpec
|
|
4
4
|
#Based on patch from Wilson Bilkovich
|
5
5
|
class Change #:nodoc:
|
6
6
|
def initialize(receiver=nil, message=nil, &block)
|
7
|
-
@message = message
|
7
|
+
@message = message
|
8
8
|
@value_proc = block || lambda {receiver.__send__(message)}
|
9
9
|
@to = @from = @minimum = @maximum = @amount = nil
|
10
|
+
@given_from = @given_to = false
|
10
11
|
end
|
11
12
|
|
12
13
|
def matches?(event_proc)
|
@@ -16,14 +17,9 @@ module RSpec
|
|
16
17
|
event_proc.call
|
17
18
|
@after = evaluate_value_proc
|
18
19
|
|
19
|
-
|
20
|
-
return false if @to unless @to == @after
|
21
|
-
return (@before + @amount == @after) if @amount
|
22
|
-
return ((@after - @before) >= @minimum) if @minimum
|
23
|
-
return ((@after - @before) <= @maximum) if @maximum
|
24
|
-
return @before != @after
|
20
|
+
changed? && matches_before? && matches_after? && matches_amount? && matches_min? && matches_max?
|
25
21
|
end
|
26
|
-
|
22
|
+
|
27
23
|
def raise_block_syntax_error
|
28
24
|
raise MatcherError.new(<<-MESSAGE
|
29
25
|
block passed to should or should_not change must use {} instead of do/end
|
@@ -36,18 +32,18 @@ MESSAGE
|
|
36
32
|
end
|
37
33
|
|
38
34
|
def failure_message_for_should
|
39
|
-
if @
|
40
|
-
"#{
|
41
|
-
elsif @
|
42
|
-
"#{
|
35
|
+
if @given_from && @before != @from
|
36
|
+
"#{message} should have initially been #{@from.inspect}, but was #{@before.inspect}"
|
37
|
+
elsif @given_to && @to != @after
|
38
|
+
"#{message} should have been changed to #{@to.inspect}, but is now #{@after.inspect}"
|
43
39
|
elsif @amount
|
44
|
-
"#{
|
40
|
+
"#{message} should have been changed by #{@amount.inspect}, but was changed by #{actual_delta.inspect}"
|
45
41
|
elsif @minimum
|
46
|
-
"#{
|
42
|
+
"#{message} should have been changed by at least #{@minimum.inspect}, but was changed by #{actual_delta.inspect}"
|
47
43
|
elsif @maximum
|
48
|
-
"#{
|
44
|
+
"#{message} should have been changed by at most #{@maximum.inspect}, but was changed by #{actual_delta.inspect}"
|
49
45
|
else
|
50
|
-
"#{
|
46
|
+
"#{message} should have changed, but is still #{@before.inspect}"
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
@@ -56,7 +52,7 @@ MESSAGE
|
|
56
52
|
end
|
57
53
|
|
58
54
|
def failure_message_for_should_not
|
59
|
-
"#{
|
55
|
+
"#{message} should not have changed, but did change from #{@before.inspect} to #{@after.inspect}"
|
60
56
|
end
|
61
57
|
|
62
58
|
def by(amount)
|
@@ -75,18 +71,51 @@ MESSAGE
|
|
75
71
|
end
|
76
72
|
|
77
73
|
def to(to)
|
74
|
+
@given_to = true
|
78
75
|
@to = to
|
79
76
|
self
|
80
77
|
end
|
81
78
|
|
82
79
|
def from (from)
|
80
|
+
@given_from = true
|
83
81
|
@from = from
|
84
82
|
self
|
85
83
|
end
|
86
84
|
|
87
85
|
def description
|
88
|
-
"change ##{
|
86
|
+
"change ##{message}"
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def message
|
92
|
+
@message || "result"
|
93
|
+
end
|
94
|
+
|
95
|
+
def changed?
|
96
|
+
@before != @after
|
97
|
+
end
|
98
|
+
|
99
|
+
def matches_before?
|
100
|
+
@given_from ? @from == @before : true
|
89
101
|
end
|
102
|
+
|
103
|
+
def matches_after?
|
104
|
+
@given_to ? @to == @after : true
|
105
|
+
end
|
106
|
+
|
107
|
+
def matches_amount?
|
108
|
+
@amount ? (@before + @amount == @after) : true
|
109
|
+
end
|
110
|
+
|
111
|
+
def matches_min?
|
112
|
+
@minimum ? (@after - @before >= @minimum) : true
|
113
|
+
end
|
114
|
+
|
115
|
+
def matches_max?
|
116
|
+
@maximum ? (@after - @before <= @maximum) : true
|
117
|
+
end
|
118
|
+
|
90
119
|
end
|
91
120
|
|
92
121
|
# :call-seq:
|
data/lib/rspec/matchers/eq.rb
CHANGED
data/lib/rspec/matchers/eql.rb
CHANGED
data/rspec-expectations.gemspec
CHANGED
@@ -1,179 +1,31 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require "rspec/expectations/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "rspec-expectations"
|
7
|
+
s.version = RSpec::Expectations::Version::STRING
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["David Chelimsky", "Chad Humphries"]
|
10
|
+
s.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
|
11
|
+
s.homepage = "http://github.com/rspec/rspec-expectations"
|
12
|
+
s.summary = "rspec-expectations-#{RSpec::Expectations::Version::STRING}"
|
13
|
+
s.description = "rspec expectations (should[_not] and matchers)"
|
9
14
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.date = %q{2010-08-24}
|
13
|
-
s.description = %q{rspec expectations (should[_not] and matchers)}
|
14
|
-
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"README.markdown"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".document",
|
20
|
-
".gitignore",
|
21
|
-
"Gemfile",
|
22
|
-
"License.txt",
|
23
|
-
"README.markdown",
|
24
|
-
"Rakefile",
|
25
|
-
"Upgrade.markdown",
|
26
|
-
"VERSION",
|
27
|
-
"cucumber.yml",
|
28
|
-
"features/README.markdown",
|
29
|
-
"features/expectations/attribute_of_subject.feature",
|
30
|
-
"features/expectations/customized_message.feature",
|
31
|
-
"features/expectations/implicit_docstrings.feature",
|
32
|
-
"features/matchers/access_running_example.feature",
|
33
|
-
"features/matchers/define_diffable_matcher.feature",
|
34
|
-
"features/matchers/define_matcher.feature",
|
35
|
-
"features/matchers/define_matcher_outside_rspec.feature",
|
36
|
-
"features/matchers/define_matcher_with_fluent_interface.feature",
|
37
|
-
"features/matchers/expect_change.feature",
|
38
|
-
"features/matchers/expect_error.feature",
|
39
|
-
"features/support/env.rb",
|
40
|
-
"lib/rspec-expectations.rb",
|
41
|
-
"lib/rspec/expectations.rb",
|
42
|
-
"lib/rspec/expectations/backward_compatibility.rb",
|
43
|
-
"lib/rspec/expectations/differ.rb",
|
44
|
-
"lib/rspec/expectations/errors.rb",
|
45
|
-
"lib/rspec/expectations/extensions.rb",
|
46
|
-
"lib/rspec/expectations/extensions/array.rb",
|
47
|
-
"lib/rspec/expectations/extensions/kernel.rb",
|
48
|
-
"lib/rspec/expectations/extensions/rspec/core/example_group.rb",
|
49
|
-
"lib/rspec/expectations/fail_with.rb",
|
50
|
-
"lib/rspec/expectations/handler.rb",
|
51
|
-
"lib/rspec/expectations/version.rb",
|
52
|
-
"lib/rspec/matchers.rb",
|
53
|
-
"lib/rspec/matchers/be.rb",
|
54
|
-
"lib/rspec/matchers/be_close.rb",
|
55
|
-
"lib/rspec/matchers/be_instance_of.rb",
|
56
|
-
"lib/rspec/matchers/be_kind_of.rb",
|
57
|
-
"lib/rspec/matchers/change.rb",
|
58
|
-
"lib/rspec/matchers/compatibility.rb",
|
59
|
-
"lib/rspec/matchers/dsl.rb",
|
60
|
-
"lib/rspec/matchers/eq.rb",
|
61
|
-
"lib/rspec/matchers/eql.rb",
|
62
|
-
"lib/rspec/matchers/equal.rb",
|
63
|
-
"lib/rspec/matchers/errors.rb",
|
64
|
-
"lib/rspec/matchers/exist.rb",
|
65
|
-
"lib/rspec/matchers/extensions/instance_exec.rb",
|
66
|
-
"lib/rspec/matchers/generated_descriptions.rb",
|
67
|
-
"lib/rspec/matchers/has.rb",
|
68
|
-
"lib/rspec/matchers/have.rb",
|
69
|
-
"lib/rspec/matchers/include.rb",
|
70
|
-
"lib/rspec/matchers/match.rb",
|
71
|
-
"lib/rspec/matchers/match_array.rb",
|
72
|
-
"lib/rspec/matchers/matcher.rb",
|
73
|
-
"lib/rspec/matchers/method_missing.rb",
|
74
|
-
"lib/rspec/matchers/operator_matcher.rb",
|
75
|
-
"lib/rspec/matchers/pretty.rb",
|
76
|
-
"lib/rspec/matchers/raise_error.rb",
|
77
|
-
"lib/rspec/matchers/respond_to.rb",
|
78
|
-
"lib/rspec/matchers/satisfy.rb",
|
79
|
-
"lib/rspec/matchers/throw_symbol.rb",
|
80
|
-
"rspec-expectations.gemspec",
|
81
|
-
"spec/rspec/expectations/differ_spec.rb",
|
82
|
-
"spec/rspec/expectations/extensions/kernel_spec.rb",
|
83
|
-
"spec/rspec/expectations/fail_with_spec.rb",
|
84
|
-
"spec/rspec/expectations/handler_spec.rb",
|
85
|
-
"spec/rspec/matchers/be_close_spec.rb",
|
86
|
-
"spec/rspec/matchers/be_instance_of_spec.rb",
|
87
|
-
"spec/rspec/matchers/be_kind_of_spec.rb",
|
88
|
-
"spec/rspec/matchers/be_spec.rb",
|
89
|
-
"spec/rspec/matchers/change_spec.rb",
|
90
|
-
"spec/rspec/matchers/compatibility_spec.rb",
|
91
|
-
"spec/rspec/matchers/description_generation_spec.rb",
|
92
|
-
"spec/rspec/matchers/dsl_spec.rb",
|
93
|
-
"spec/rspec/matchers/eq_spec.rb",
|
94
|
-
"spec/rspec/matchers/eql_spec.rb",
|
95
|
-
"spec/rspec/matchers/equal_spec.rb",
|
96
|
-
"spec/rspec/matchers/exist_spec.rb",
|
97
|
-
"spec/rspec/matchers/has_spec.rb",
|
98
|
-
"spec/rspec/matchers/have_spec.rb",
|
99
|
-
"spec/rspec/matchers/include_spec.rb",
|
100
|
-
"spec/rspec/matchers/match_array_spec.rb",
|
101
|
-
"spec/rspec/matchers/match_spec.rb",
|
102
|
-
"spec/rspec/matchers/matcher_spec.rb",
|
103
|
-
"spec/rspec/matchers/matchers_spec.rb",
|
104
|
-
"spec/rspec/matchers/operator_matcher_spec.rb",
|
105
|
-
"spec/rspec/matchers/raise_error_spec.rb",
|
106
|
-
"spec/rspec/matchers/respond_to_spec.rb",
|
107
|
-
"spec/rspec/matchers/satisfy_spec.rb",
|
108
|
-
"spec/rspec/matchers/throw_symbol_spec.rb",
|
109
|
-
"spec/spec_helper.rb",
|
110
|
-
"spec/suite.rb",
|
111
|
-
"spec/support/classes.rb",
|
112
|
-
"specs.watchr"
|
113
|
-
]
|
114
|
-
s.homepage = %q{http://github.com/rspec/expectations}
|
115
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
116
|
-
s.require_paths = ["lib"]
|
117
|
-
s.rubyforge_project = %q{rspec}
|
118
|
-
s.rubygems_version = %q{1.3.7}
|
119
|
-
s.summary = %q{rspec-expectations-2.0.0.beta.20}
|
120
|
-
s.test_files = [
|
121
|
-
"spec/rspec/expectations/differ_spec.rb",
|
122
|
-
"spec/rspec/expectations/extensions/kernel_spec.rb",
|
123
|
-
"spec/rspec/expectations/fail_with_spec.rb",
|
124
|
-
"spec/rspec/expectations/handler_spec.rb",
|
125
|
-
"spec/rspec/matchers/be_close_spec.rb",
|
126
|
-
"spec/rspec/matchers/be_instance_of_spec.rb",
|
127
|
-
"spec/rspec/matchers/be_kind_of_spec.rb",
|
128
|
-
"spec/rspec/matchers/be_spec.rb",
|
129
|
-
"spec/rspec/matchers/change_spec.rb",
|
130
|
-
"spec/rspec/matchers/compatibility_spec.rb",
|
131
|
-
"spec/rspec/matchers/description_generation_spec.rb",
|
132
|
-
"spec/rspec/matchers/dsl_spec.rb",
|
133
|
-
"spec/rspec/matchers/eq_spec.rb",
|
134
|
-
"spec/rspec/matchers/eql_spec.rb",
|
135
|
-
"spec/rspec/matchers/equal_spec.rb",
|
136
|
-
"spec/rspec/matchers/exist_spec.rb",
|
137
|
-
"spec/rspec/matchers/has_spec.rb",
|
138
|
-
"spec/rspec/matchers/have_spec.rb",
|
139
|
-
"spec/rspec/matchers/include_spec.rb",
|
140
|
-
"spec/rspec/matchers/match_array_spec.rb",
|
141
|
-
"spec/rspec/matchers/match_spec.rb",
|
142
|
-
"spec/rspec/matchers/matcher_spec.rb",
|
143
|
-
"spec/rspec/matchers/matchers_spec.rb",
|
144
|
-
"spec/rspec/matchers/operator_matcher_spec.rb",
|
145
|
-
"spec/rspec/matchers/raise_error_spec.rb",
|
146
|
-
"spec/rspec/matchers/respond_to_spec.rb",
|
147
|
-
"spec/rspec/matchers/satisfy_spec.rb",
|
148
|
-
"spec/rspec/matchers/throw_symbol_spec.rb",
|
149
|
-
"spec/spec_helper.rb",
|
150
|
-
"spec/suite.rb",
|
151
|
-
"spec/support/classes.rb"
|
152
|
-
]
|
15
|
+
s.rubygems_version = "1.3.7"
|
16
|
+
s.rubyforge_project = "rspec"
|
153
17
|
|
154
|
-
|
155
|
-
|
156
|
-
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.extra_rdoc_files = [ "README.markdown" ]
|
22
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
23
|
+
s.require_path = "lib"
|
157
24
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
164
|
-
else
|
165
|
-
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
166
|
-
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
167
|
-
s.add_dependency(%q<aruba>, [">= 0.1.1"])
|
168
|
-
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.20"])
|
169
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
170
|
-
end
|
171
|
-
else
|
172
|
-
s.add_dependency(%q<diff-lcs>, [">= 1.1.2"])
|
173
|
-
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
174
|
-
s.add_dependency(%q<aruba>, [">= 0.1.1"])
|
175
|
-
s.add_dependency(%q<rspec-core>, [">= 2.0.0.beta.20"])
|
176
|
-
s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.20"])
|
177
|
-
end
|
25
|
+
s.add_runtime_dependency 'diff-lcs', '>= 1.1.2'
|
26
|
+
s.add_development_dependency 'cucumber', ">= 0.6.2"
|
27
|
+
s.add_development_dependency 'aruba', ">= 0.1.1"
|
28
|
+
s.add_development_dependency 'rspec-core', ">= #{RSpec::Expectations::Version::STRING}"
|
29
|
+
s.add_development_dependency 'rspec-mocks', ">= #{RSpec::Expectations::Version::STRING}"
|
178
30
|
end
|
179
31
|
|
@@ -6,35 +6,62 @@ describe RSpec::Expectations, "#fail_with with diff" do
|
|
6
6
|
before(:each) do
|
7
7
|
RSpec::Expectations.stub(:differ) { differ }
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
|
+
it "calls differ if expected/actual are not strings (or numbers or procs)" do
|
11
|
+
differ.should_receive(:diff_as_object).and_return("diff")
|
12
|
+
lambda {
|
13
|
+
RSpec::Expectations.fail_with "the message", Object.new, Object.new
|
14
|
+
}.should fail_with("the message\nDiff:diff")
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with two strings" do
|
18
|
+
context "and actual is multiline" do
|
19
|
+
it "calls differ" do
|
20
|
+
differ.should_receive(:diff_as_string).and_return("diff")
|
21
|
+
lambda {
|
22
|
+
RSpec::Expectations.fail_with "the message", "expected\nthis", "actual"
|
23
|
+
}.should fail_with("the message\nDiff:diff")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "and expected is multiline" do
|
28
|
+
it "calls differ" do
|
29
|
+
differ.should_receive(:diff_as_string).and_return("diff")
|
30
|
+
lambda {
|
31
|
+
RSpec::Expectations.fail_with "the message", "expected", "actual\nthat"
|
32
|
+
}.should fail_with("the message\nDiff:diff")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "and both are single line strings" do
|
37
|
+
it "does not call differ" do
|
38
|
+
differ.should_not_receive(:diff_as_string)
|
39
|
+
lambda {
|
40
|
+
RSpec::Expectations.fail_with("the message", "expected", "actual")
|
41
|
+
}.should fail_with("the message")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
10
46
|
it "does not call differ if no expected/actual" do
|
11
47
|
lambda {
|
12
48
|
RSpec::Expectations.fail_with "the message"
|
13
49
|
}.should fail_with("the message")
|
14
50
|
end
|
15
|
-
|
16
|
-
it "
|
17
|
-
differ.should_receive(:diff_as_string).and_return("diff")
|
51
|
+
|
52
|
+
it "does not call differ expected is Numeric" do
|
18
53
|
lambda {
|
19
|
-
RSpec::Expectations.fail_with "the message",
|
20
|
-
}.should fail_with("the message
|
21
|
-
end
|
22
|
-
|
23
|
-
it "does not call differ if expected/actual are single line strings" do
|
24
|
-
differ.should_not_receive(:diff_as_string)
|
25
|
-
RSpec::Expectations.fail_with("the message", "expected", "actual") rescue nil
|
54
|
+
RSpec::Expectations.fail_with "the message", 1, "1"
|
55
|
+
}.should fail_with("the message")
|
26
56
|
end
|
27
|
-
|
28
|
-
it "
|
29
|
-
differ.should_receive(:diff_as_object).and_return("diff")
|
57
|
+
|
58
|
+
it "does not call differ when actual is Numeric" do
|
30
59
|
lambda {
|
31
|
-
RSpec::Expectations.fail_with "the message",
|
32
|
-
}.should fail_with("the message
|
60
|
+
RSpec::Expectations.fail_with "the message", "1", 1
|
61
|
+
}.should fail_with("the message")
|
33
62
|
end
|
34
|
-
|
63
|
+
|
35
64
|
it "does not call differ if expected or actual are procs" do
|
36
|
-
differ.should_not_receive(:diff_as_string)
|
37
|
-
differ.should_not_receive(:diff_as_object)
|
38
65
|
lambda {
|
39
66
|
RSpec::Expectations.fail_with "the message", lambda {}, lambda {}
|
40
67
|
}.should fail_with("the message")
|
@@ -386,25 +386,16 @@ describe "should_not be" do
|
|
386
386
|
end
|
387
387
|
|
388
388
|
describe "should be(value)" do
|
389
|
-
it "
|
389
|
+
it "delegates to equal" do
|
390
|
+
self.should_receive(:equal).with(5)
|
390
391
|
5.should be(5)
|
391
392
|
end
|
392
|
-
|
393
|
-
it "fails if !actual.equal?(value)" do
|
394
|
-
lambda { 5.should be(6) }.should fail_with("expected 6, got 5")
|
395
|
-
end
|
396
|
-
|
397
|
-
it "describes itself" do
|
398
|
-
be(5).description.should == "be 5"
|
399
|
-
end
|
400
393
|
end
|
401
394
|
|
402
395
|
describe "should_not be(value)" do
|
403
|
-
it "
|
404
|
-
|
405
|
-
|
406
|
-
it "fails if !actual.equal?(value)" do
|
407
|
-
lambda { 5.should_not be(5) }.should fail_with("expected not 5, got 5")
|
396
|
+
it "delegates to equal" do
|
397
|
+
self.should_receive(:equal).with(4)
|
398
|
+
5.should_not be(4)
|
408
399
|
end
|
409
400
|
end
|
410
401
|
|
@@ -420,7 +411,6 @@ end
|
|
420
411
|
|
421
412
|
describe "arbitrary predicate with DelegateClass" do
|
422
413
|
it "accesses methods defined in the delegating class (LH[#48])" do
|
423
|
-
pending("this fails in 1.9.2-preview3") unless RUBY_VERSION.to_s =~ /^1.8/
|
424
414
|
require 'delegate'
|
425
415
|
class ArrayDelegate < DelegateClass(Array)
|
426
416
|
def initialize(array)
|
@@ -1,28 +1,48 @@
|
|
1
1
|
#Based on patch from Wilson Bilkovich
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
|
4
5
|
class SomethingExpected
|
5
6
|
attr_accessor :some_value
|
6
7
|
end
|
7
8
|
|
8
9
|
describe "should change(actual, message)" do
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
context "with a numeric value" do
|
11
|
+
before(:each) do
|
12
|
+
@instance = SomethingExpected.new
|
13
|
+
@instance.some_value = 5
|
14
|
+
end
|
15
|
+
|
16
|
+
it "passes when actual is modified by the block" do
|
17
|
+
expect {@instance.some_value = 6}.to change(@instance, :some_value)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "fails when actual is not modified by the block" do
|
21
|
+
expect do
|
22
|
+
expect {}.to change(@instance, :some_value)
|
23
|
+
end.to fail_with("some_value should have changed, but is still 5")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "provides a #description" do
|
27
|
+
change(@instance, :some_value).description.should == "change #some_value"
|
28
|
+
end
|
12
29
|
end
|
13
30
|
|
14
|
-
|
15
|
-
|
16
|
-
|
31
|
+
context "with boolean values" do
|
32
|
+
before(:each) do
|
33
|
+
@instance = SomethingExpected.new
|
34
|
+
@instance.some_value = true
|
35
|
+
end
|
17
36
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
37
|
+
it "passes when actual is modified by the block" do
|
38
|
+
expect {@instance.some_value = false}.to change(@instance, :some_value)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "fails when actual is not modified by the block" do
|
42
|
+
expect do
|
43
|
+
expect {}.to change(@instance, :some_value)
|
44
|
+
end.to fail_with("some_value should have changed, but is still true")
|
45
|
+
end
|
26
46
|
end
|
27
47
|
end
|
28
48
|
|
@@ -227,19 +247,37 @@ describe "should change{ block }.by_at_most(expected)" do
|
|
227
247
|
end
|
228
248
|
|
229
249
|
describe "should change(actual, message).from(old)" do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
expect
|
242
|
-
|
250
|
+
context "with boolean values" do
|
251
|
+
before(:each) do
|
252
|
+
@instance = SomethingExpected.new
|
253
|
+
@instance.some_value = true
|
254
|
+
end
|
255
|
+
|
256
|
+
it "passes when attribute is == to expected value before executing block" do
|
257
|
+
expect { @instance.some_value = false }.to change(@instance, :some_value).from(true)
|
258
|
+
end
|
259
|
+
|
260
|
+
it "fails when attribute is not == to expected value before executing block" do
|
261
|
+
expect do
|
262
|
+
expect { @instance.some_value = 'foo' }.to change(@instance, :some_value).from(false)
|
263
|
+
end.to fail_with("some_value should have initially been false, but was true")
|
264
|
+
end
|
265
|
+
end
|
266
|
+
context "with non-boolean values" do
|
267
|
+
before(:each) do
|
268
|
+
@instance = SomethingExpected.new
|
269
|
+
@instance.some_value = 'string'
|
270
|
+
end
|
271
|
+
|
272
|
+
it "passes when attribute is == to expected value before executing block" do
|
273
|
+
expect { @instance.some_value = "astring" }.to change(@instance, :some_value).from("string")
|
274
|
+
end
|
275
|
+
|
276
|
+
it "fails when attribute is not == to expected value before executing block" do
|
277
|
+
expect do
|
278
|
+
expect { @instance.some_value = "knot" }.to change(@instance, :some_value).from("cat")
|
279
|
+
end.to fail_with("some_value should have initially been \"cat\", but was \"string\"")
|
280
|
+
end
|
243
281
|
end
|
244
282
|
end
|
245
283
|
|
@@ -261,19 +299,37 @@ describe "should change{ block }.from(old)" do
|
|
261
299
|
end
|
262
300
|
|
263
301
|
describe "should change(actual, message).to(new)" do
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
expect
|
276
|
-
|
302
|
+
context "with boolean values" do
|
303
|
+
before(:each) do
|
304
|
+
@instance = SomethingExpected.new
|
305
|
+
@instance.some_value = true
|
306
|
+
end
|
307
|
+
|
308
|
+
it "passes when attribute is == to expected value after executing block" do
|
309
|
+
expect { @instance.some_value = false }.to change(@instance, :some_value).to(false)
|
310
|
+
end
|
311
|
+
|
312
|
+
it "fails when attribute is not == to expected value after executing block" do
|
313
|
+
expect do
|
314
|
+
expect { @instance.some_value = 1 }.to change(@instance, :some_value).from(true).to(false)
|
315
|
+
end.to fail_with("some_value should have been changed to false, but is now 1")
|
316
|
+
end
|
317
|
+
end
|
318
|
+
context "with non-boolean values" do
|
319
|
+
before(:each) do
|
320
|
+
@instance = SomethingExpected.new
|
321
|
+
@instance.some_value = 'string'
|
322
|
+
end
|
323
|
+
|
324
|
+
it "passes when attribute is == to expected value after executing block" do
|
325
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat")
|
326
|
+
end
|
327
|
+
|
328
|
+
it "fails when attribute is not == to expected value after executing block" do
|
329
|
+
expect do
|
330
|
+
expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog")
|
331
|
+
end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"")
|
332
|
+
end
|
277
333
|
end
|
278
334
|
end
|
279
335
|
|
@@ -1,15 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'stringio'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
owner = RSpec::Expectations::Helper::CollectionOwner.new
|
7
|
-
(1..n).each do |number|
|
8
|
-
owner.add_to_collection_with_length_method(number)
|
9
|
-
owner.add_to_collection_with_size_method(number)
|
10
|
-
end
|
11
|
-
owner
|
12
|
-
end
|
4
|
+
describe "have matcher" do
|
5
|
+
|
13
6
|
before(:each) do
|
14
7
|
if defined?(::ActiveSupport::Inflector)
|
15
8
|
@active_support_was_defined = true
|
@@ -24,10 +17,17 @@ share_as :HaveSpecHelper do
|
|
24
17
|
end
|
25
18
|
end
|
26
19
|
end
|
27
|
-
|
20
|
+
|
21
|
+
def create_collection_owner_with(n)
|
22
|
+
owner = RSpec::Expectations::Helper::CollectionOwner.new
|
23
|
+
(1..n).each do |number|
|
24
|
+
owner.add_to_collection_with_length_method(number)
|
25
|
+
owner.add_to_collection_with_size_method(number)
|
26
|
+
end
|
27
|
+
owner
|
28
|
+
end
|
28
29
|
|
29
30
|
describe "should have(n).items" do
|
30
|
-
include HaveSpecHelper
|
31
31
|
|
32
32
|
it "passes if target has a collection of items with n members" do
|
33
33
|
owner = create_collection_owner_with(3)
|
@@ -63,7 +63,6 @@ describe "should have(n).items" do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
66
|
-
include HaveSpecHelper
|
67
66
|
|
68
67
|
it 'pluralizes the collection name' do
|
69
68
|
owner = create_collection_owner_with(1)
|
@@ -78,7 +77,6 @@ describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
|
78
77
|
end
|
79
78
|
|
80
79
|
describe 'should have(1).item when Inflector is defined' do
|
81
|
-
include HaveSpecHelper
|
82
80
|
|
83
81
|
before(:each) do
|
84
82
|
if defined?(Inflector)
|
@@ -119,7 +117,6 @@ describe "should have(n).items where result responds to items but returns someth
|
|
119
117
|
end
|
120
118
|
|
121
119
|
describe "should_not have(n).items" do
|
122
|
-
include HaveSpecHelper
|
123
120
|
|
124
121
|
it "passes if target has a collection of items with < n members" do
|
125
122
|
owner = create_collection_owner_with(3)
|
@@ -145,7 +142,6 @@ describe "should_not have(n).items" do
|
|
145
142
|
end
|
146
143
|
|
147
144
|
describe "should have_exactly(n).items" do
|
148
|
-
include HaveSpecHelper
|
149
145
|
|
150
146
|
it "passes if target has a collection of items with n members" do
|
151
147
|
owner = create_collection_owner_with(3)
|
@@ -181,7 +177,6 @@ describe "should have_exactly(n).items" do
|
|
181
177
|
end
|
182
178
|
|
183
179
|
describe "should have_at_least(n).items" do
|
184
|
-
include HaveSpecHelper
|
185
180
|
|
186
181
|
it "passes if target has a collection of items with n members" do
|
187
182
|
owner = create_collection_owner_with(3)
|
@@ -235,8 +230,6 @@ EOF
|
|
235
230
|
end
|
236
231
|
|
237
232
|
describe "should have_at_most(n).items" do
|
238
|
-
include HaveSpecHelper
|
239
|
-
|
240
233
|
it "passes if target has a collection of items with n members" do
|
241
234
|
owner = create_collection_owner_with(3)
|
242
235
|
owner.should have_at_most(3).items_in_collection_with_length_method
|
@@ -330,8 +323,6 @@ describe "have(n).things on an object which is not a collection nor contains one
|
|
330
323
|
end
|
331
324
|
|
332
325
|
describe RSpec::Matchers::Have, "for a collection owner that implements #send" do
|
333
|
-
include HaveSpecHelper
|
334
|
-
|
335
326
|
before(:each) do
|
336
327
|
@collection = Object.new
|
337
328
|
def @collection.floozles; [1,2] end
|
@@ -406,3 +397,5 @@ module RSpec
|
|
406
397
|
end
|
407
398
|
end
|
408
399
|
end
|
400
|
+
|
401
|
+
end
|
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
version: 2.0.0.beta.
|
10
|
+
- 22
|
11
|
+
version: 2.0.0.beta.22
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- David Chelimsky
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2010-
|
20
|
+
date: 2010-09-12 00:00:00 -05:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -77,8 +77,8 @@ dependencies:
|
|
77
77
|
- 0
|
78
78
|
- 0
|
79
79
|
- beta
|
80
|
-
-
|
81
|
-
version: 2.0.0.beta.
|
80
|
+
- 22
|
81
|
+
version: 2.0.0.beta.22
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: *id004
|
@@ -94,8 +94,8 @@ dependencies:
|
|
94
94
|
- 0
|
95
95
|
- 0
|
96
96
|
- beta
|
97
|
-
-
|
98
|
-
version: 2.0.0.beta.
|
97
|
+
- 22
|
98
|
+
version: 2.0.0.beta.22
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
101
|
version_requirements: *id005
|
@@ -111,21 +111,23 @@ files:
|
|
111
111
|
- .document
|
112
112
|
- .gitignore
|
113
113
|
- Gemfile
|
114
|
+
- History.md
|
114
115
|
- License.txt
|
115
116
|
- README.markdown
|
116
117
|
- Rakefile
|
117
118
|
- Upgrade.markdown
|
118
|
-
- VERSION
|
119
119
|
- cucumber.yml
|
120
120
|
- features/README.markdown
|
121
121
|
- features/expectations/attribute_of_subject.feature
|
122
122
|
- features/expectations/customized_message.feature
|
123
|
+
- features/expectations/diffing.feature
|
123
124
|
- features/expectations/implicit_docstrings.feature
|
124
125
|
- features/matchers/access_running_example.feature
|
125
126
|
- features/matchers/define_diffable_matcher.feature
|
126
127
|
- features/matchers/define_matcher.feature
|
127
128
|
- features/matchers/define_matcher_outside_rspec.feature
|
128
129
|
- features/matchers/define_matcher_with_fluent_interface.feature
|
130
|
+
- features/matchers/equality.feature
|
129
131
|
- features/matchers/expect_change.feature
|
130
132
|
- features/matchers/expect_error.feature
|
131
133
|
- features/support/env.rb
|
@@ -203,7 +205,7 @@ files:
|
|
203
205
|
- spec/support/classes.rb
|
204
206
|
- specs.watchr
|
205
207
|
has_rdoc: true
|
206
|
-
homepage: http://github.com/rspec/expectations
|
208
|
+
homepage: http://github.com/rspec/rspec-expectations
|
207
209
|
licenses: []
|
208
210
|
|
209
211
|
post_install_message:
|
@@ -216,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
218
|
requirements:
|
217
219
|
- - ">="
|
218
220
|
- !ruby/object:Gem::Version
|
219
|
-
hash:
|
221
|
+
hash: -37858944882232104
|
220
222
|
segments:
|
221
223
|
- 0
|
222
224
|
version: "0"
|
@@ -236,8 +238,22 @@ rubyforge_project: rspec
|
|
236
238
|
rubygems_version: 1.3.7
|
237
239
|
signing_key:
|
238
240
|
specification_version: 3
|
239
|
-
summary: rspec-expectations-2.0.0.beta.
|
241
|
+
summary: rspec-expectations-2.0.0.beta.22
|
240
242
|
test_files:
|
243
|
+
- features/README.markdown
|
244
|
+
- features/expectations/attribute_of_subject.feature
|
245
|
+
- features/expectations/customized_message.feature
|
246
|
+
- features/expectations/diffing.feature
|
247
|
+
- features/expectations/implicit_docstrings.feature
|
248
|
+
- features/matchers/access_running_example.feature
|
249
|
+
- features/matchers/define_diffable_matcher.feature
|
250
|
+
- features/matchers/define_matcher.feature
|
251
|
+
- features/matchers/define_matcher_outside_rspec.feature
|
252
|
+
- features/matchers/define_matcher_with_fluent_interface.feature
|
253
|
+
- features/matchers/equality.feature
|
254
|
+
- features/matchers/expect_change.feature
|
255
|
+
- features/matchers/expect_error.feature
|
256
|
+
- features/support/env.rb
|
241
257
|
- spec/rspec/expectations/differ_spec.rb
|
242
258
|
- spec/rspec/expectations/extensions/kernel_spec.rb
|
243
259
|
- spec/rspec/expectations/fail_with_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0.beta.20
|