【问题标题】:How to check if controller response has link?如何检查控制器响应是否有链接?
【发布时间】:2012-08-29 01:16:34
【问题描述】:

什么是体面的做法?最好匹配一个正则表达式。

我现在的代码是这样的:

describe "get #show" do
  context "signed in" do
    it "should have a link to edit profile" do
      # i sign in the user
      get :show
      response # i don't know what to do here
    end
  end
end

感谢您的帮助!

【问题讨论】:

    标签: ruby rspec rspec2 rspec-rails


    【解决方案1】:

    您似乎正在尝试执行acceptance test,这可能意味着您应该遵从Capybara。然后你就可以变魔术了

    page.should have_css('edit_link', text: 'Edit me')

    【讨论】:

      猜你喜欢
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-21
      相关资源
      最近更新 更多