Created
September 5, 2009 21:58
-
-
Save nakajima/181530 to your computer and use it in GitHub Desktop.
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 'acts_as_fu' | |
build_model(:people) do | |
string :age | |
named_scope :minors, :conditions => ['age < ?', 18] | |
end |
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
[~] ruby named-scope-fu.rb | |
Loaded suite named-scope-fu | |
Started | |
.. | |
Finished in 0.009923 seconds. | |
2 tests, 2 assertions, 0 failures, 0 errors |
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/unit' | |
class ActsAsFuNamedScopeTest < Test::Unit::TestCase | |
def test_includes_people_under_18 | |
person = Person.create!(:age => 16) | |
assert_equal [person], Person.minors | |
end | |
def test_does_not_include_people_over_18 | |
person = Person.create!(:age => 21) | |
assert_equal [], Person.minors | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment