Skip to content

Instantly share code, notes, and snippets.

@MatheusRich
Last active November 26, 2024 04:49
Show Gist options
  • Select an option

  • Save MatheusRich/5f6dadd0fe70ea287a30158c2b67d3be to your computer and use it in GitHub Desktop.

Select an option

Save MatheusRich/5f6dadd0fe70ea287a30158c2b67d3be to your computer and use it in GitHub Desktop.

Revisions

  1. MatheusRich revised this gist Apr 12, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions system.rb
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@
    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"
  2. MatheusRich created this gist Apr 12, 2024.
    19 changes: 19 additions & 0 deletions request.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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
    20 changes: 20 additions & 0 deletions system.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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