Skip to content

Instantly share code, notes, and snippets.

@nakajima
Created September 5, 2009 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakajima/181530 to your computer and use it in GitHub Desktop.
Save nakajima/181530 to your computer and use it in GitHub Desktop.
require 'acts_as_fu'
build_model(:people) do
string :age
named_scope :minors, :conditions => ['age < ?', 18]
end
[~] ruby named-scope-fu.rb
Loaded suite named-scope-fu
Started
..
Finished in 0.009923 seconds.
2 tests, 2 assertions, 0 failures, 0 errors
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