rspec-core 2.0.0.beta.10 → 2.0.0.beta.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,18 +63,6 @@ Use the documentation formatter to see the resulting spec:
63
63
  Finished in 0.000379 seconds
64
64
  1 example, 0 failures
65
65
 
66
- ## Configuration
67
-
68
- You can define runtime configuration options in four places. They
69
- are loaded and processed in this order:
70
-
71
- * ~/.rspec
72
- * .rspec
73
- * RSpec.configure
74
- * command line
75
-
76
- Run `rspec --help` to see supported configuration options.
77
-
78
66
  #### Also see
79
67
 
80
68
  * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
@@ -1,11 +1,29 @@
1
1
  # Upgrade to rspec-core-2.0
2
2
 
3
- ## What's changed
3
+ ## What's changed since rspec-1
4
4
 
5
- ### RSpec namespace
5
+ ### rspec command
6
6
 
7
- The root namespace is now `RSpec` instead of `Spec`, and the root directory
8
- under `lib` is `rspec` instead of `spec`.
7
+ The command to run specs is now `rspec` instead of `spec`.
8
+
9
+ rspec ./spec
10
+
11
+ ### autotest
12
+
13
+ RSpec-2 works with autotest as follows:
14
+
15
+ # in ./autotest/discover.rb
16
+ Autotest.add_discovery { "rspec2" }
17
+
18
+ # command line
19
+ $ autotest
20
+
21
+ The `autospec` command is a thing of the past.
22
+
23
+ ### RSpec
24
+
25
+ The root namespace (top level module ) is now `RSpec` instead of `Spec`, and
26
+ the root directory under `lib` within all of the `rspec` gems is `rspec` instead of `spec`.
9
27
 
10
28
  ### Configuration
11
29
 
@@ -15,11 +33,15 @@ Typically in `spec/spec_helper.rb`, configuration is now done like this:
15
33
  # ....
16
34
  end
17
35
 
18
- ### rspec commmand
36
+ ### .rspec
19
37
 
20
- The command to run specs is now `rspec` instead of `spec`.
38
+ Command line options can be persisted in a `.rspec` file in a project. You
39
+ can also store a `.rspec` file in your home directory (`~/.rspec`) with global
40
+ options. Precedence is:
21
41
 
22
- rspec ./spec
42
+ command line
43
+ ./.rspec
44
+ ~/.rspec
23
45
 
24
46
  ## What's new
25
47
 
@@ -35,6 +57,8 @@ like the file and line number on which it was declared, the arguments passed to
35
57
  argument passed to `describe` or `it`, allowing us to pre and post-process
36
58
  each example in a variety of ways.
37
59
 
60
+ ### Filtering
61
+
38
62
  The most obvious use is for filtering the run. For example:
39
63
 
40
64
  # in spec/spec_helper.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0.beta.10
1
+ 2.0.0.beta.11
@@ -166,6 +166,10 @@ Feature: before and after hooks
166
166
  example "in outer group" do
167
167
  end
168
168
 
169
+ after(:all) do
170
+ puts "outer after all"
171
+ end
172
+
169
173
  describe "nested group" do
170
174
  before(:all) do
171
175
  puts "inner before all"
@@ -179,10 +183,6 @@ Feature: before and after hooks
179
183
  end
180
184
  end
181
185
 
182
- after(:all) do
183
- puts "outer after all"
184
- end
185
-
186
186
  end
187
187
  """
188
188
  When I run "rspec ./before_and_after_all_spec.rb"
@@ -197,6 +197,42 @@ Feature: before and after hooks
197
197
  Then I should see "1 example, 0 failures"
198
198
  Then I should see matching /outer before all\n.outer after all\n\n\n\nFinished/
199
199
 
200
+ Scenario: before/after all blocks have access to state
201
+ Given a file named "before_and_after_all_spec.rb" with:
202
+ """
203
+ describe "before and after callbacks" do
204
+ before(:all) do
205
+ @outer_state = "set in outer before all"
206
+ end
207
+
208
+ example "in outer group" do
209
+ @outer_state.should eq("set in outer before all")
210
+ end
211
+
212
+ describe "nested group" do
213
+ before(:all) do
214
+ @inner_state = "set in inner before all"
215
+ end
216
+
217
+ example "in nested group" do
218
+ @outer_state.should eq("set in outer before all")
219
+ @inner_state.should eq("set in inner before all")
220
+ end
221
+
222
+ after(:all) do
223
+ @inner_state.should eq("set in inner before all")
224
+ end
225
+ end
226
+
227
+ after(:all) do
228
+ # p @outer_state.nil?
229
+ @outer_state.should eq("set in outer before all")
230
+ end
231
+ end
232
+ """
233
+ When I run "rspec ./before_and_after_all_spec.rb"
234
+ Then I should see "2 examples, 0 failures"
235
+
200
236
  Scenario: exception in before(:each) is captured and reported as failure
201
237
  Given a file named "error_in_before_each_spec.rb" with:
202
238
  """
