spec/authority/abilities_spec.rb in authority-3.0.0 vs spec/authority/abilities_spec.rb in authority-3.1.0

- old
+ new

@@ -69,17 +69,17 @@ describe "authorizer" do it "constantizes the authorizer name as the authorizer" do resource_class.instance_variable_set(:@authorizer, nil) - resource_class.authorizer_name.should_receive(:constantize) + expect(resource_class.authorizer_name).to receive(:constantize) resource_class.authorizer end it "memoizes the authorizer to avoid reconstantizing" do resource_class.authorizer - resource_class.authorizer_name.should_not_receive(:constantize) + expect(resource_class.authorizer_name).not_to receive(:constantize) resource_class.authorizer end it "raises a friendly error if the authorizer doesn't exist" do class NoAuthorizerModel < resource_class; end ; @@ -104,20 +104,20 @@ describe "#{method_name}" do context "when given an options hash" do it "delegates `#{method_name}` to its authorizer class, passing the options" do - resource_class.authorizer.should_receive(method_name).with(user, :lacking => 'nothing') + expect(resource_class.authorizer).to receive(method_name).with(user, :lacking => 'nothing') resource_class.send(method_name, user, :lacking => 'nothing') end end context "when not given an options hash" do it "delegates `#{method_name}` to its authorizer class, passing no options" do - resource_class.authorizer.should_receive(method_name).with(user) + expect(resource_class.authorizer).to receive(method_name).with(user) resource_class.send(method_name, user) end end @@ -145,22 +145,22 @@ describe "#{method_name}" do context "when given an options hash" do it "delegates `#{method_name}` to a new authorizer instance, passing the options" do - resource_class.authorizer.stub(:new).and_return(@authorizer) - @authorizer.should_receive(method_name).with(user, :with => 'mayo') + allow(resource_class.authorizer).to receive(:new).and_return(@authorizer) + expect(@authorizer).to receive(method_name).with(user, :with => 'mayo') resource_instance.send(method_name, user, :with => 'mayo') end end context "when not given an options hash" do it "delegates `#{method_name}` to a new authorizer instance, passing no options" do - resource_class.authorizer.stub(:new).and_return(@authorizer) - @authorizer.should_receive(method_name).with(user) + allow(resource_class.authorizer).to receive(:new).and_return(@authorizer) + expect(@authorizer).to receive(method_name).with(user) resource_instance.send(method_name, user) end end @@ -174,10 +174,10 @@ # When checking instance methods, we want to ensure that every check uses a new # instance of the authorizer. Otherwise, you might check, make a change to the # model instance, check again, and get an outdated answer. it "always creates a new authorizer instance when accessing the authorizer" do - resource_instance.class.authorizer.should_receive(:new).with(resource_instance).twice + expect(resource_instance.class.authorizer).to receive(:new).with(resource_instance).twice 2.times { resource_instance.authorizer } end end