rspec-core 2.0.0.rc → 2.0.0

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.
@@ -384,6 +384,32 @@ module RSpec::Core
384
384
  example.metadata[:execution_result][:exception_encountered].message.should == "error in before all"
385
385
  end
386
386
 
387
+ context "when an error occurs in an after(:all) hook" do
388
+ before(:each) do
389
+ RSpec.configuration.reporter.stub(:message)
390
+ end
391
+
392
+ let(:group) do
393
+ ExampleGroup.describe do
394
+ after(:all) { raise "error in after all" }
395
+ it("equality") { 1.should == 1 }
396
+ end
397
+ end
398
+
399
+ it "allows the example to pass" do
400
+ group.run
401
+ example = group.examples.first
402
+ example.metadata.should_not be_nil
403
+ example.metadata[:execution_result].should_not be_nil
404
+ example.metadata[:execution_result][:status].should == "passed"
405
+ end
406
+
407
+ it "rescues the error and prints it out" do
408
+ RSpec.configuration.reporter.should_receive(:message).with(/error in after all/)
409
+ group.run
410
+ end
411
+ end
412
+
387
413
  it "has no 'running example' within before(:all)" do
388
414
  group = ExampleGroup.describe
389
415
  running_example = :none
@@ -117,18 +117,6 @@ describe RSpec::Core::Example, :parent_metadata => 'sample' do
117
117
  end
118
118
  end
119
119
 
120
- describe "#in_block?" do
121
- before do
122
- example.should_not be_in_block
123
- end
124
- it "is only true during the example (but not before or after)" do
125
- example.should be_in_block
126
- end
127
- after do
128
- example.should_not be_in_block
129
- end
130
- end
131
-
132
120
  describe "#pending" do
133
121
  context "in the example" do
134
122
  it "sets the example to pending" do
@@ -26,6 +26,26 @@ module RSpec::Core
26
26
  end
27
27
 
28
28
  describe "hooks with single filters" do
29
+
30
+ context "with no scope specified" do
31
+ it "should be ran around|before|after :each if the filter matches the example group's filter" do
32
+ filters = []
33
+ RSpec.configure do |c|
34
+ c.around(:match => true) {|example| filters << "around each in config"; example.run}
35
+ c.before(:match => true) { filters << "before each in config"}
36
+ c.after(:match => true) { filters << "after each in config"}
37
+ end
38
+ group = ExampleGroup.describe(:match => true)
39
+ group.example("example") {}
40
+ group.run
41
+ filters.should == [
42
+ "around each in config",
43
+ "before each in config",
44
+ "after each in config"
45
+ ]
46
+ end
47
+ end
48
+
29
49
  it "should be ran if the filter matches the example group's filter" do
30
50
  filters = []
31
51
  RSpec.configure do |c|
@@ -6,6 +6,8 @@ module RSpec::Core
6
6
  RSpec.stub(:deprecate)
7
7
  end
8
8
 
9
+ let(:output_file){ mock File }
10
+
9
11
  it "deprecates the --formatter option" do
10
12
  RSpec.should_receive(:deprecate)
11
13
  Parser.parse!(%w[--formatter doc])
@@ -23,13 +25,15 @@ module RSpec::Core
23
25
  end
24
26
 
25
27
  it "parses output stream from --out" do
28
+ File.should_receive(:open).with("foo.txt",'w').and_return(output_file)
26
29
  options = Parser.parse!(%w[--out foo.txt])
27
- options.should eq( {:output_stream=>"foo.txt"} )
30
+ options.should eq( {:output_stream=>output_file} )
28
31
  end
29
32
 
30
33
  it "parses output stream from -o" do
34
+ File.should_receive(:open).with("foo.txt",'w').and_return(output_file)
31
35
  options = Parser.parse!(%w[-o foo.txt])
32
- options.should eq( {:output_stream=>"foo.txt"} )
36
+ options.should eq( {:output_stream=>output_file} )
33
37
  end
34
38
  end
35
- end
39
+ end
@@ -88,17 +88,24 @@ module RSpec::Core
88
88
  it "renders them after rcov" do
89
89
  task.rcov = true
