Hi everyone,
I am testing the validation of association of the model but i can a
error.. plzz help
error
/usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
active_record/matchers/association_matcher.rb:27:in `have_many': wrong
number of arguments (2 for 1) (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:429:in `method_missing'
from test/unit/prescription_test.rb:71:in `block in
<class:PrescriptionTest>'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `merge_block'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:301:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `context'
from test/unit/prescription_test.rb:64:in `<class:PrescriptionTest>'
from test/unit/prescription_test.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `block in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:227:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `block
in <main>'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `each'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `<main>'
Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader
Started
there is one
prescription model
has _many :others
has_many :phrases, :through => :reasons
phrase model
has_many :others
reason model
validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE"
belongs_to :phrase
other model
validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE"
belongs_to :phrase
test file of prescription_test.rb
context "checking assocciation" do
should have_many :phrases, :through => :others
end
Hi everyone,
I am testing the validation of association of the model but i can a
error.. plzz help
error
/usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
active_record/matchers/association_matcher.rb:27:in `have_many': wrong
number of arguments (2 for 1) (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:429:in `method_missing'
from test/unit/prescription_test.rb:71:in `block in
<class:PrescriptionTest>'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `merge_block'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:301:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `context'
from test/unit/prescription_test.rb:64:in `<class:PrescriptionTest>'
from test/unit/prescription_test.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `block in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:227:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `block
in <main>'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `each'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `<main>'
Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader
Started
there is one
prescription model
has _many :others
has_many :phrases, :through => :reasons
You also need has_many :reasons in order to specify has_many through
(I think). Or should this be through :others?
phrase model
has_many :others
reason model
validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE"
belongs_to :phrase
Again you will need belongs_to prescription.
other model
validates_presence_of :phrase_id, :message => "ERROR_MISSING_PHRASE"
belongs_to :phrase
and belongs_to prescription.
test file of prescription_test.rb
context "checking assocciation" do
should have_many :phrases, :through => :others
Above you have specified through reasons not through others. Either
the test or the relation is wrong.
Colin
Hi everyone,
I am testing the validation of association of the model but i can a
error… plzz help
error
/usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
active_record/matchers/association_matcher.rb:27:in `have_many’: wrong
number of arguments (2 for 1) (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:429:in `method_missing’
from test/unit/prescription_test.rb:71:in `block in
class:PrescriptionTest’
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `call’
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:306:in `merge_block’
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:301:in `initialize’
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `new’
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/
context.rb:199:in `context’
from test/unit/prescription_test.rb:64:in `<class:PrescriptionTest>'
from test/unit/prescription_test.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load’
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `block in load’
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:227:in `load_dependency’
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/
active_support/dependencies.rb:235:in `load’
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `block
in ’
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `each'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `<main>'
Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader
Started
there is one
prescription model
has _many :others
has_many :phrases, :through => :reasons
You also need has_many :reasons in order to specify has_many through
(I think). Or should this be through :others?
phrase model
has_many :others
reason model
validates_presence_of :phrase_id, :message => “ERROR_MISSING_PHRASE”
belongs_to :phrase
Again you will need belongs_to prescription.
other model
validates_presence_of :phrase_id, :message => “ERROR_MISSING_PHRASE”
belongs_to :phrase
and belongs_to prescription.
test file of prescription_test.rb
context “checking assocciation” do
should have_many :phrases, :through => :others
Above you have specified through reasons not through others. Either
the test or the relation is wrong.
I follow the way that you said and edit “belongs to prescription”
right now it gives an error
/usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/active_record/matchers/association_matcher.rb:27:in `have_many’: wrong number of arguments (2 for 1) (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:429:in `method_missing'
from test/unit/prescription_test.rb:71:in `block in <class:PrescriptionTest>'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:306:in `call'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:306:in `merge_block'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:301:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:199:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/shoulda-2.11.3/lib/shoulda/context.rb:199:in `context'
from test/unit/prescription_test.rb:64:in `<class:PrescriptionTest>'
from test/unit/prescription_test.rb:3:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `block in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:227:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `block in <main>'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `each'
from /usr/local/lib/ruby/1.9.1/rake/rake_test_loader.rb:5:in `<main>'
Loaded suite /usr/local/lib/ruby/1.9.1/rake/rake_test_loader
Started
plz help