ruby-on-rails – 使用RSpec测试导轨金属/机架?
发布时间:2020-12-17 01:22:51 所属栏目:百科 来源:网络整理
导读:假设我有一个名为Preview的Metal类.如何使用RSpec进行测试? 当我尝试: require 'spec_helper'describe Preview do it "should return the posted content" do post "/preview",:content = "*title*" response.body.should == "*title*" endend 我明白了:
假设我有一个名为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> 似乎RSpec没有加载:post方法,如果测试没有显式为Controller.我已经尝试过指定:type => :控制器无济于事. 解决方法
rspec具有包含rails集成测试(通过机架)的集成规范.只需将该规范放在./spec/integration/preview_spec.rb中即可.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |