Created
November 9, 2008 05:52
-
-
Save freireag/23205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class ProductTest < ActiveSupport::TestCase | |
context "given an existing product" do | |
fixtures :all | |
should_have_db_columns :id, :name, :description, :price, :quantity | |
should_have_db_column :name, :type => "string", :null => false | |
should_have_db_column :price, :type => "decimal", :null => false, :scale => 2 | |
should_have_db_column :quantity, :type => "integer", :default => 0, :null => false | |
should_have_instance_methods :name, :name=, :description, :description=, :price, :price=, :quantity, :quantity= | |
should_not_allow_values_for :price, -1, 0 | |
should_not_allow_values_for :quantity, -1, 1.3 | |
should_allow_values_for :quantity, 0 | |
should_only_allow_numeric_values_for :price | |
should_only_allow_numeric_values_for :quantity | |
should_require_attributes :name, :price, :quantity | |
should_require_unique_attributes :name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment