Last active
April 12, 2024 16:24
-
-
Save MatheusRich/5f6dadd0fe70ea287a30158c2b67d3be to your computer and use it in GitHub Desktop.
Request Specs vs. System Specs Comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_helper" | |
RSpec.describe "User management", type: :request do | |
# Runs in about 0.2 seconds (excluding file load time) | |
it "lists existing users" do | |
User.create!(name: "John", age: 30) | |
get users_path | |
expect(page).to have_table "Users" do |table| | |
expect(table).to have_content "John" | |
expect(table).to have_content "30" | |
end | |
end | |
private | |
def page = Capybara.string(response.body) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_helper" | |
RSpec.describe "User management", type: :system do | |
before do | |
driven_by(:selenium_chrome_headless) | |
# driven_by(:cuprite) # uncomment this line to use Cuprite | |
end | |
# Runs in about 2.5 seconds with Selenium (excluding file load time) | |
# Runs in about 1.5 seconds with Cuprite (excluding file load time) | |
it "lists existing users" do | |
User.create!(name: "John", age: 30) | |
visit users_path | |
within_table "Users" do | |
expect(page).to have_content "John" | |
expect(page).to have_content "30" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment