假设我有一个名为 Preview 的 Metal 类。如何使用 RSpec 对其进行测试?
当我尝试:
require 'spec_helper'
describe Preview do
it "should return the posted content" do
post "/preview", :content => "*title*"
response.body.should == "*title*"
end
end
我得到:
undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0x1058b3098>
:post
如果测试不是明确针对控制器,RSpec 似乎不会加载该方法。我试过指定:type => :controller
无济于事。