开发者

Setting up Shoulda under Test/Unit in Rails 3 (3.0.3)

I have posted this in other places but no response. Trying to get Shoulda working inside Test/Unit in Rails 3.0.3 (1.9.2). When I try to run the test (copied below), I get this error:

test/unit/practice_member_test.rb:4:in <class:Pract开发者_开发技巧iceMemberTest>': undefined methodcontext' for PracticeMemberTest:Class (NoMethodError)

Note that I have another Rails 3 project with Rspec including Shoulda also and it works fine via Rspec. In the failing project I tried placing "require 'shoulda'" in test helper to no avail, but when I run the debugger and type Shoulda, the object is found, so the library is being loaded.

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

Must be something I am overlooking as I have not seen anyone with this same issue.


Did you try adding the following to your config/environment.rb file:

  Rails::Initializer.run do |config|
    config.gem "shoulda", :lib => "shoulda"
  end

Then

 $ rake gems:install
 $ rake gems:unpack

As suggested in the documentation?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