spec/unit/resource_controller/sidebars_spec.rb in yousty-activeadmin-1.0.4.pre vs spec/unit/resource_controller/sidebars_spec.rb in yousty-activeadmin-1.0.5.pre

- old
+ new

@@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' describe ActiveAdmin::ResourceController::Sidebars do let(:controller){ Admin::PostsController } context 'without before_filter' do @@ -8,11 +8,11 @@ ActiveAdmin.register Post end subject { find_before_filter controller, :skip_sidebar! } - it { should set_skip_sidebar_to nil } + it { is_expected.to set_skip_sidebar_to nil, for: controller } end describe '#skip_sidebar!' do before do ActiveAdmin.register Post do @@ -20,27 +20,26 @@ end end subject { find_before_filter controller, :skip_sidebar! } - it { should set_skip_sidebar_to true } + it { is_expected.to set_skip_sidebar_to true, for: controller } end def find_before_filter(controller, filter) #raise controller._process_action_callbacks.map(&:filter).inspect controller._process_action_callbacks.detect { |f| f.raw_filter == filter.to_sym } end - RSpec::Matchers.define :set_skip_sidebar_to do |expected| + RSpec::Matchers.define :set_skip_sidebar_to do |expected, options| match do |filter| - klass = filter && filter.klass || controller - object = klass.new + object = options[:for].new object.send filter.raw_filter if filter @actual = object.instance_variable_get(:@skip_sidebar) - @actual == expected + expect(@actual).to eq expected end - failure_message_for_should do |filter| + failure_message do |filter| message = "expected before_filter to set @skip_sidebar to '#{expected}', but was '#{@actual}'" end end end