rspec-mocks 2.0.0.a10 → 2.0.0.beta.1
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/.gitignore +1 -0
- data/Rakefile +16 -14
- data/VERSION +1 -1
- data/features/mocks/block_local_expectations.feature +68 -0
- data/features/mocks/mix_stubs_and_mocks.feature +28 -0
- data/features/support/env.rb +2 -0
- data/spec/spec_helper.rb +3 -3
- metadata +20 -50
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
2
|
require 'rake'
|
3
|
-
|
4
|
-
$:.unshift File.expand_path(File.join(File.dirname(__FILE__),'lib'))
|
5
|
-
|
6
3
|
require 'rspec/mocks/version'
|
7
4
|
|
8
5
|
begin
|
@@ -16,19 +13,16 @@ begin
|
|
16
13
|
gem.homepage = "http://github.com/rspec/mocks"
|
17
14
|
gem.authors = ["David Chelimsky", "Chad Humphries"]
|
18
15
|
gem.rubyforge_project = "rspec"
|
19
|
-
gem.add_development_dependency
|
20
|
-
gem.add_development_dependency
|
21
|
-
gem.add_development_dependency('mocha')
|
22
|
-
gem.add_development_dependency('flexmock')
|
23
|
-
gem.add_development_dependency('rr')
|
16
|
+
gem.add_development_dependency 'rspec-core', Rspec::Mocks::Version::STRING
|
17
|
+
gem.add_development_dependency 'rspec-expectations', Rspec::Mocks::Version::STRING
|
24
18
|
gem.post_install_message = <<-EOM
|
25
19
|
#{"*"*50}
|
26
20
|
|
27
21
|
Thank you for installing #{gem.summary}
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
This is beta software. If you are looking
|
24
|
+
for a supported production release, please
|
25
|
+
"gem install rspec" (without --pre).
|
32
26
|
|
33
27
|
#{"*"*50}
|
34
28
|
EOM
|
@@ -49,14 +43,21 @@ rescue LoadError
|
|
49
43
|
puts "Rspec core or one of its dependencies is not installed. Install it with: gem install rspec-meta"
|
50
44
|
end
|
51
45
|
|
46
|
+
begin
|
47
|
+
require 'cucumber/rake/task'
|
48
|
+
Cucumber::Rake::Task.new do |t|
|
49
|
+
t.cucumber_opts = %w{--format progress}
|
50
|
+
end
|
51
|
+
rescue LoadError
|
52
|
+
puts "Cucumber or one of its dependencies is not installed. Install it with: gem install cucumber"
|
53
|
+
end
|
54
|
+
|
52
55
|
task :clobber do
|
53
56
|
rm_rf 'pkg'
|
54
57
|
rm_rf 'tmp'
|
55
58
|
rm_rf 'coverage'
|
56
59
|
end
|
57
60
|
|
58
|
-
task :default => [:check_dependencies, :spec]
|
59
|
-
|
60
61
|
require 'rake/rdoctask'
|
61
62
|
Rake::RDocTask.new do |rdoc|
|
62
63
|
rdoc.rdoc_dir = 'rdoc'
|
@@ -65,3 +66,4 @@ Rake::RDocTask.new do |rdoc|
|
|
65
66
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
66
67
|
end
|
67
68
|
|
69
|
+
task :default => [:check_dependencies, :spec, :cucumber]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.beta.1
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Feature: block local expectations
|
2
|
+
|
3
|
+
In order to set message expectations on ...
|
4
|
+
As an RSpec user
|
5
|
+
I want to configure the evaluation context
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "account.rb" with:
|
9
|
+
"""
|
10
|
+
class Account
|
11
|
+
def self.create
|
12
|
+
yield new
|
13
|
+
end
|
14
|
+
|
15
|
+
def opening_balance(amount, currency)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
|
20
|
+
Scenario: passing example
|
21
|
+
Given a file named "account_passing_spec.rb" with:
|
22
|
+
"""
|
23
|
+
require 'account'
|
24
|
+
|
25
|
+
Rspec.configure do |config|
|
26
|
+
config.mock_framework = :rspec
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "account DSL" do
|
30
|
+
it "it succeeds when the block local receives the given call" do
|
31
|
+
account = Account.new
|
32
|
+
Account.should_receive(:create).and_yield do |account|
|
33
|
+
account.should_receive(:opening_balance).with(100, :USD)
|
34
|
+
end
|
35
|
+
Account.create do
|
36
|
+
opening_balance 100, :USD
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When I run "rspec account_passing_spec.rb"
|
42
|
+
Then I should see "1 example, 0 failures"
|
43
|
+
|
44
|
+
Scenario: failing example
|
45
|
+
|
46
|
+
Given a file named "account_failing_spec.rb" with:
|
47
|
+
"""
|
48
|
+
require 'account'
|
49
|
+
|
50
|
+
Rspec.configure do |config|
|
51
|
+
config.mock_framework = :rspec
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "account DSL" do
|
55
|
+
it "fails when the block local does not receive the expected call" do
|
56
|
+
account = Account.new
|
57
|
+
Account.should_receive(:create).and_yield do |account|
|
58
|
+
account.should_receive(:opening_balance).with(100, :USD)
|
59
|
+
end
|
60
|
+
Account.create do
|
61
|
+
# opening_balance is not called here
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
|
67
|
+
When I run "rspec account_failing_spec.rb"
|
68
|
+
Then I should see "1 example, 1 failure"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Spec and test together
|
2
|
+
|
3
|
+
As an RSpec user
|
4
|
+
I want to use stubs and mocks together
|
5
|
+
|
6
|
+
Scenario: stub in before
|
7
|
+
Given a file named "stub_and_mocks_spec.rb" with:
|
8
|
+
"""
|
9
|
+
require 'rspec/expectations'
|
10
|
+
|
11
|
+
Rspec.configure do |config|
|
12
|
+
config.mock_framework = :rspec
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "a stub in before" do
|
16
|
+
before(:each) do
|
17
|
+
@messenger = mock('messenger').as_null_object
|
18
|
+
end
|
19
|
+
|
20
|
+
it "a" do
|
21
|
+
@messenger.should_receive(:foo).with('first')
|
22
|
+
@messenger.foo('second')
|
23
|
+
@messenger.foo('third')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
When I run "rspec stub_and_mocks_spec.rb -fs"
|
28
|
+
Then I should see "'messenger' expected :foo with"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('../../../rspec-core/lib', __FILE__))
|
2
|
-
require 'rspec/core'
|
3
1
|
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
+
$LOAD_PATH << File.expand_path('../../../rspec-core/lib', __FILE__)
|
3
|
+
$LOAD_PATH << File.expand_path('../../../rspec-expectations/lib', __FILE__)
|
4
|
+
require 'rspec/core'
|
4
5
|
require 'rspec/mocks'
|
5
|
-
$LOAD_PATH.unshift(File.expand_path('../../../rspec-expectations/lib', __FILE__))
|
6
6
|
require 'rspec/expectations'
|
7
7
|
|
8
8
|
module Macros
|
metadata
CHANGED
@@ -6,8 +6,9 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 2
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
|
9
|
+
- beta
|
10
|
+
- 1
|
11
|
+
version: 2.0.0.beta.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- David Chelimsky
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-
|
20
|
+
date: 2010-03-01 00:00:00 -06:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
@@ -24,14 +25,15 @@ dependencies:
|
|
24
25
|
prerelease: false
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
27
|
requirements:
|
27
|
-
- - "
|
28
|
+
- - "="
|
28
29
|
- !ruby/object:Gem::Version
|
29
30
|
segments:
|
30
31
|
- 2
|
31
32
|
- 0
|
32
33
|
- 0
|
33
|
-
-
|
34
|
-
|
34
|
+
- beta
|
35
|
+
- 1
|
36
|
+
version: 2.0.0.beta.1
|
35
37
|
type: :development
|
36
38
|
version_requirements: *id001
|
37
39
|
- !ruby/object:Gem::Dependency
|
@@ -39,52 +41,17 @@ dependencies:
|
|
39
41
|
prerelease: false
|
40
42
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
43
|
requirements:
|
42
|
-
- - "
|
44
|
+
- - "="
|
43
45
|
- !ruby/object:Gem::Version
|
44
46
|
segments:
|
45
47
|
- 2
|
46
48
|
- 0
|
47
49
|
- 0
|
48
|
-
-
|
49
|
-
|
50
|
+
- beta
|
51
|
+
- 1
|
52
|
+
version: 2.0.0.beta.1
|
50
53
|
type: :development
|
51
54
|
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: mocha
|
54
|
-
prerelease: false
|
55
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
62
|
-
type: :development
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: flexmock
|
66
|
-
prerelease: false
|
67
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
version: "0"
|
74
|
-
type: :development
|
75
|
-
version_requirements: *id004
|
76
|
-
- !ruby/object:Gem::Dependency
|
77
|
-
name: rr
|
78
|
-
prerelease: false
|
79
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
version: "0"
|
86
|
-
type: :development
|
87
|
-
version_requirements: *id005
|
88
55
|
description: Rspec's 'test double' framework, with support for stubbing and mocking
|
89
56
|
email: dchelimsky@gmail.com;chad.humphries@gmail.com
|
90
57
|
executables: []
|
@@ -100,6 +67,9 @@ files:
|
|
100
67
|
- README.markdown
|
101
68
|
- Rakefile
|
102
69
|
- VERSION
|
70
|
+
- features/mocks/block_local_expectations.feature
|
71
|
+
- features/mocks/mix_stubs_and_mocks.feature
|
72
|
+
- features/support/env.rb
|
103
73
|
- lib/rspec/mocks.rb
|
104
74
|
- lib/rspec/mocks/argument_expectation.rb
|
105
75
|
- lib/rspec/mocks/argument_matchers.rb
|
@@ -166,11 +136,11 @@ licenses: []
|
|
166
136
|
post_install_message: |
|
167
137
|
**************************************************
|
168
138
|
|
169
|
-
Thank you for installing rspec-mocks-2.0.0.
|
139
|
+
Thank you for installing rspec-mocks-2.0.0.beta.1
|
170
140
|
|
171
|
-
|
172
|
-
|
173
|
-
|
141
|
+
This is beta software. If you are looking
|
142
|
+
for a supported production release, please
|
143
|
+
"gem install rspec" (without --pre).
|
174
144
|
|
175
145
|
**************************************************
|
176
146
|
|
@@ -200,7 +170,7 @@ rubyforge_project: rspec
|
|
200
170
|
rubygems_version: 1.3.6
|
201
171
|
signing_key:
|
202
172
|
specification_version: 3
|
203
|
-
summary: rspec-mocks-2.0.0.
|
173
|
+
summary: rspec-mocks-2.0.0.beta.1
|
204
174
|
test_files:
|
205
175
|
- spec/rspec/mocks/and_yield_spec.rb
|
206
176
|
- spec/rspec/mocks/any_number_of_times_spec.rb
|