File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ module ClassMethods
101
101
# hooks.
102
102
def setup ( *methods )
103
103
methods . each do |method |
104
- if method . to_s =~ /^setup_(fixtures|controller_request_and_response)$/
104
+ if method . to_s =~ /^setup_(with_controller| fixtures|controller_request_and_response)$/
105
105
prepend_before { __send__ method }
106
106
else
107
107
before { __send__ method }
Original file line number Diff line number Diff line change @@ -194,6 +194,21 @@ def controller
194
194
allow ( view_spec ) . to receive ( :_view ) { view }
195
195
expect ( view_spec . view ) . to eq ( view )
196
196
end
197
+
198
+ it 'is accessible to hooks' do
199
+ with_isolated_config do
200
+ run_count = 0
201
+ RSpec . configuration . before ( :each , :type => :view ) do
202
+ allow ( view ) . to receive ( :a_stubbed_helper ) { :value }
203
+ run_count += 1
204
+ end
205
+ group = RSpec ::Core ::ExampleGroup . describe 'a view' , :type => :view do
206
+ specify { true }
207
+ end
208
+ group . run NullObject . new
209
+ expect ( run_count ) . to eq 1
210
+ end
211
+ end
197
212
end
198
213
199
214
describe "#template" do
Original file line number Diff line number Diff line change 2
2
3
3
module RSpecRails
4
4
class Application < ::Rails ::Application
5
+ self . config . secret_key_base = 'ASecretString' if config . respond_to? :secret_key_base
5
6
end
6
7
end
7
8
Original file line number Diff line number Diff line change @@ -16,5 +16,19 @@ def metadata_with(additional_metadata)
16
16
m
17
17
end
18
18
19
+ def with_isolated_config
20
+ original_config = RSpec . configuration
21
+ RSpec . configuration = RSpec ::Core ::Configuration . new
22
+ RSpec . configure do |c |
23
+ c . include RSpec ::Rails ::FixtureSupport
24
+ c . add_setting :use_transactional_fixtures , :alias_with => :use_transactional_examples
25
+ c . add_setting :use_instantiated_fixtures
26
+ c . add_setting :global_fixtures
27
+ c . add_setting :fixture_path
28
+ end
29
+ yield
30
+ RSpec . configuration = original_config
31
+ end
32
+
19
33
RSpec . configure { |c | c . include self }
20
34
end
You can’t perform that action at this time.
0 commit comments