spec/authority_spec.rb in authority-3.0.0 vs spec/authority_spec.rb in authority-3.1.0
- old
+ new
@@ -30,13 +30,28 @@
it "has a `configure` method" do
expect(Authority).to respond_to(:configure)
end
it "requires the remainder of library internals after configuration" do
- Authority.should_receive(:require_authority_internals!)
+ expect(Authority).to receive(:require_authority_internals!)
Authority.configure
end
+
+ it "allows changing the logger" do
+ starting_config = Authority.configuration
+ logger1 = Object.new
+ logger2 = Object.new
+ config = Authority::Configuration.new
+ Authority.configuration = config
+
+ config.logger = logger1
+ expect(Authority.logger).to eq(logger1)
+
+ config.logger = logger2
+ expect(Authority.logger).to eq(logger2)
+ Authority.configuration = starting_config
+ end
end
describe "enforcement" do
let(:resource_class) { ExampleResource }
@@ -47,19 +62,19 @@
describe "when given options" do
it "checks the user's authorization, passing along the options" do
options = { :for => 'context' }
- user.should_receive(:can_delete?).with(resource_class, options).and_return(true)
+ expect(user).to receive(:can_delete?).with(resource_class, options).and_return(true)
Authority.enforce(:delete, resource_class, user, options)
end
end
describe "when not given options" do
it "checks the user's authorization, passing no options" do
- user.should_receive(:can_delete?).with(resource_class).and_return(true)
+ expect(user).to receive(:can_delete?).with(resource_class).and_return(true)
Authority.enforce(:delete, resource_class, user)
end
end