Sha256: 1d0edcfafbcc0e9d5e89525a184557af04c69a3c04d1947ec8b4f72fa91e3a54

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

require 'spec_helper'

class LikeSpec < MiniTest::Spec
  describe Recommendable::Like do
    before :each do
      @user = User.create(:username => "dave")
    end
    
    it "should not be created for an object that does not act_as_recommendedable" do
      cake = PhpFramework.create(:name => "CakePHP")
      proc { @user.like(cake) }.must_raise Recommendable::UnrecommendableError
    end
    
    it "should be created for an object that does act_as_recommendable" do
      movie = Movie.create(:title => "2001: A Space Odyssey", :year => 1968)
      
      @user.like(movie).must_equal true
    end
    
    it "should not be created twice for the same user-object pair" do
      movie = Movie.create(:title => "2001: A Space Odyssey", :year => 1968)
      
      @user.like(movie).must_equal true
      @user.like(movie).must_be_nil
      Recommendable::Like.count.must_equal 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recommendable-1.1.3 spec/models/like_spec.rb
recommendable-1.1.2 spec/models/like_spec.rb
recommendable-1.1.1 spec/models/like_spec.rb