It’s pretty common to have multiple tests that are nearly the same. In one app, we support bidding on both online and hammer auctions (auctions with people physically present). They’re separate controllers but with a lot of shared code and behavior.…
链接 https://relishapp.com/rspec/rspec-expectations/v/3-4/docs/custom-matchers/define-a-custom-matcher#define-aliases-for-your-matcher require 'rspec/expectations' class String def words split('') end end RSpec::Matchers.define :have_5_words do match d…
转自 http://lmws.net/describe-vs-context-in-rspec 学习rspec,不太理解describe和context.google了一下,找到这篇文章,感觉说的有些道理 1 在Rspec的世界里,我们经常看到人们使用descirbe代码块和context代码块 例如 describe "launch the rocket" do context "all ready" do end context "not ready…
这里讲了如何安装rspec,安装使用rspec. 下面介绍一下rspec中常见的使用方法. 下面是一个最简单的测试用例,判断true是不是等于true,should_be是旧的用法,新用法推荐使用expect() it "is true when true" do true.should be_true end#新用法 it "is true when true" do expect(true).to be_true end 一,测试models中的方法 1,测试实…
官方文档如下: https://github.com/rspec/rspec-rails/blob/master/Capybara.md Capybara 2.0 To use Capybara 2.0, you need rspec-rails-2.11.1 or greater. Capybara::DSL is added to examples in: spec/features Capybara::RSpecMatchers is added to examples in: spec/…