How to test the model dependence ?

Good morning,

I'm new to rails and am having some basic questions in development. See
if anyone can help me with a test problem. I need to test if my model
"Procedure" is linked to the workflow. If not, the system must
acknowledge an error. Below is the code that is in the file test \ unit
\ procedure_test.rb.

require 'test_helper'

class ProcedureTest < ActiveSupport::TestCase
  should belong_to :workflow
  should has_many :tasks, :through => :workflow
  #should has_one :timeline
  #should has_many :timeline_items, :through => :timeline
end

The shoul "belong_to" is working normally but when running "rake test"
appears the following error:

$ Rake test
/ home / guilhermec / iba_jornais / test / unit / procedure_test.rb: 5:
in `‘: undefined method `has_many’ for ProcedureTest:Class
(NoMethodError)
from /home/guilhermec/iba_jornais/test/unit/procedure_test.rb:3:in `<top
(required)>’
from
/home/guilhermec/.rvm/gems/ruby-1.9.2-p180@iba-jornais/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
`require’
from
/home/guilhermec/.rvm/gems/ruby-1.9.2-p180@iba-jornais/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
`block in require’
from
/home/guilhermec/.rvm/gems/ruby-1.9.2-p180@iba-jornais/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in
`load_dependency’
from
/home/guilhermec/.rvm/gems/ruby-1.9.2-p180@iba-jornais/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
`require’
from
/home/guilhermec/.rvm/gems/ruby-1.9.2-p180@iba-jornais/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in
`block (2 levels) in '
from `Each '
from `Block in'
from `Select '
from `'
Loaded suite

Does anyone know what I should do to fix this?

I usually use Shoulda for this:

http://rubydoc.info/gems/shoulda/frames

should belong_to(:user)
    should have_many(:tags).through(:taggings)

Dheeraj Kumar

Good morning,

I'm new to rails and am having some basic questions in development. See
if anyone can help me with a test problem. I need to test if my model
"Procedure" is linked to the workflow. If not, the system must
acknowledge an error. Below is the code that is in the file test \ unit
\ procedure_test.rb.

require 'test_helper'

class ProcedureTest < ActiveSupport::TestCase
should belong_to :workflow
should has_many :tasks, :through => :workflow

Try have_many rather than has_many

Colin

I was using "has" and de corretly is "have" . Tks everbody.