-
brew install qt
-
gem 'capybara'
-
gem 'laundry'
-
create a features folder in rspec
rails g rspec:feature campaigns
- in rails_helper.rb, include capybara/rails as a required gem
require 'spec_helper'
require 'rspec/rails'
require 'capybara/rails'
- in spec/features/campaigns_spec.rb
describe "Campaigns Listing" do
it "displays a text 'Recent Campaigns'" do
# this simulates users typing the 'campaign_path' in the address bar
# to actually visit the page
visit campaigns_path
# we have accss to an object 'page' that contains the rendered HTML page
#
expect(page).to have_text "Recent Campaigns"
end
end
- add this line to index.html.erb
<p> Recent Campaigns</p>
- spec/features/campaigns_spec.rb
it "displays an h2 header with text 'All Campaigns'" do
visit campaigns_path
expect(page).to have_selector "h2", text: "All campaigns"
end
- the laundry gem allows a debugging technique
save_and_open_page
this line will pause the test and open the page