Ruby on Rails Wednesday, December 15, 2010



On Tue, Dec 14, 2010 at 6:17 PM, David Kahn <dk@structuralartistry.com> wrote:
Curious if anyone has Shoulda working with test/unit in Rails 3. I tried it this morning and am getting:

test/unit/practice_member_test.rb:4:in `<class:PracticeMemberTest>': undefined method `context' for PracticeMemberTest:Class (NoMethodError)

Now, I have a Rails 3 project with Rspec including Shoulda also and it works fine. I tried placing  "require 'shoulda'" in test helper to no avail, but when I run the debugger and type Shoulda, the object is found.


It it helps, here is my test:

require 'test_helper'

class PracticeMemberTest < Test::Unit::TestCase
  context "practice member" do    
    should "get global practice member count not including Demo Practice" do
      assert_equal PracticeMember.practice_members_global_count, 0

      practice = Factory.create(:practice_one)

      practice_member = Factory.create(:practice_member)
      practice_member.practice_id = practice.id
      practice_member.save
      practice_member = Factory.create(:practice_member)
      practice_member.practice_id = practice.id
      practice_member.save

      assert_equal PracticeMember.practice_members_global_count, 2
    end
  end
end


the whole context syntax is been deprecated in favor of a pure rspec like syntax.

http://robots.thoughtbot.com/post/701863189/shoulda-rails3-and-beyond

--
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@googlegroups.com.
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.

No comments:

Post a Comment