Sha256: 27ed8aa41e442e737afba39ae295675a4f26d9d4531a2617eaaf2511a787c57e

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# jquery_mockjax_rails

[![Build Status](https://travis-ci.org/chautoni/jquery_mockjax_rails.png?branch=master)](https://travis-ci.org/chautoni/jquery_mockjax_rails)

This gem provides:

  * [jQuery Mockjax 1.5.2](https://github.com/appendto/jquery-mockjax)
  * Ajax mocking helper in your Rspec integration tests

## Requirements

  * Rails 3.1 or later
  * Assets pipeline enabled
  * jQuery
  * Rspec/Capybara integration tests

## Installation

Add the `jquery_mockjax_rails` gem to your Gemfile

```ruby
group :test do
  gem 'jquery_mockjax_rails'
end
```

And run `bundle install`

## Getting Started

Stub the ajax request in a `before` block

```ruby
describe 'My integration spec', js: true do

  before do
    stub_ajax url: '/api/path', responseText: { message: 'message' }
  end
end
```

Once the browser has been lauched, open the JS console and test the mocked response

```coffeescript
$.getJSON('/api/path', function(data) { console.log(data.message) }); # => message
```

## Acknowledgements

The original idea has come from [ejholmes](https://github.com/ejholmes/mockjax), however, the gem has been deprecated and does not work with current Rails 3 application using rspec/capybara integration test, so I've decided to re-write the gem from scratch.
Most of the core code pieces have been emerged from [ejholmes](https://github.com/ejholmes/mockjax)'s work.

## Contributing

Pull requests are more than welcome. Before submitting pull requests, please make sure your changes are covered with tests.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jquery_mockjax_rails-0.0.3 README.md
jquery_mockjax_rails-0.0.2 README.md