This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ ### Development
2
+
3
+ Bug Fixes:
4
+
5
+ * Correctly run ` before(:suite) ` (and friends) in the context of an example
6
+ group instance, thus making the expected RSpec environment available.
7
+ (Jon Rowe, #1986 )
8
+
1
9
### 3.3.0 / 2015-06-12
2
10
[ Full Changelog] ( http://github.com/rspec/rspec-core/compare/v3.2.3...v3.3.0 )
3
11
Original file line number Diff line number Diff line change @@ -558,6 +558,7 @@ def issue_deprecation(_method_name, *_args)
558
558
class SuiteHookContext < Example
559
559
def initialize
560
560
super ( AnonymousExampleGroup , "" , { } )
561
+ @example_group_instance = AnonymousExampleGroup . new
561
562
end
562
563
563
564
# rubocop:disable Style/AccessorMethodName
Original file line number Diff line number Diff line change @@ -23,6 +23,30 @@ module RSpec::Core
23
23
} . to raise_error ( ZeroDivisionError )
24
24
end
25
25
26
+ it 'runs in the context of an example group' do
27
+ run_context = nil
28
+ RSpec . configuration . __send__ ( registration_method , :suite ) { run_context = self }
29
+ RSpec . configuration . with_suite_hooks { }
30
+ expect ( run_context ) . to be_a ExampleGroup
31
+ end
32
+
33
+ it 'allows access to rspec-mocks methods within the hook' do
34
+ run = false
35
+ RSpec . configuration . __send__ ( registration_method , :suite ) do
36
+ RSpec ::Mocks . with_temporary_scope { double ( 'something' ) }
37
+ run = true
38
+ end
39
+ RSpec . configuration . with_suite_hooks { }
40
+ expect ( run ) . to be true
41
+ end
42
+
43
+ it 'allows access to rspec-expectation methods within the hook' do
44
+ RSpec . configuration . __send__ ( registration_method , :suite ) { expect ( true ) . to be false }
45
+ expect {
46
+ RSpec . configuration . with_suite_hooks { }
47
+ } . to raise_error RSpec ::Expectations ::ExpectationNotMetError
48
+ end
49
+
26
50
context "registered on an example group" do
27
51
it "is ignored with a clear warning" do
28
52
sequence = [ ]
You can’t perform that action at this time.
0 commit comments