首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使save_and_open_page在rspec中用于拼写错误的项目

无法使save_and_open_page在rspec中用于拼写错误的项目
EN

Stack Overflow用户
提问于 2012-11-23 03:16:43
回答 2查看 1.5K关注 0票数 2

所以我正在做EdX第二部分的家庭作业1,我似乎不能让save_and_open_page工作。

下面是rspec代码块:

代码语言:javascript
复制
    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

其他堆栈溢出帖子建议解决方案:

RSpec2 and Capybara

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‘

非常感谢您的帮助

EN

Stack Overflow用户

发布于 2013-09-06 01:17:12

根据评论中Sam Joseph的黑客解决方案,我编写了这个方法,并将其放在spec/support/helpers.rb中:

代码语言:javascript
复制
def save_and_open_rspec_page
  File.open('/tmp/test.html','w'){|file| file.write(rendered)}; `open '/tmp/test.html'`
end

response.body对我不起作用,大概是因为我在视图规范中?

firefox也不适合我。因为我用的是Mac,所以我用的是open

此外,在我的视图规范中,我在save_and_open_rspec_page之前调用了render

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13518855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档