Sha256: 1b9d274763ce882a7568ef6d882b2f4237548104232c64544e8ab99ff0a16b58

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

$LOAD_PATH.unshift File.expand_path('../../test', __FILE__)
require 'test_helper'

class RaterTest < Minitest::Test
  def setup
    @user = Factory(:user)
  end

  def test_that_it_belongs_to_recommendables_user_class
    assert_instance_of Recommendable.config.user_class, @user
  end

  def test_that_its_class_responds_to_recommendable_hooks
    %w[like dislike hide bookmark].each do |action|
      assert_respond_to @user.class, "before_#{action}"
      assert_respond_to @user.class, "before_un#{action}"
      assert_respond_to @user.class, "after_#{action}"
      assert_respond_to @user.class, "after_un#{action}"
    end
  end

  def test_that_rated_anything_is_false_by_default
    refute @user.rated_anything?
  end

  def test_that_unrate_removes_any_rating
    @movie = Factory(:movie)
    %w[like dislike hide bookmark].each do |action|
      @user.send(action, @movie)
      assert @user.send("#{action.pluralize}?", @movie)

      @user.unrate(@movie)
      refute @user.send("#{action.pluralize}?", @movie)
    end
  end

  def teardown
    Recommendable.redis.flushdb
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
recommendable-2.2.2 test/recommendable/rater_test.rb
recommendable-2.2.1 test/recommendable/rater_test.rb