Sha256: fbd799159c589e633d4c2f9860cb03cabbf3eedaaf07e938384b9ca0e396267a

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

class RatingValueByDefaultTest < ActiveRecord::TestCase
  def setup
    @rating_value = RatingValue.new
  end
  
  def test_should_not_have_a_name
    assert @rating_value.name.blank?
  end
  
  def test_should_not_have_a_value
    assert_nil @rating_value.value
  end
end

class RatingValueTest < ActiveRecord::TestCase
  def test_should_be_valid_with_a_valid_set_of_attributes
    rating_value = new_rating_value
    assert rating_value.valid?
  end
  
  def test_should_require_a_name
    rating_value = new_rating_value(:name => nil)
    assert !rating_value.valid?
    assert rating_value.errors.invalid?(:name)
  end
  
  def test_should_require_a_value
    rating_value = new_rating_value(:value => nil)
    assert !rating_value.valid?
    assert rating_value.errors.invalid?(:value)
  end
  
  def test_should_convert_to_an_integer
    rating_value = new_rating_value(:value => 1)
    assert_equal 1, rating_value.to_i
  end
end

class RatingValueAfterBeingCreatedTest < ActiveRecord::TestCase
  def setup
    @rating_value = create_rating_value
  end
  
  def test_should_not_have_any_ratings
    assert @rating_value.ratings.empty?
  end
end

class RatingValueWithRatingsTest < ActiveRecord::TestCase
  def setup
    @rating_value = create_rating_value
    @poor_rating = create_rating(:value => @rating_value)
    @second_poor_rating = create_rating(:value => @rating_value)
  end
  
  def test_should_have_ratings
    assert_equal [@poor_rating, @second_poor_rating], @rating_value.ratings
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
pluginaweek-has_ratings-0.3.0 test/unit/rating_value_test.rb
has_ratings-0.3.1 test/unit/rating_value_test.rb
has_ratings-0.3.0 test/unit/rating_value_test.rb