Last active
August 29, 2015 14:15
-
-
Save caulfield/36b4ba1902f45cc54d5b to your computer and use it in GitHub Desktop.
Action controller callbacks rspec matchers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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