Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grkek/spec-grip
Easy testing for Grip
https://github.com/grkek/spec-grip
Last synced: about 1 month ago
JSON representation
Easy testing for Grip
- Host: GitHub
- URL: https://github.com/grkek/spec-grip
- Owner: grkek
- License: mit
- Created: 2020-02-27T13:57:26.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-27T13:58:03.000Z (almost 5 years ago)
- Last Synced: 2024-10-25T01:28:20.147Z (3 months ago)
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spec-grip
Grip helpers to Crystal's `spec` for easy testing.Forked from spec-grip and adapted to [Grip](grkek/grip)
## Installation
Add it to your `shard.yml`.
```yaml
name: your-grip-app
version: 0.1.0dependencies:
spec-grip:
github: Whaxion/spec-grip
branch: master
grip:
github: grkek/grip
branch: master
```## Usage
Just require it before your files in your `spec/spec_helper.cr`
```crystal
require "spec-grip"
require "../src/your-grip-app"
```Your Grip application
```crystal
# src/your-grip-app.crrequire "grip"
class HelloWorldHttpConsumer < Grip::HttpConsumer
def get(req)
"Hello world"
end
endclass HelloWorld < Grip::Application
scope do
get "/", HelloWorldHttpConsumer
end
endHelloWorld.new.run
```Now you can easily test your `Grip` application in your `spec`s.
```
GRIP_ENV=test crystal spec
``````crystal
# spec/your-grip-app-spec.crdescribe "Your::Grip::App" do
# You can use get,post,put,patch,delete to call the corresponding route.
it "renders /" do
get "/"
response.body.should eq "Hello World!"
endend
```## Contributing
1. Fork it ( https://github.com/Whaxion/spec-grip/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request## Contributors
- [Whaxion](https://github.com/Whaxion) Whaxion - maintainer of the fork
- [sdogruyol](https://github.com/sdogruyol) Sdogruyol - creator