Skip to content

Instantly share code, notes, and snippets.

@caulfield
Last active August 29, 2015 14:15
Show Gist options
  • Save caulfield/36b4ba1902f45cc54d5b to your computer and use it in GitHub Desktop.
Save caulfield/36b4ba1902f45cc54d5b to your computer and use it in GitHub Desktop.
Action controller callbacks rspec matchers
RSpec::Matchers.define :use_before_action do |expected|
# @example
# expect { get :index }.to use_before_action(:authenticate_user!)
match do |actual|
expect(controller).to receive(expected).and_call_original
instance_exec &actual
described_class._process_action_callbacks.find do |callback|
callback.filter == expected
end.kind == :before
end
supports_block_expectations
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment