Sha256: fc654f2e3e488a6ea1590e747c74b44601dea6dee1ad1e9afe901cab998ea128
Contents?: true
Size: 950 Bytes
Versions: 2
Compression:
Stored size: 950 Bytes
Contents
require File.join(File.dirname(__FILE__), "test_helper") class SearchTest < Test::Unit::TestCase setup do Ohm.flush end class Lane < Ohm::Model attribute :lane_type index :lane_type def to_s lane_type.capitalize end def validate assert_unique :lane_type end def error_messages errors.present do |e| e.on [:lane_type, :not_unique], "The lane type #{lane_type} is already in use" end end end context "A model with an indexed attribute" do setup do @results = [] @subresults = [] Lane.search(:lane_type => "email") { |sr| @results << sr.size } Lane.create(:lane_type => "email") Lane.search(:lane_type => "email") { |sr| @results << sr.size } Lane.search(:lane_type => "email") { |sr| @results << sr.size } end should "be able to find by the given attribute" do assert_equal [0, 1, 1], @results end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ohm-0.0.26 | test/search_test.rb |
ohm-0.0.25 | test/search_test.rb |