spec/authority/abilities_spec.rb in authority-1.1.0 vs spec/authority/abilities_spec.rb in authority-2.0.0

- old
+ new

@@ -1,8 +1,7 @@ require 'spec_helper' require 'support/ability_model' -require 'support/no_authorizer_model' require 'support/user' describe Authority::Abilities do before :each do @@ -17,12 +16,12 @@ it "should have a class attribute setter for authorizer_name" do AbilityModel.should respond_to(:authorizer_name=) end - it "should have a default authorizer_name of '(ClassName)Authorizer'" do - AbilityModel.authorizer_name.should eq("AbilityModelAuthorizer") + it "should have a default authorizer_name of 'ApplicationAuthorizer'" do + AbilityModel.authorizer_name.should eq("ApplicationAuthorizer") end it "should constantize the authorizer name as the authorizer" do AbilityModel.instance_variable_set(:@authorizer, nil) AbilityModel.authorizer_name.should_receive(:constantize) @@ -34,10 +33,17 @@ AbilityModel.authorizer_name.should_not_receive(:constantize) AbilityModel.authorizer end it "should raise a friendly error if the authorizer doesn't exist" do - expect { NoAuthorizerModel.authorizer }.to raise_error(Authority::NoAuthorizerError) + AbilityModel.instance_variable_set(:@authorizer, nil) + AbilityModel.authorizer_name = 'NonExistentAuthorizer' + expect { AbilityModel.authorizer }.to raise_error(Authority::NoAuthorizerError) + + # Cleanup to prevent affecting other tests + # TODO: Clean up this cleanup code. :) + AbilityModel.instance_variable_set(:@authorizer, nil) + AbilityModel.authorizer_name = 'ApplicationAuthorizer' end end describe "class methods" do