90
90
  task.rcov_opts = '--exclude "mocks"'
91
- spec_command.should =~ /^-S rcov --exclude "mocks"/
91
+ spec_command.should =~ /rcov.*--exclude "mocks"/
92
+ end
93
+
94
+ it "ensures that -Ispec is in the resulting command" do
95
+ task.rcov = true
96
+ task.rcov_opts = '--exclude "mocks"'
97
+ spec_command.should =~ /rcov.*-Ispec/
92
98
  end
93
99
  end
94
100
  end
95
101
 
96
102
  context "with rspec_opts" do
97
103
  context "with rcov=true" do
98
- it "does not add the rspec_opts" do
104
+ it "adds the rspec_opts after the rcov_opts and files" do
105
+ task.stub(:files_to_run) { "this.rb that.rb" }
99
106
  task.rcov = true
100
107
  task.rspec_opts = "-Ifoo"
101
- spec_command.should_not =~ /-Ifoo/
108
+ spec_command.should =~ /this.rb that.rb -- -Ifoo/
102
109
  end
103
110
  end
104
111
  context "with rcov=false (default)" do
@@ -123,5 +130,19 @@ module RSpec::Core
123
130
  end
124
131
  end
125
132
 
133
+ context "with SPEC=path/to/file" do
134
+ before do
135
+ @orig_spec = ENV["SPEC"]
136
+ ENV["SPEC"] = "path/to/file"
137
+ end
138
+
139
+ after do
140
+ ENV["SPEC"] = @orig_spec
141
+ end
142
+
143
+ it "sets files to run" do
144
+ task.__send__(:files_to_run).should eq(["path/to/file"])
145
+ end
146
+ end
126
147
  end
127
148
  end
@@ -23,18 +23,6 @@ class NullObject
23
23
  end
24
24
  end
25
25
 
26
- module RSpec::Core
27
- class SandboxedExampleGroup < ExampleGroup
28
- def self.run(reporter=nil)
29
- @orig_mock_space = RSpec::Mocks::space
30
- RSpec::Mocks::space = RSpec::Mocks::Space.new
31
- super(reporter || NullObject.new)
32
- ensure
33
- RSpec::Mocks::space = @orig_mock_space
34
- end
35
- end
36
- end
37
-
38
26
  def sandboxed(&block)
39
27
  begin
40
28
  @orig_config = RSpec.configuration
@@ -48,13 +36,25 @@ def sandboxed(&block)
48
36
  object.extend(RSpec::Core::ObjectExtensions)
49
37
  object.extend(RSpec::Core::SharedExampleGroup)
50
38
 
51
- @orig_example_group_class = RSpec::Core::const_get(:ExampleGroup)
52
- RSpec::Core::__send__ :remove_const, :ExampleGroup
53
- RSpec::Core::const_set(:ExampleGroup, RSpec::Core::SandboxedExampleGroup)
39
+ (class << RSpec::Core::ExampleGroup; self; end).class_eval do
40
+ alias_method :orig_run, :run
41
+ def run(reporter=nil)
42
+ @orig_mock_space = RSpec::Mocks::space
43
+ RSpec::Mocks::space = RSpec::Mocks::Space.new
44
+ orig_run(reporter || NullObject.new)
45
+ ensure
46
+ RSpec::Mocks::space = @orig_mock_space
47
+ end
48
+ end
49
+
54
50
  object.instance_eval(&block)
55
51
  ensure
56
- RSpec::Core::__send__ :remove_const, :ExampleGroup
57
- RSpec::Core::const_set(:ExampleGroup, @orig_example_group_class)
52
+ (class << RSpec::Core::ExampleGroup; self; end).class_eval do
53
+ remove_method :run
54
+ alias_method :run, :orig_run
55
+ remove_method :orig_run
56
+ end
57
+
58
58
  RSpec.instance_variable_set(:@configuration, @orig_config)
59
59
  RSpec.instance_variable_set(:@world, @orig_world)
60
60
  end
@@ -34,12 +34,11 @@ end
34
34
  watch('^spec/(.*)_spec\.rb') { |m| run_spec_matching(m[1]) }
