Created
April 11, 2010 15:44
-
-
Save rbarazi/362827 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 12-9. Create properties table and define its model in vendor/plugins/simple_search/test/simple_search_test.rb
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' | |
$stdout = StringIO.new | |
def create_properties_table | |
ActiveRecord::Schema.define(:version => 1) do | |
create_table :properties do |t| | |
t.column :name, :string | |
t.column :description, :text | |
end | |
end | |
end | |
class Property < ActiveRecord::Base | |
simple_search :name, :description | |
end | |
class SimpleSearchTest < ActiveSupport::TestCase | |
setup do | |
create_properties_table | |
Property.create(:name => 'Some name', :description => 'Some description') | |
Property.create(:name => 'another name', :description => 'another description') | |
end | |
test "search method is available" do | |
assert Property.respond_to?(:search) | |
end | |
test "should search" do | |
assert_equal 2, Property.search("name").size | |
assert_equal 1, Property.search("another").size | |
assert_equal 0, Property.search("swimming").size | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get an error telling me that the table Properties is already created.
Rails 3.0.9
Any ideas? Thanks