spec/unit/devise_spec.rb in activeadmin-0.6.6 vs spec/unit/devise_spec.rb in activeadmin-1.0.0.pre1

- old
+ new

@@ -1,6 +1,6 @@ -require 'spec_helper' +require 'rails_helper' describe ActiveAdmin::Devise::Controller do let(:controller_class) do klass = Class.new do @@ -16,31 +16,31 @@ context 'with a RAILS_RELATIVE_URL_ROOT set' do before { Rails.configuration.action_controller[:relative_url_root] = '/foo' } it "should set the root path to the default namespace" do - controller.root_path.should == "/foo/admin" + expect(controller.root_path).to eq "/foo/admin" end it "should set the root path to '/' when no default namespace" do - ActiveAdmin.application.stub!(:default_namespace => false) - controller.root_path.should == "/foo/" + allow(ActiveAdmin.application).to receive(:default_namespace).and_return(false) + expect(controller.root_path).to eq "/foo/" end end context 'without a RAILS_RELATIVE_URL_ROOT set' do before { Rails.configuration.action_controller[:relative_url_root] = nil } it "should set the root path to the default namespace" do - controller.root_path.should == "/admin" + expect(controller.root_path).to eq "/admin" end it "should set the root path to '/' when no default namespace" do - ActiveAdmin.application.stub!(:default_namespace => false) - controller.root_path.should == "/" + allow(ActiveAdmin.application).to receive(:default_namespace).and_return(false) + expect(controller.root_path).to eq "/" end end context "within a scoped route" do @@ -52,11 +52,11 @@ routes = Rails.application.routes routes.clear! # Add scoped routes routes.draw do - scope :path => SCOPE do + scope path: SCOPE do ActiveAdmin.routes(self) devise_for :admin_users, ActiveAdmin::Devise.config end end end @@ -65,50 +65,30 @@ # Resume default routes reload_routes! end it "should include scope path in root_path" do - controller.root_path.should == "#{SCOPE}/admin" + expect(controller.root_path).to eq "#{SCOPE}/admin" end end describe "#config" do let(:config) { ActiveAdmin::Devise.config } describe ":sign_out_via option" do + it "should contain the application.logout_link_method" do + expect(::Devise).to receive(:sign_out_via).and_return(:delete) + expect(ActiveAdmin.application).to receive(:logout_link_method).and_return(:get) - subject { config[:sign_out_via] } - - context "when Devise does not implement sign_out_via (version < 1.2)" do - before do - ::Devise.should_receive(:respond_to?).with(:sign_out_via).and_return(false) - end - - it "should not contain any customization for sign_out_via" do - config.should_not have_key(:sign_out_via) - end + expect(config[:sign_out_via]).to include(:get) end - context "when Devise implements sign_out_via (version >= 1.2)" do - before do - ::Devise.should_receive(:respond_to?).with(:sign_out_via).and_return(true) - ::Devise.stub!(:sign_out_via) { :delete } - end + it "should contain Devise's logout_via_method(s)" do + expect(::Devise).to receive(:sign_out_via).and_return([:delete, :post]) + expect(ActiveAdmin.application).to receive(:logout_link_method).and_return(:get) - it "should contain the application.logout_link_method" do - ::Devise.should_receive(:sign_out_via).and_return(:delete) - ActiveAdmin.application.should_receive(:logout_link_method).and_return(:get) - - config[:sign_out_via].should include(:get) - end - - it "should contain Devise's logout_via_method(s)" do - ::Devise.should_receive(:sign_out_via).and_return([:delete, :post]) - ActiveAdmin.application.should_receive(:logout_link_method).and_return(:get) - - config[:sign_out_via].should == [:delete, :post, :get] - end + expect(config[:sign_out_via]).to eq [:delete, :post, :get] end end # describe ":sign_out_via option" end # describe "#config"