35
35
  watch('^lib/(.*)\.rb') { |m| run_spec_matching(m[1]) }
36
36
  watch('^spec/spec_helper\.rb') { run_all_specs }
37
- watch('^spec/support/.*\.rb') { run_all_specs }
37
+ watch('^spec/support/.*\.rb') { run_all_specs }
38
38
 
39
39
  # --------------------------------------------------
40
40
  # Signal Handling
41
41
  # --------------------------------------------------
42
-
43
42
  def no_int_for_you
44
43
  @sent_an_int = nil
45
44
  end
metadata CHANGED
@@ -1,14 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-core
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7712058
5
- prerelease: true
4
+ prerelease: false
6
5
  segments:
7
6
  - 2
8
7
  - 0
9
8
  - 0
10
- - rc
11
- version: 2.0.0.rc
9
+ version: 2.0.0
12
10
  platform: ruby
13
11
  authors:
14
12
  - Chad Humphries
@@ -17,133 +15,123 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2010-10-04 00:00:00 -05:00
18
+ date: 2010-10-10 00:00:00 -05:00
21
19
  default_executable: rspec
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: rspec-expectations
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 7712058
30
28
  segments:
31
29
  - 2
32
30
  - 0
33
31
  - 0
34
- - rc
35
- version: 2.0.0.rc
36
- requirement: *id001
32
+ version: 2.0.0
37
33
  type: :development
38
- name: rspec-expectations
39
34
  prerelease: false
35
+ version_requirements: *id001
40
36
  - !ruby/object:Gem::Dependency
41
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ name: rspec-mocks
38
+ requirement: &id002 !ruby/object:Gem::Requirement
42
39
  none: false
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
- hash: 7712058
47
43
  segments:
48
44
  - 2
49
45
  - 0
50
46
  - 0
51
- - rc
52
- version: 2.0.0.rc
53
- requirement: *id002
47
+ version: 2.0.0
54
48
  type: :development
55
- name: rspec-mocks
56
49
  prerelease: false
50
+ version_requirements: *id002
57
51
  - !ruby/object:Gem::Dependency
58
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ name: cucumber
53
+ requirement: &id003 !ruby/object:Gem::Requirement
59
54
  none: false
60
55
  requirements:
61
56
  - - ">="
62
57
  - !ruby/object:Gem::Version
63
- hash: 13
64
58
  segments:
65
59
  - 0
66
60
  - 5
67
61
  - 3
68
62
  version: 0.5.3
69
- requirement: *id003
70
63
  type: :development
71
- name: cucumber
72
64
  prerelease: false
65
+ version_requirements: *id003
73
66
  - !ruby/object:Gem::Dependency
74
- version_requirements: &id004 !ruby/object:Gem::Requirement
67
+ name: autotest
68
+ requirement: &id004 !ruby/object:Gem::Requirement
75
69
  none: false
76
70
  requirements:
77
71
  - - ">="
78
72
  - !ruby/object:Gem::Version
79
- hash: 37
80
73
  segments:
81
74
  - 4
82
75
  - 2
83
76
  - 9
84
77
  version: 4.2.9
85
- requirement: *id004
86
78
  type: :development
87
- name: autotest
88
79
  prerelease: false
80
+ version_requirements: *id004
89
81
  - !ruby/object:Gem::Dependency
90
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ name: syntax
83
+ requirement: &id005 !ruby/object:Gem::Requirement
91
84
  none: false
92
85
  requirements:
93
86
  - - ">="
94
87
  - !ruby/object:Gem::Version
95
- hash: 23
96
88
  segments:
97
89
  - 1
98
90
  - 0
99
91
  - 0
100
92
  version: 1.0.0
101
- requirement: *id005
102
93
  type: :development
103
- name: syntax
104
94
  prerelease: false
95
+ version_requirements: *id005
105
96
  - !ruby/object:Gem::Dependency
106
- version_requirements: &id006 !ruby/object:Gem::Requirement
97
+ name: flexmock
98
+ requirement: &id006 !ruby/object:Gem::Requirement
107
99
  none: false
108
100
  requirements:
109
101
  - - ">="
