Skip to content

Merge pull request #833 from rspec/verify_views_are_accessible_to_hooks #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rspec/rails/adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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 }
Expand Down
15 changes: 15 additions & 0 deletions spec/rspec/rails/example/view_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ def controller
view_spec.stub(:_view) { view }
view_spec.view.should == 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
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module RSpecRails
class Application < ::Rails::Application
self.config.secret_key_base = 'ASecretString' if config.respond_to? :secret_key_base
end
end

Expand Down
14 changes: 14 additions & 0 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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