Created
November 7, 2011 17:02
-
-
Save amacdougall/1345526 to your computer and use it in GitHub Desktop.
Human-friendly context strings
This file contains 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 NewPaperTest < ActiveSupport::TestCase | |
context "setting design_theme along with family" do | |
# see Paperless::Content::Family -- setting design theme should also load | |
# the family from which the theme comes | |
setup do | |
@paper = create_new_paper | |
@paper.design_theme = {:design_theme => "Red", :family => "Flowers"} | |
@paper.save | |
end | |
should "have a design theme" do | |
assert_equal "Red", @paper.design_theme.name | |
end | |
should "have a family" do | |
assert_equal "Flowers", @paper.family.name | |
end | |
should "use existing family" do | |
red_id = @paper.design_theme_id | |
@paper.design_theme = {:design_theme => "Blue", :family => "Flowers"} | |
@paper.design_theme = {:design_theme => "Red", :family => "Flowers"} | |
assert_equal red_id, @paper.design_theme_id | |
end | |
end | |
context "setting the value of #coins" do | |
setup do | |
@paper = NewPaper.new | |
@paper.coins = 150 # valid nonzero coin count | |
end | |
should "interpret nil as 0" do | |
@paper.coins = nil | |
assert_equal 0, @paper.coins | |
end | |
should "interpret numeric string as integer" do | |
@paper.coins = "100" | |
assert_equal 100, @paper.coins | |
end | |
should "interpret empty string as 0" do | |
@paper.coins = "" | |
assert_equal 0, @paper.coins | |
end | |
should "interpret invalid string as 0" do | |
@paper.coins = "one hundred" | |
assert_equal 0, @paper.coins | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment