Skip to content

Commit

Permalink
First trivial (validate environment) example passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhennemeyer committed Nov 4, 2008
1 parent d489529 commit e1caec0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/existence_validated.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# def existence_validated(assocs=[], options={})
def existence_validated(assocs=[], options={})
# def existing_assoc(sym, mock=nil)
# klass = sym.to_s.capitalize.constantize
# obj = mock || mock_model(klass)
Expand All @@ -15,4 +15,5 @@
# existing_assoc(sym, options[sym])
# end
# end.inject {|s,i| s.merge(i)}
# end
{}
end
5 changes: 3 additions & 2 deletions spec/existence_validated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
describe "existence_validated" do

before(:all) do
class Assoc < ActiveRecord::Base
end
class Model < ActiveRecord::Base
belongs_to :assoc
validates_existence_of :assoc
end
end

Expand All @@ -15,7 +16,7 @@ def valid_attributes(options={})
}.update(existence_validated([:assoc], options)).update(options)
end

it "should not fail" do
it "should not fail " do
Model.create!(valid_attributes)
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@


ActiveRecord::Migration.create_table :models do |t|
t.integer :assoc_id
t.string :name
end
ActiveRecord::Migration.create_table :assocs do |t|
end

0 comments on commit e1caec0

Please sign in to comment.