RSpec::Matchers.define :be_naturally_sorted do match do |array| array == array.natural_sort end end See RSpec: Where to put custom...
When putting phone numbers into web pages, you should use tel: links so smartphone users can click those numbers to...
Upgrading from Ruby 1.8.7 to 2.1.2 took me an hour for a medium-sized application. It involved hardly any changes...
This is what worked for me in a Rails 4: # JSON data as first argument, then parameters patch :update, { some...
Capybara will fail to find tags that are missing an href attribute. This will probably happen to you every now...
Though nowhere to be found in the official docs, this works just fine. describe Facebook::Post do it_behaves_like...
Sometimes you need complex expectations on method arguments like this SomeApi.should_receive(:find).with(:query => '*foo*', :sort => 'timestamp ASC', :limit...
TL;DR In blueprints, always wrap associations in blocks. # Broken Task.blueprint(:vacation) do project Project.make(:vacation) hours 8 accounting_method...
While RSpec 1 and 2 decided that specs inside spec/model are model specs, and those inside spec/features are feature specs...
When you don't only have a favicon.ico in your project but also PNGs of different sizes and backgrounds, you...
Spreewald 1.1.0 drops the be_true and be_false matchers in order to be RSpec 3 and Ruby 2 compatible...
The attached RSpec matcher allows for comfortably testing delegation. Examples describe Post do it { should delegate(:name).to(:author).with...
So you're getting an error message like the following, although your Gemfile lists shoulda-matchers and it has always...
Using this gem, whenever a Capybara test in Cucumber, Rspec or Minitest fails, the HTML for the failed page and...
RSpec 3.0 deprecates the :should way of writing specs for expecting things to happen. However, if you have tests you...
Warnings like those below may originate from rspec or shoulda-matchers or other gems that have not updated yet to...
When using TextMate2 with the cucumber bundle, it does not recognize step definitions (e.g. custom_steps.rb) as such but believes they...
Sometimes you have a test expectation but actually want a better error message in case of a failure. Here is...
You might not know that Rails disables CSRF protection in tests. This means that if you accidentally forget to send...
If you want to have routes that are only available in tests (e.g. for testing obscure redirects), you can use...
In contrast to RSpec's included allow_value matcher, the attached matcher will also work on associations, which makes it...
When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module...
Custom matchers are a useful RSpec feature which you can use to DRY up repetitive expectations in your specs. Unfortunately...
Shared example groups are a useful RSpec feature. Unfortunately the default directory structure generated by rspec-rails has no obvious...