所以我正在做EdX第二部分的家庭作业1,我似乎不能让save_and_open_page工作。
下面是rspec代码块:
describe 'merge action' do
before do
@article_for_merging = Factory(:article)
@article_for_merging.body = 'something we will merge'
end
it 'should merge articles' do
get :merge, 'id' => @article.id, 'merge_with' => @article_for_merging.id
response.should render_template('new')
assigns(:article).should_not be_nil
assigns(:article).should be_valid
response.should contain(/body/)
response.should contain(/extended content/)
save_and_open_page
debugger
response.should have_field('article[body]',:with => @article.body + @article_for_merging.body)
response.should have_selector('form#merge input#merge_with')
response.should have_selector('form#merge input#merge')
end
end其他堆栈溢出帖子建议解决方案:
http://paikialog.wordpress.com/2012/02/11/webrat-no-such-file-to-load-action_controllerintegration/
save_and_open_page (capybara / launchy) stopped working in a project - error
我相信我已经尝试了所有的方法,但是我不能让它工作。这很令人沮丧,因为我可以查看原始的HTML,但对于大页面来说,查找我需要的html细节是一件非常痛苦的事情-在浏览器中查找像chrome的"inspect元素“这样的东西要容易得多。
无论我尝试了什么建议的解决方案组合,我总是会返回到这个错误的一些变体:
(1)具有管理连接合并操作的Admin::ContentController应合并文章:失败/错误: save_and_open_page _ LoadError:*没有要加载的此类文件-- action_controller/integration:# ./spec/controllers/admin/content_controller_spec.rb:498:in ` `block (4 Level) in‘
非常感谢您的帮助
发布于 2013-09-06 01:17:12
根据评论中Sam Joseph的黑客解决方案,我编写了这个方法,并将其放在spec/support/helpers.rb中:
def save_and_open_rspec_page
File.open('/tmp/test.html','w'){|file| file.write(rendered)}; `open '/tmp/test.html'`
endresponse.body对我不起作用,大概是因为我在视图规范中?
firefox也不适合我。因为我用的是Mac,所以我用的是open。
此外,在我的视图规范中,我在save_and_open_rspec_page之前调用了render。
https://stackoverflow.com/questions/13518855
复制相似问题