Answer the question
In order to leave comments, you need to log in
RSpec Rails - why aren't all tests checked in features?
I'm trying to test a Rails application through RSpec using the syntax recommended on these resources:
https://relishapp.com/rspec/rspec-rails/v/3-2/docs...
betterspecs.org/en
Wrote this spec for testing main pages:
spec/features/main_pages_spec.rb
require 'rails_helper'
RSpec.describe "main pages", type: :features do
scenario "root page" do
visit root_path
expect(page).to have_link("Login", href: login_path(locale: I18n.locale))
expect(page).to have_link("Signup", href: signup_path(locale: I18n.locale))
end
end
bundle exec rspec spec/features/main_pages_spec.rb
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 47521
main pages
root page
Top 1 slowest examples (1.4 seconds, 99.9% of total time):
main pages root page
1.4 seconds ./spec/features/main_pages_spec.rb:8
Finished in 1.4 seconds (files took 4.58 seconds to load)
1 example, 0 failures
gem 'rails', '~> 4.2', '>= 4.2.5'
gem 'rspec-rails', '~> 3.3'
gem 'capybara', '~> 2.5'
gem 'minitest'
gem 'selenium-webdriver', '~> 2.48'
Answer the question
In order to leave comments, you need to log in
Both expect pass. In feature tests, scenario is synonymous with it from regular tests.
If rspec logs that the test has passed, then everything that is written in it has been completed.
To verify this, try the following code
scenario "root page" do
visit root_path
puts 'A'
expect(page).to have_link("Login", href: login_path(locale: I18n.locale))
puts 'B'
expect(page).to have_link("Signup", href: signup_path(locale: I18n.locale))
puts 'C'
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question