Created
March 3, 2012 17:51
-
-
Save jonathanpberger/1967118 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
############# first try, got a NoMethodError | |
require 'spec_helper' | |
describe Playdate do | |
describe "associatons" do | |
it { should have_one(:location) } | |
end | |
end | |
############## second try, still getting | |
#Failures: | |
# 1) Playdate associations should have one location | |
# Failure/Error: foo.should have_one :location | |
# NoMethodError: | |
# undefined method `has_one?' for #<Playdate:0x00000103cd2b08> | |
# ./spec/models/playdate_spec.rb:8:in `block (3 levels) in <top (required)>' | |
####### Here's the spec: | |
require 'spec_helper' | |
describe Playdate do | |
describe "associations" do | |
# it { should have_one(:location) } | |
it "should have one location" do | |
foo = Playdate.new | |
foo.should have_one :location | |
end | |
end | |
end | |
##################################### | |
############# messing around in the console allowed me to create a Playdate, but not a Location | |
1.9.2-p290 :009 > Location.create | |
SyntaxError: /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods/write.rb:14: syntax error, unexpected '?', expecting ';' or '\n' | |
def public?=(new_value); write_attribute('public?', new_value); end | |
^ | |
/Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods/write.rb:14: syntax error, unexpected keyword_end, expecting $end | |
def public?=(new_value); write_attribute('public?', new_value); end | |
^ | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods/write.rb:14:in `module_eval' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods/write.rb:14:in `define_method_attribute=' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods/time_zone_conversion.rb:51:in `define_method_attribute=' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:267:in `block in define_attribute_method' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:260:in `each' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:260:in `define_attribute_method' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:256:in `block in define_attribute_methods' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:256:in `each' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activemodel-3.2.2/lib/active_model/attribute_methods.rb:256:in `define_attribute_methods' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods.rb:66:in `block in define_attribute_methods' | |
from <internal:prelude>:10:in `synchronize' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods.rb:63:in `define_attribute_methods' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/attribute_methods.rb:167:in `respond_to?' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:398:in `__run_callback' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:385:in `_run_initialize_callbacks' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activesupport-3.2.2/lib/active_support/callbacks.rb:81:in `run_callbacks' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/base.rb:498:in `initialize' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/persistence.rb:44:in `new' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/activerecord-3.2.2/lib/active_record/persistence.rb:44:in `create' | |
from (irb):9 | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start' | |
from /Users/jpb/.rvm/gems/ruby-1.9.2-p290@cuketest/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>' | |
from script/rails:6:in `require' | |
################################## | |
# Here's the entire playdate class | |
class Playdate < ActiveRecord::Base | |
has_one :location | |
end | |
################################## | |
# and the location class | |
class Location < ActiveRecord::Base | |
end |
still fails:
Failures:
- Playdate associations should have one location
Failure/Error: @location = foo.location.build(:name => "location_name_or_whatever_to_be_valid")
NoMethodError:
undefined method `location' for #Playdate:0x000001034b4958./spec/models/playdate_spec.rb:8:in`block (3 levels) in <top (required)>'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try the following:
foo = Playdate.new
@location = foo.location.build(:name => "location_name_or_whatever_to_be_valid")
foo.location.should == @location