spec/castronaut/adapters/restful_authentication/user_spec.rb in relevance-castronaut-0.3.6 vs spec/castronaut/adapters/restful_authentication/user_spec.rb in relevance-castronaut-0.4.1

- old
+ new

@@ -32,10 +32,15 @@ it "returns nil if no user is found with the given login" do Castronaut::Adapters::RestfulAuthentication::User.stub!(:find).and_return(nil) Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob').should be_nil end + + it "returns the user found with the given login" do + Castronaut::Adapters::RestfulAuthentication::User.stub!(:find).and_return(user = stub('user')) + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob').should == user + end describe "when the config has extra authentication conditions" do before do Castronaut.config.cas_adapter['extra_authentication_conditions'] = '1=2' @@ -45,14 +50,17 @@ Castronaut.config.cas_adapter.has_key?('extra_authentication_conditions').should be_true Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob') end it "attempts to find the user with the extra authentication conditions" do - Castronaut::Adapters::RestfulAuthentication::User.should_receive(:find).and_return(stub('user'), nil) - + Castronaut::Adapters::RestfulAuthentication::User.should_receive(:find).with(:first, :conditions => ["login = ? AND 1=2", 'bob']) Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob') end - + + it "returns the user found with the given login" do + Castronaut::Adapters::RestfulAuthentication::User.stub!(:find).and_return(user = stub('user')) + Castronaut::Adapters::RestfulAuthentication::User.find_by_login('bob').should == user + end end end describe "authenticate" do