Sha256: e55cf11de2ace2e964a878631afceb529bcfd6a7f9a4a1e32f764a987664bf6c

Contents?: true

Size: 910 Bytes

Versions: 8

Compression:

Stored size: 910 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::RecordNotRecommendableError
    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

8 entries across 8 versions & 1 rubygems

Version Path
recommendable-1.0.0 spec/models/like_spec.rb
recommendable-0.2.1.1 spec/models/like_spec.rb
recommendable-0.1.8 spec/models/like_spec.rb
recommendable-0.1.6 spec/models/like_spec.rb
recommendable-0.1.5 spec/models/like_spec.rb
recommendable-0.1.4 spec/models/like_spec.rb
recommendable-0.1.3 spec/models/like_spec.rb
recommendable-0.1.2 spec/models/like_spec.rb