Skip to content

Commit 30aa864

Browse files
sethpollackdblock
authored andcommitted
Added testing with Airborne.
1 parent 44914da commit 30aa864

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,14 +2295,14 @@ end
22952295

22962296
## Writing Tests
22972297

2298-
You can test a Grape API with RSpec by making HTTP requests and examining the response.
2299-
23002298
### Writing Tests with Rack
23012299

23022300
Use `rack-test` and define your API as `app`.
23032301

23042302
#### RSpec
23052303

2304+
You can test a Grape API with RSpec by making HTTP requests and examining the response.
2305+
23062306
```ruby
23072307
require 'spec_helper'
23082308

@@ -2332,6 +2332,28 @@ describe Twitter::API do
23322332
end
23332333
```
23342334

2335+
#### Airborne
2336+
2337+
You can test with other RSpec-based frameworks, including [Airborne](https://github.com/brooklynDev/airborne), which uses `rack-test` to make requests.
2338+
2339+
```ruby
2340+
require 'airborne'
2341+
2342+
Airborne.configure do |config|
2343+
config.rack_app = Twitter::API
2344+
end
2345+
2346+
describe Twitter::API do
2347+
describe "GET /api/statuses/:id" do
2348+
it "returns a status by id" do
2349+
status = Status.create!
2350+
get "/api/statuses/#{status.id}"
2351+
expect_json(status.as_json)
2352+
end
2353+
end
2354+
end
2355+
```
2356+
23352357
#### MiniTest
23362358

23372359
```ruby

0 commit comments

Comments
 (0)