Skip to content

Instantly share code, notes, and snippets.

@dsisnero
Forked from dogweather/request_helpers.rb
Created October 12, 2023 11:37
Show Gist options
  • Select an option

  • Save dsisnero/21f995d87b00a9992a0275e494413bda to your computer and use it in GitHub Desktop.

Select an option

Save dsisnero/21f995d87b00a9992a0275e494413bda to your computer and use it in GitHub Desktop.

Revisions

  1. @dogweather dogweather revised this gist Oct 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion some_spec.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to use the above helpers.

    Spec.describe 'Test some page', type: :request do
    RSpec.describe 'Test some page', type: :request do
    it 'has a <p> with "Title"' do
    get '/my-page'

  2. @dogweather dogweather created this gist Oct 10, 2023.
    7 changes: 7 additions & 0 deletions request_helpers.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    def css(selector)
    html.css(selector).text
    end

    def html
    Nokogiri::HTML(response.body)
    end
    9 changes: 9 additions & 0 deletions some_spec.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # How to use the above helpers.

    Spec.describe 'Test some page', type: :request do
    it 'has a <p> with "Title"' do
    get '/my-page'

    expect( css 'p' ).to include 'Title'
    end
    end