@@ -71,7 +71,7 @@ module RSpec
71
71
  def local_options_file(options)
72
72
  return options[:options_file] if options[:options_file]
73
73
  return LOCAL_OPTIONS_FILE if File.exist?(LOCAL_OPTIONS_FILE)
74
- RSpec.deprecate("spec/spec.opts", ".rspec or ~/.rspec", "2.0.0") if File.exist?("spec/spec.opts")
74
+ RSpec.deprecate("spec/spec.opts", "./.rspec or ~/.rspec", "2.0.0") if File.exist?("spec/spec.opts")
75
75
  "spec/spec.opts"
76
76
  end
77
77
  end
@@ -156,13 +156,13 @@ module RSpec
156
156
 
157
157
  def self.eval_after_alls(running_example)
158
158
  return if filtered_examples.empty?
159
+ before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
159
160
  ancestors.each do |ancestor|
160
161
  until ancestor.after_alls.empty?
161
162
  running_example.instance_eval &ancestor.after_alls.pop
162
163
  end
163
164
  end
164
165
  world.run_hook(:after, :all, self, running_example)
165
- before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
166
166
  end
167
167
 
168
168
  def self.run(reporter)
@@ -9,7 +9,7 @@ module RSpec
9
9
  end
10
10
 
11
11
  def subject
12
- attribute_of_subject || original_subject
12
+ using_attribute? ? attribute_of_subject : original_subject
13
13
  end
14
14
 
15
15
  # When +should+ is called with no explicit receiver, the call is
@@ -80,7 +80,7 @@ module RSpec
80
80
  end
81
81
 
82
82
  def attribute_of_subject
83
- original_subject.send(running_example.description) if using_attribute?
83
+ original_subject.send(running_example.description) if using_attribute?
84
84
  end
85
85
 
86
86
  def using_attribute?
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-core}
8
- s.version = "2.0.0.beta.10"
8
+ s.version = "2.0.0.beta.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Humphries", "David Chelimsky"]
12
- s.date = %q{2010-06-02}
12
+ s.date = %q{2010-06-06}
13
13
  s.description = %q{RSpec runner and example group classes}
14
14
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
15
15
  s.executables = ["rspec", "spec"]
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  "License.txt",
25
25
  "README.markdown",
26
26
  "Rakefile",
27
- "TODO.markdown",
28
27
  "Upgrade.markdown",
29
28
  "VERSION",
30
29
  "autotest/discover.rb",
