How to include Capybara RSpec matchers in RSpec
Today I've Learned postlet say you want to use have_content
and have_selector
in spec
# Gemfile
gem 'capybara'
gem 'rspec'
# spec/spec_helper.rb
#...
require 'capybara/rspec'
#...
require 'spec_helper'
RSpec.describe MyPresenter do
include Capybara::RSpecMatchers
it do
expect("<b>abc</b>").to have_selector("b")
end
end
Entire blog website and all the articles can be forked from this Github Repo