110
102
  - !ruby/object:Gem::Version
111
- hash: 3
112
103
  segments:
113
104
  - 0
114
105
  version: "0"
115
- requirement: *id006
116
106
  type: :development
117
- name: flexmock
118
107
  prerelease: false
108
+ version_requirements: *id006
119
109
  - !ruby/object:Gem::Dependency
120
- version_requirements: &id007 !ruby/object:Gem::Requirement
110
+ name: mocha
111
+ requirement: &id007 !ruby/object:Gem::Requirement
121
112
  none: false
122
113
  requirements:
123
114
  - - ">="
124
115
  - !ruby/object:Gem::Version
125
- hash: 3
126
116
  segments:
127
117
  - 0
128
118
  version: "0"
129
- requirement: *id007
130
119
  type: :development
131
- name: mocha
132
120
  prerelease: false
121
+ version_requirements: *id007
133
122
  - !ruby/object:Gem::Dependency
134
- version_requirements: &id008 !ruby/object:Gem::Requirement
123
+ name: rr
124
+ requirement: &id008 !ruby/object:Gem::Requirement
135
125
  none: false
136
126
  requirements:
137
127
  - - ">="
138
128
  - !ruby/object:Gem::Version
139
- hash: 3
140
129
  segments:
141
130
  - 0
142
131
  version: "0"
143
- requirement: *id008
144
132
  type: :development
145
- name: rr
146
133
  prerelease: false
134
+ version_requirements: *id008
147
135
  description: RSpec runner and example groups
148
136
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
149
137
  executables:
@@ -183,8 +171,8 @@ files:
183
171
  - features/formatters/custom_formatter.feature
184
172
  - features/hooks/around_hooks.feature
185
173
  - features/hooks/before_and_after_hooks.feature
186
- - features/hooks/described_class.feature
187
174
  - features/hooks/halt.feature
175
+ - features/metadata/described_class.feature
188
176
  - features/mock_framework_integration/use_flexmock.feature
189
177
  - features/mock_framework_integration/use_mocha.feature
190
178
  - features/mock_framework_integration/use_rr.feature
@@ -305,7 +293,7 @@ licenses: []
305
293
  post_install_message: |
306
294
  **************************************************
307
295
 
308
- Thank you for installing rspec-core-2.0.0.rc
296
+ Thank you for installing rspec-core-2.0.0
309
297
 
310
298
  Please be sure to look at Upgrade.markdown to see what might have changed
311
299
  since the last release.
@@ -321,28 +309,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
321
309
  requirements:
322
310
  - - ">="
323
311
  - !ruby/object:Gem::Version
324
- hash: 3
312
+ hash: -3850690917648988866
325
313
  segments:
326
314
  - 0
327
315
  version: "0"
328
316
  required_rubygems_version: !ruby/object:Gem::Requirement
329
317
  none: false
330
318
  requirements:
331
- - - ">"
319
+ - - ">="
332
320
  - !ruby/object:Gem::Version
333
- hash: 25
321
+ hash: -3850690917648988866
334
322
  segments:
335
- - 1
336
- - 3
337
- - 1
338
- version: 1.3.1
323
+ - 0
324
+ version: "0"
339
325
  requirements: []
340
326
 
341
327
  rubyforge_project: rspec
342
328
  rubygems_version: 1.3.7
343
329
  signing_key:
344
330
  specification_version: 3
345
- summary: rspec-core-2.0.0.rc
331
+ summary: rspec-core-2.0.0
346
332
  test_files:
347
333
  - features/README.markdown
348
334
  - features/command_line/configure.feature
@@ -362,8 +348,8 @@ test_files:
362
348
  - features/formatters/custom_formatter.feature
363
349
  - features/hooks/around_hooks.feature
364
350
  - features/hooks/before_and_after_hooks.feature
365
- - features/hooks/described_class.feature
366
351
  - features/hooks/halt.feature
352
+ - features/metadata/described_class.feature
367
353
  - features/mock_framework_integration/use_flexmock.feature
368
354
  - features/mock_framework_integration/use_mocha.feature
369
355
  - features/mock_framework_integration/use_rr.feature