Also create a joined table so the test won't fail

This commit is contained in:
Prem Sichanugrist 2011-09-12 17:25:31 +07:00
parent a6fa83e18c
commit 3e6463bbc5
2 changed files with 10 additions and 2 deletions

View File

@ -90,6 +90,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do
has_and_belongs_to_many :children
validates_presence_of :children
end.new
create_table "children_parents", :id => false do |t|
t.integer :child_id
t.integer :parent_id
end
end
it "should require the attribute to be set" do
@ -103,6 +107,10 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher do
@model = define_model :parent do
has_and_belongs_to_many :children
end.new
create_table "children_parents", :id => false do |t|
t.integer :child_id
t.integer :parent_id
end
end
it "should not require the attribute to be set" do

View File

@ -12,12 +12,12 @@ module ModelBuilder
end
end
def create_table(table_name, &block)
def create_table(table_name, options = {}, &block)
connection = ActiveRecord::Base.connection
begin
connection.execute("DROP TABLE IF EXISTS #{table_name}")
connection.create_table(table_name, &block)
connection.create_table(table_name, options, &block)
@created_tables << table_name
connection
rescue Exception => e