Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Created October 4, 2012 23:39
Show Gist options
  • Save patrick99e99/af0a33b4f7dfe7bb3361 to your computer and use it in GitHub Desktop.
Save patrick99e99/af0a33b4f7dfe7bb3361 to your computer and use it in GitHub Desktop.
# from the context of within an rspec test:
mock_it { render :text => "hello" }
def mock_it(&block)
ApplicationController.class_eval do
define_method mocked_method do
return block.call if block_given?
end
end
end
==> undefined method `render' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2:0x00000103ad1318>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment