rspec-core 2.9.0.rc2 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +3 -2
- data/lib/rspec/core/subject.rb +15 -7
- data/lib/rspec/core/version.rb +1 -1
- data/spec/rspec/core/subject_spec.rb +29 -0
- metadata +9 -13
data/Changelog.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
### 2.9.0
|
2
|
-
[full changelog](http://github.com/rspec/rspec-core/compare/v2.8.0...v2.9.0
|
1
|
+
### 2.9.0 / 2012-03-17
|
2
|
+
[full changelog](http://github.com/rspec/rspec-core/compare/v2.8.0...v2.9.0)
|
3
3
|
|
4
4
|
Enhancements
|
5
5
|
|
@@ -19,6 +19,7 @@ Bug fixes
|
|
19
19
|
* In "autorun", don't run the specs in the at_exit hook if there was an
|
20
20
|
exception (most likely due to a SyntaxError). (sunaku)
|
21
21
|
* Don't extend groups with modules already used to extend ancestor groups.
|
22
|
+
* `its` correctly memoizes nil or false values (Yamada Masaki)
|
22
23
|
|
23
24
|
### 2.8.0 / 2012-01-04
|
24
25
|
|
data/lib/rspec/core/subject.rb
CHANGED
@@ -67,6 +67,16 @@ module RSpec
|
|
67
67
|
end
|
68
68
|
rescue LoadError
|
69
69
|
end
|
70
|
+
|
71
|
+
def _attribute_chain(attribute)
|
72
|
+
attribute.to_s.split('.')
|
73
|
+
end
|
74
|
+
|
75
|
+
def _nested_attribute(subject, attribute)
|
76
|
+
_attribute_chain(attribute).inject(subject) do |subject, attr|
|
77
|
+
subject.send(attr)
|
78
|
+
end
|
79
|
+
end
|
70
80
|
end
|
71
81
|
|
72
82
|
module ExampleGroupMethods
|
@@ -122,13 +132,11 @@ module RSpec
|
|
122
132
|
example do
|
123
133
|
self.class.class_eval do
|
124
134
|
define_method(:subject) do
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
135
|
+
if defined?(@_subject)
|
136
|
+
@_subject
|
137
|
+
else
|
138
|
+
@_subject = Array === attribute ? super()[*attribute] : _nested_attribute(super(), attribute)
|
139
|
+
end
|
132
140
|
end
|
133
141
|
end
|
134
142
|
instance_eval(&block)
|
data/lib/rspec/core/version.rb
CHANGED
@@ -194,6 +194,35 @@ module RSpec::Core
|
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
+
context "with nil subject" do
|
198
|
+
subject do
|
199
|
+
Class.new do
|
200
|
+
def initialize
|
201
|
+
@counter = -1
|
202
|
+
end
|
203
|
+
def nil_if_first_time
|
204
|
+
@counter += 1
|
205
|
+
@counter == 0 ? nil : true
|
206
|
+
end
|
207
|
+
end.new
|
208
|
+
end
|
209
|
+
its(:nil_if_first_time) { should be(nil) }
|
210
|
+
end
|
211
|
+
|
212
|
+
context "with false subject" do
|
213
|
+
subject do
|
214
|
+
Class.new do
|
215
|
+
def initialize
|
216
|
+
@counter = -1
|
217
|
+
end
|
218
|
+
def false_if_first_time
|
219
|
+
@counter += 1
|
220
|
+
@counter > 0
|
221
|
+
end
|
222
|
+
end.new
|
223
|
+
end
|
224
|
+
its(:false_if_first_time) { should be(false) }
|
225
|
+
end
|
197
226
|
end
|
198
227
|
end
|
199
228
|
end
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 43
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 9
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 2
|
12
|
-
version: 2.9.0.rc2
|
10
|
+
version: 2.9.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Steven Baker
|
@@ -19,7 +17,7 @@ autorequire:
|
|
19
17
|
bindir: exe
|
20
18
|
cert_chain: []
|
21
19
|
|
22
|
-
date: 2012-03-
|
20
|
+
date: 2012-03-17 00:00:00 Z
|
23
21
|
dependencies:
|
24
22
|
- !ruby/object:Gem::Dependency
|
25
23
|
name: cucumber
|
@@ -363,21 +361,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
363
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
364
362
|
none: false
|
365
363
|
requirements:
|
366
|
-
- - "
|
364
|
+
- - ">="
|
367
365
|
- !ruby/object:Gem::Version
|
368
|
-
hash:
|
366
|
+
hash: 3
|
369
367
|
segments:
|
370
|
-
-
|
371
|
-
|
372
|
-
- 1
|
373
|
-
version: 1.3.1
|
368
|
+
- 0
|
369
|
+
version: "0"
|
374
370
|
requirements: []
|
375
371
|
|
376
372
|
rubyforge_project: rspec
|
377
373
|
rubygems_version: 1.8.15
|
378
374
|
signing_key:
|
379
375
|
specification_version: 3
|
380
|
-
summary: rspec-core-2.9.0
|
376
|
+
summary: rspec-core-2.9.0
|
381
377
|
test_files:
|
382
378
|
- features/Autotest.md
|
383
379
|
- features/README.md
|