【问题标题】:How to write Rails rspec feature test for a custom gem?如何为自定义 gem 编写 Rails rspec 功能测试?
【发布时间】:2016-06-06 03:59:33
【问题描述】:

我在哪里可以找到有关如何编写使用 ajaxful_rating gem 的 Rails rspec 测试的指南。我正在编写的测试类似于下面的测试。 https://github.com/edgarjs/ajaxful-rating

require "rails_helper"

RSpec.feature "Users can create new review" do
  scenario "with valid attributes" do

    # Put in a 5 star rating here.

    fill_in "Review", with: "This place is pretty good."
    click_button "Create Review"

    expect(page).to have_content "Review has been created."
  end
end

【问题讨论】:

  • 要选择 5 开始评级,您需要单击第 5 次开始的元素 - 不幸的是,从 ajaxful 评级页面链接到的演示应用程序已关闭,所以我看不到 html 的内容它生成的是——如果你将它在页面上生成的 html 添加到你的问题中,我们可以告诉你如何点击它

标签: ruby-on-rails capybara rspec-rails


【解决方案1】:

这可能是一个非常广泛的答案,但是如果您想了解如何在 rspec 中编写测试用例,this documentation 可能有助于理解什么是测试用例的概念以及如何制作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多