Permalink
Browse files

Merge #833 into master

  • Loading branch information...
1 parent eb3e8e5 commit 2dd9640377d9aa11ee2d5c093c09c06955ad9117 @JonRowe JonRowe committed Dec 12, 2013
Showing with 30 additions and 1 deletion.
  1. +1 −1 lib/rspec/rails/adapters.rb
  2. +15 −0 spec/rspec/rails/example/view_example_group_spec.rb
  3. +14 −0 spec/support/helpers.rb
View
2 lib/rspec/rails/adapters.rb
@@ -99,7 +99,7 @@ module ClassMethods
# hooks.
def setup(*methods)
methods.each do |method|
- if method.to_s =~ /^setup_(fixtures|controller_request_and_response)$/
+ if method.to_s =~ /^setup_(with_controller|fixtures|controller_request_and_response)$/
prepend_before { __send__ method }
else
before { __send__ method }
View
15 spec/rspec/rails/example/view_example_group_spec.rb
@@ -194,6 +194,21 @@ def controller
allow(view_spec).to receive(:_view) { view }
expect(view_spec.view).to eq(view)
end
+
+ it 'is accessible to hooks' do
+ with_isolated_config do
+ run_count = 0
+ RSpec.configuration.before(:each, :type => :view) do
+ allow(view).to receive(:a_stubbed_helper) { :value }
+ run_count += 1
+ end
+ group = RSpec::Core::ExampleGroup.describe 'a view', :type => :view do
+ specify { true }
+ end
+ group.run NullObject.new
+ expect(run_count).to eq 1
+ end
+ end
end
describe "#template" do
View
14 spec/support/helpers.rb
@@ -16,5 +16,19 @@ def metadata_with(additional_metadata)
m
end
+ def with_isolated_config
+ original_config = RSpec.configuration
+ RSpec.configuration = RSpec::Core::Configuration.new
+ RSpec.configure do |c|
+ c.include RSpec::Rails::FixtureSupport
+ c.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
+ c.add_setting :use_instantiated_fixtures
+ c.add_setting :global_fixtures
+ c.add_setting :fixture_path
+ end
+ yield
+ RSpec.configuration = original_config
+ end
+
RSpec.configure {|c| c.include self}
end

0 comments on commit 2dd9640

Please sign in to comment.