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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I usually use Shoulda for this: http://rubydoc.info/gems/shoulda/frames should belong_to(:user) should have_many(:tags).through(:taggings) Dheeraj Kumar On Friday 27 January 2012 at 4:51 PM, Guilherme R. wrote:> 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? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 27 January 2012 11:21, Guilherme R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 => :workflowTry have_many rather than has_many Colin> #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? > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- gplus.to/clanlaw -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I was using "has" and de corretly is "have" . Tks everbody. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.