假设我有一个名为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
I get:
undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0x1058b3098>
看起来如果测试不是明确为控制器的话,RSpec就不会加载:post
方法。尽管我已经尝试了指定:type => :controller
,但并没有用。
./spec/integration/
中)仍然无法捕获异常。 - Steven