spec/tokens_spec.rb in tokens-0.2.1 vs spec/tokens_spec.rb in tokens-1.0.0

- old
+ new

@@ -35,31 +35,31 @@ User.generate_token(8).size.should == 8 end it "should alias token method" do token = @user.add_token(:uid) - token.hash.should == token.token + token.to_s.should == token.token end it "should find user by token" do token = @user.add_token(:uid) - User.find_by_token(:uid, token.hash).should == @user + User.find_by_token(:uid, token.to_s).should == @user end it "should return user by its valid token without expiration time" do token = @user.add_token(:uid) - User.find_by_valid_token(:uid, token.hash).should == @user + User.find_by_valid_token(:uid, token.to_s).should == @user end it "should return user by its valid token with expiration time" do token = @user.add_token(:uid, :expires_at => @expire) - User.find_by_valid_token(:uid, token.hash).should == @user + User.find_by_valid_token(:uid, token.to_s).should == @user end it "should find token using class method with one argument (hash only)" do token = @user.add_token(:uid) - User.find_token(:name => :uid, :token => token.hash).should == token + User.find_token(:name => :uid, :token => token.to_s).should == token end it "should not conflict with other models" do user_token = @user.add_token(:uid) post_token = @post.add_token(:uid) @@ -68,11 +68,11 @@ User.find_token(:name => :uid) end it "to_s should return hash" do token = @user.add_token(:uid) - token.to_s.should == token.hash + token.to_s.should == token.to_s end describe Token do it "should be created" do expect { @user.add_token(:uid) }.to change(Token, :count) @@ -96,11 +96,11 @@ token.reload token.data.should == {:name => "John Doe"} end it "should be created with custom size" do - @user.add_token(:uid, :size => 6).hash.size.should == 6 + @user.add_token(:uid, :size => 6).to_s.size.should == 6 end it "should find token by its name" do token = @user.add_token(:uid) @user.find_token_by_name(:uid).should == token @@ -111,19 +111,19 @@ @user.find_token_by_name(:uid).should be_nil end it "should be a valid token" do token = @user.add_token(:uid) - @user.valid_token?(:uid, token.hash).should be_true + @user.valid_token?(:uid, token.to_s).should be_true end it "should not be a valid token" do @user.valid_token?(:uid, "invalid").should be_false end it "should find token by its name and hash" do token = @user.add_token(:uid) - @user.find_token(:uid, token.hash).should == token + @user.find_token(:uid, token.to_s).should == token end it "should not be expired when have no expiration date" do @user.add_token(:uid).should_not be_expired end