@@ -131,7 +130,7 @@ Gem::Specification.new do |s|
131
130
  s.homepage = %q{http://github.com/rspec/core}
132
131
  s.post_install_message = %q{**************************************************
133
132
 
134
- Thank you for installing rspec-core-2.0.0.beta.10
133
+ Thank you for installing rspec-core-2.0.0.beta.11
135
134
 
136
135
  This is beta software. If you are looking
137
136
  for a supported production release, please
@@ -143,7 +142,7 @@ Gem::Specification.new do |s|
143
142
  s.require_paths = ["lib"]
144
143
  s.rubyforge_project = %q{rspec}
145
144
  s.rubygems_version = %q{1.3.6}
146
- s.summary = %q{rspec-core-2.0.0.beta.10}
145
+ s.summary = %q{rspec-core-2.0.0.beta.11}
147
146
  s.test_files = [
148
147
  "spec/autotest/failed_results_re_spec.rb",
149
148
  "spec/autotest/rspec_spec.rb",
@@ -183,19 +182,19 @@ Gem::Specification.new do |s|
183
182
  s.specification_version = 3
184
183
 
185
184
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
186
- s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.10"])
187
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.10"])
185
+ s.add_development_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.11"])
186
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.11"])
188
187
  s.add_development_dependency(%q<cucumber>, [">= 0.5.3"])
189
188
  s.add_development_dependency(%q<autotest>, [">= 4.2.9"])
190
189
  else
191
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.10"])
192
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.10"])
190
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.11"])
191
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.11"])
193
192
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
194
193
  s.add_dependency(%q<autotest>, [">= 4.2.9"])
195
194
  end
196
195
  else
197
- s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.10"])
198
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.10"])
196
+ s.add_dependency(%q<rspec-expectations>, [">= 2.0.0.beta.11"])
197
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.beta.11"])
199
198
  s.add_dependency(%q<cucumber>, [">= 0.5.3"])
200
199
  s.add_dependency(%q<autotest>, [">= 4.2.9"])
201
200
  end
@@ -238,6 +238,17 @@ module RSpec::Core
238
238
  ]
239
239
  end
240
240
 
241
+ it "accesses before(:all) state in after(:all)" do
242
+ group = ExampleGroup.describe
243
+ group.before(:all) { @ivar = "value" }
244
+ group.after(:all) { @ivar.should eq("value") }
245
+ group.example("ignore") { }
246
+
247
+ expect do
248
+ group.run_all
249
+ end.to_not raise_error
250
+ end
251
+
241
252
  it "exposes the around each blocks at after_alls" do
242
253
  group = ExampleGroup.describe
243
254
  group.around(:each) { 'foo' }
@@ -439,6 +450,17 @@ module RSpec::Core
439
450
  context "subject modified in before block" do
440
451
  before { subject.class.should == RSpec::Core::ExampleGroup }
441
452
  end
453
+
454
+ context "with nil value" do
455
+ subject do
456
+ Class.new do
457
+ def nil_value
458
+ nil
459
+ end
460
+ end.new
461
+ end
462
+ its(:nil_value) { should be_nil }
463
+ end
442
464
  end
443
465
 
444
466
  describe "#top_level_description" do
metadata CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
7
7
  - 0
8
8
  - 0
9
9
  - beta
10
- - 10
11
- version: 2.0.0.beta.10
10
+ - 11
11
+ version: 2.0.0.beta.11
12
12
  platform: ruby
13
13
  authors:
14
14
  - Chad Humphries
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-06-02 00:00:00 -05:00
20
+ date: 2010-06-06 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -32,8 +32,8 @@ dependencies:
32
32
  - 0
33
33
  - 0
34
34
  - beta
35
- - 10
36
- version: 2.0.0.beta.10
35
+ - 11
36
+ version: 2.0.0.beta.11
37
37
  type: :development
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,8 @@ dependencies:
48
48
  - 0
49
49
  - 0
50
50
  - beta
51
- - 10
52
- version: 2.0.0.beta.10
51
+ - 11
52
+ version: 2.0.0.beta.11
53
53
  type: :development
54
54
  version_requirements: *id002
55
55
  - !ruby/object:Gem::Dependency
@@ -97,7 +97,6 @@ files:
97
97
  - License.txt
98
98
  - README.markdown
99
99
  - Rakefile
100
- - TODO.markdown
101
100
  - Upgrade.markdown
102
101
  - VERSION
103
102
  - autotest/discover.rb
@@ -207,7 +206,7 @@ licenses: []
207
206
  post_install_message: |
208
207
  **************************************************
209
208
 
210
- Thank you for installing rspec-core-2.0.0.beta.10
209
+ Thank you for installing rspec-core-2.0.0.beta.11
211
210
 
212
211
  This is beta software. If you are looking
213
212
  for a supported production release, please
@@ -241,7 +240,7 @@ rubyforge_project: rspec
241
240
  rubygems_version: 1.3.6
242
241
  signing_key:
243
242
  specification_version: 3
244
- summary: rspec-core-2.0.0.beta.10
243
+ summary: rspec-core-2.0.0.beta.11
245
244
  test_files:
246
245
  - spec/autotest/failed_results_re_spec.rb
247
246
  - spec/autotest/rspec_spec.rb
@@ -1,15 +0,0 @@
1
- ### RSpec Core
2
-
3
- * support the following concepts from rspec-1.2.x
4
- * run options
5
- * from command line
6
- * in rake task definitions
7
- * formatters
8
- * For self testing
9
- ** shared example groups should not be merged into the real 'world'
10
- * make sure all behaviour refs are now examplegroup
11
-
12
- ### Maxwell
13
-
14
- * need to figure out how maxwell will allow us to mix all the rails testing
15
- facilities with rspec when working with rails.