rspec-core 2.0.0.a10 → 2.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +9 -14
- data/VERSION +1 -1
- data/bin/autospec +4 -0
- data/features/hooks/described_class.feature +14 -0
- data/features/support/env.rb +15 -1
- data/lib/rspec/core.rb +3 -0
- data/lib/rspec/core/example.rb +8 -8
- data/lib/rspec/core/example_group.rb +10 -15
- data/lib/rspec/core/example_group_subject.rb +6 -2
- data/lib/rspec/core/rake_task.rb +1 -1
- metadata +18 -14
- data/features/mocks/block_local_expectations.feature +0 -68
- data/features/mocks/mix_stubs_and_mocks.feature +0 -28
data/Rakefile
CHANGED
@@ -28,9 +28,9 @@ begin
|
|
28
28
|
|
29
29
|
Thank you for installing #{gem.summary}
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
This is beta software. If you are looking
|
32
|
+
for a supported production release, please
|
33
|
+
"gem install rspec" (without --pre).
|
34
34
|
|
35
35
|
#{"*"*50}
|
36
36
|
EOM
|
@@ -39,17 +39,13 @@ rescue LoadError
|
|
39
39
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
Rspec::Core::RakeTask.new :spec
|
42
|
+
Rspec::Core::RakeTask.new(:spec)
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
rescue LoadError
|
52
|
-
puts "Rspec core or one of its dependencies is not installed. Install it with: gem install rspec-meta"
|
44
|
+
desc "Run all examples using rcov"
|
45
|
+
Rspec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
|
46
|
+
t.rcov = true
|
47
|
+
t.rcov_opts = %[-Ilib -Ispec --exclude "mocks,expectations,gems/*,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"]
|
48
|
+
t.rcov_opts << %[--no-html --aggregate coverage.data]
|
53
49
|
end
|
54
50
|
|
55
51
|
task :cleanup_rcov_files do
|
@@ -79,7 +75,6 @@ else
|
|
79
75
|
task :default => [:check_dependencies, :rcov, :features]
|
80
76
|
end
|
81
77
|
|
82
|
-
|
83
78
|
Rake::RDocTask.new do |rdoc|
|
84
79
|
rdoc.rdoc_dir = 'rdoc'
|
85
80
|
rdoc.title = "rspec-core #{Rspec::Core::Version::STRING}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.beta.1
|
data/bin/autospec
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: described class
|
2
|
+
|
3
|
+
Scenario: access the described class from the example
|
4
|
+
Given a file named "spec/example_spec.rb" with:
|
5
|
+
"""
|
6
|
+
describe Fixnum do
|
7
|
+
it "is available as described_class" do
|
8
|
+
described_class.should == Fixnum
|
9
|
+
end
|
10
|
+
end
|
11
|
+
"""
|
12
|
+
When I run "rspec spec/example_spec.rb"
|
13
|
+
Then I should see "1 example, 0 failures"
|
14
|
+
|
data/features/support/env.rb
CHANGED
@@ -1,2 +1,16 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH << File.expand_path("../../../../rspec-expectations/lib", __FILE__)
|
2
2
|
require 'rspec/expectations'
|
3
|
+
require 'aruba'
|
4
|
+
|
5
|
+
module ArubaOverrides
|
6
|
+
def detect_ruby_script(cmd)
|
7
|
+
if cmd =~ /^rspec /
|
8
|
+
"ruby -I../../lib -S ../../bin/#{cmd}"
|
9
|
+
else
|
10
|
+
super(cmd)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
World(ArubaOverrides)
|
16
|
+
|
data/lib/rspec/core.rb
CHANGED
data/lib/rspec/core/example.rb
CHANGED
@@ -31,6 +31,14 @@ module Rspec
|
|
31
31
|
@metadata[:file_path] || example_group.file_path
|
32
32
|
end
|
33
33
|
|
34
|
+
def inspect
|
35
|
+
@metadata[:full_description]
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
inspect
|
40
|
+
end
|
41
|
+
|
34
42
|
def run_started
|
35
43
|
record_results :started_at => Time.now
|
36
44
|
end
|
@@ -118,14 +126,6 @@ module Rspec
|
|
118
126
|
all_systems_nominal
|
119
127
|
end
|
120
128
|
|
121
|
-
def inspect
|
122
|
-
@metadata[:full_description]
|
123
|
-
end
|
124
|
-
|
125
|
-
def to_s
|
126
|
-
inspect
|
127
|
-
end
|
128
|
-
|
129
129
|
end
|
130
130
|
|
131
131
|
end
|
@@ -87,18 +87,14 @@ module Rspec
|
|
87
87
|
friendly ? metadata[:example_group][:name] : super()
|
88
88
|
end
|
89
89
|
|
90
|
-
def self.describes
|
91
|
-
metadata[:example_group][:describes]
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.described_class
|
95
|
-
describes || description
|
96
|
-
end
|
97
|
-
|
98
90
|
def self.description
|
99
91
|
metadata[:example_group][:description]
|
100
92
|
end
|
101
93
|
|
94
|
+
def self.describes
|
95
|
+
metadata[:example_group][:describes]
|
96
|
+
end
|
97
|
+
|
102
98
|
def self.file_path
|
103
99
|
metadata[:example_group][:file_path]
|
104
100
|
end
|
@@ -206,9 +202,8 @@ module Rspec
|
|
206
202
|
end
|
207
203
|
|
208
204
|
def self.let(name, &block)
|
209
|
-
# Should we block defining method names already defined?
|
210
205
|
define_method(name) do
|
211
|
-
|
206
|
+
__memoized[name] ||= instance_eval(&block)
|
212
207
|
end
|
213
208
|
end
|
214
209
|
|
@@ -216,17 +211,17 @@ module Rspec
|
|
216
211
|
metadata.all_apply?(filters)
|
217
212
|
end
|
218
213
|
|
219
|
-
def
|
220
|
-
|
214
|
+
def described_class
|
215
|
+
self.class.describes
|
221
216
|
end
|
222
217
|
|
223
|
-
def
|
224
|
-
|
218
|
+
def __memoized
|
219
|
+
@__memoized ||= {}
|
225
220
|
end
|
226
221
|
|
227
222
|
def __reset__
|
228
223
|
instance_variables.each { |ivar| remove_instance_variable(ivar) }
|
229
|
-
|
224
|
+
__memoized.clear
|
230
225
|
end
|
231
226
|
|
232
227
|
end
|
@@ -58,7 +58,7 @@ module Rspec
|
|
58
58
|
|
59
59
|
attr_reader :explicit_subject_block # :nodoc:
|
60
60
|
|
61
|
-
|
61
|
+
private
|
62
62
|
|
63
63
|
def explicit_subject
|
64
64
|
group = self
|
@@ -69,7 +69,11 @@ module Rspec
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def implicit_subject
|
72
|
-
|
72
|
+
Class === described ? lambda { described.new } : lambda { described }
|
73
|
+
end
|
74
|
+
|
75
|
+
def described
|
76
|
+
@described ||= describes || description
|
73
77
|
end
|
74
78
|
end
|
75
79
|
end
|
data/lib/rspec/core/rake_task.rb
CHANGED
@@ -51,7 +51,7 @@ module Rspec
|
|
51
51
|
|
52
52
|
def define # :nodoc:
|
53
53
|
actual_name = Hash === name ? name.keys.first : name
|
54
|
-
desc("Run
|
54
|
+
desc("Run Rspec code examples") unless ::Rake.application.last_comment
|
55
55
|
|
56
56
|
task name do
|
57
57
|
RakeFileUtils.send(:verbose, verbose) do
|
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
|
- Chad Humphries
|
@@ -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
|
@@ -30,8 +31,9 @@ dependencies:
|
|
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
|
@@ -45,8 +47,9 @@ dependencies:
|
|
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
55
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +69,7 @@ dependencies:
|
|
66
69
|
description: Rspec runner and example group classes
|
67
70
|
email: dchelimsky@gmail.com;chad.humphries@gmail.com
|
68
71
|
executables:
|
72
|
+
- autospec
|
69
73
|
- rspec
|
70
74
|
- spec
|
71
75
|
extensions: []
|
@@ -81,6 +85,7 @@ files:
|
|
81
85
|
- Rakefile
|
82
86
|
- TODO.markdown
|
83
87
|
- VERSION
|
88
|
+
- bin/autospec
|
84
89
|
- bin/rspec
|
85
90
|
- bin/spec
|
86
91
|
- cucumber.yml
|
@@ -156,13 +161,12 @@ files:
|
|
156
161
|
- features/example_groups/nested_groups.feature
|
157
162
|
- features/hooks/around_hook.feature
|
158
163
|
- features/hooks/before_and_after_hooks.feature
|
164
|
+
- features/hooks/described_class.feature
|
159
165
|
- features/hooks/halt.feature
|
160
166
|
- features/mock_framework_integration/use_flexmock.feature
|
161
167
|
- features/mock_framework_integration/use_mocha.feature
|
162
168
|
- features/mock_framework_integration/use_rr.feature
|
163
169
|
- features/mock_framework_integration/use_rspec.feature
|
164
|
-
- features/mocks/block_local_expectations.feature
|
165
|
-
- features/mocks/mix_stubs_and_mocks.feature
|
166
170
|
- features/subject/explicit_subject.feature
|
167
171
|
- features/subject/implicit_subject.feature
|
168
172
|
- features/support/env.rb
|
@@ -230,11 +234,11 @@ licenses: []
|
|
230
234
|
post_install_message: |
|
231
235
|
**************************************************
|
232
236
|
|
233
|
-
Thank you for installing rspec-core-2.0.0.
|
237
|
+
Thank you for installing rspec-core-2.0.0.beta.1
|
234
238
|
|
235
|
-
|
236
|
-
|
237
|
-
|
239
|
+
This is beta software. If you are looking
|
240
|
+
for a supported production release, please
|
241
|
+
"gem install rspec" (without --pre).
|
238
242
|
|
239
243
|
**************************************************
|
240
244
|
|
@@ -264,7 +268,7 @@ rubyforge_project: rspec
|
|
264
268
|
rubygems_version: 1.3.6
|
265
269
|
signing_key:
|
266
270
|
specification_version: 3
|
267
|
-
summary: rspec-core-2.0.0.
|
271
|
+
summary: rspec-core-2.0.0.beta.1
|
268
272
|
test_files:
|
269
273
|
- spec/rspec/core/command_line_options_spec.rb
|
270
274
|
- spec/rspec/core/configuration_spec.rb
|
@@ -1,68 +0,0 @@
|
|
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"
|
@@ -1,28 +0,0 @@
|
|
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"
|