spec/unit/controller_extensions_spec.rb in loaf-0.5.0 vs spec/unit/controller_extensions_spec.rb in loaf-0.6.0

- old
+ new

@@ -1,34 +1,25 @@ # encoding: utf-8 -require 'spec_helper' - -class DummyController < ActionController::Base - def self.before_filter(options, &block) - yield self.new - end - include Loaf::ControllerExtensions -end - RSpec.describe Loaf::ControllerExtensions do context 'when classes extend controller_extensions' do it { expect(DummyController).to respond_to(:add_breadcrumb) } it { expect(DummyController).to respond_to(:breadcrumb) } it { expect(DummyController.new).to respond_to(:add_breadcrumb) } it { expect(DummyController.new).to respond_to(:breadcrumb) } - it { expect(DummyController.new).to respond_to(:add_breadcrumbs) } it { expect(DummyController.new).to respond_to(:clear_breadcrumbs) } end context 'class methods' do - it 'invokes before_filter' do - allow(DummyController).to receive(:before_filter) + it 'invokes before_action' do + allow(DummyController).to receive(:before_action) + allow(DummyController).to receive(:respond_to?).and_return(true) DummyController.breadcrumb('name', 'url_path') - expect(DummyController).to have_received(:before_filter) + expect(DummyController).to have_received(:before_action) end - it 'delegates to instance' do + it 'delegates breadcrumb registration to controller instance' do name = 'List objects' url = :object_path options = {force: true} instance = double(:controller_instance).as_null_object