Skip to content

Instantly share code, notes, and snippets.

@MatheusRich
Last active April 12, 2024 16:24
Show Gist options
  • Save MatheusRich/5f6dadd0fe70ea287a30158c2b67d3be to your computer and use it in GitHub Desktop.
Save MatheusRich/5f6dadd0fe70ea287a30158c2b67d3be to your computer and use it in GitHub Desktop.
Request Specs vs. System Specs Comparison
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
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