Sha256: d0ee906ad167c164a7d51e228d11d01b4a8604e1bbd596abe2acfab40c572a19

Contents?: true

Size: 484 Bytes

Versions: 3

Compression:

Stored size: 484 Bytes

Contents

require 'spec_helper'

describe "Stub ajax request", js: true do
  let(:message) { 'my custom message' }
  let(:api_path) { '/api/path' }

  before do
    stub_ajax url: api_path, responseText: { message: message }
    visit home_index_path
  end

  it 'stubs the ajax request and returns the correct message' do
    page.execute_script("$.getJSON('#{api_path}', function(data) { $('body').append(data.message) })")
    wait_until do
      page.has_content?(message)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jquery_mockjax_rails-0.0.3 spec/requests/home_spec.rb
jquery_mockjax_rails-0.0.2 spec/requests/home_spec.rb
jquery_mockjax_rails-0.0.1 spec/requests/home_spec.rb