Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
mwoods79 committed Aug 27, 2015
1 parent 69a2a05 commit c5702cd
Showing 1 changed file with 76 additions and 3 deletions.
79 changes: 76 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,38 @@ Or install it yourself as:

## Usage

1. Create a .exhaust.yml
1. Exhaust sets an ENV variable. Tell Ember how to use it.

```javascript
// config/environment.js
if (environment === 'development') {
// Set the ENV.API_HOST to the environment varibale.
// I like to set a default but it's all up to you.
ENV.API_HOST = (process.env.API_HOST || 'http://localhost:3000')
}
```
If using Ember Data, set the host to whatever adapter

```javascript
// app/adapters/application.js
import DS from 'ember-data';
import config from '../config/environment';

export default DS.RESTAdapter.extend({
host: config.API_HOST
});
```

If using Ember.$ reference wherever needed.
```javascript
import Ember from 'ember'
import config from '../config/environment';


Ember.$.getJSON(config.API_HOST + "/endpoint")
```

2. Create a .exhaust.yml

```yaml
rails:
Expand All @@ -31,29 +62,71 @@ ember:
port: 4201
```
2. Start the servers
3. Start the servers
```ruby
Exhaust.run!
```

3. Stop the servers
4. Stop the servers
```ruby
Exhaust.shutdown!
```

### Using with Cucumber

When used insided a rails app.

```ruby
# Add to features/support/env.rb
Exhaust.run!
at_exit { Exhaust.shutdown! }

Capybara.configure do |config|
config.run_server = false
// Use whatever driver you want
config.default_driver = :webkit
config.app_host = Exhaust.ember_host
end
```

When seperatly from rails.

1. Add your rails app Gemfile to your own

```ruby
eval_gemfile File.join("/path/to/rails/Gemfile")
```

2. Do something like this in your features/support/env.rb

```ruby
ENV['RAILS_ENV'] ||= 'test'
path_to_rails = "/path/to/rails"
require File.expand_path("#{path_to_rails}/config/environment")

require 'capybara/cucumber'
require 'database_cleaner'
require 'database_cleaner/cucumber'

DatabaseCleaner.strategy = :truncation

Around do |scenario, block|
DatabaseCleaner.cleaning(&block)
end

Exhaust.run!
at_exit { Exhaust.shutdown! }

Capybara.configure do |config|
// Use whatever driver you want
config.default_driver = :webkit
config.app_host = Exhaust.ember_host
end
```

### Using with Rspec

```ruby
# Add to spec/spec_helper.rb
Exhaust.run!
Expand Down

0 comments on commit c5702cd

Please sign in to comment.