spec-kemal/README.md

75 lines
1.3 KiB
Markdown
Raw Normal View History

2016-04-09 14:37:46 +00:00
# spec-kemal
2016-04-09 14:49:51 +00:00
Kemal helpers to Crystal's `spec` for easy testing.
2016-04-09 14:37:46 +00:00
## Installation
2016-04-09 14:49:51 +00:00
Add it to your `shard.yml`.
2016-04-09 14:37:46 +00:00
2016-04-09 14:49:51 +00:00
```yaml
name: your-kemal-app
version: 0.1.0
2016-04-09 14:37:46 +00:00
2016-04-09 14:49:51 +00:00
dependencies:
spec-kemal:
github: sdogruyol/spec-kemal
branch: master
kemal:
github: sdogruyol/kemal
branch: master
```
2016-04-09 14:37:46 +00:00
## Usage
2016-04-09 14:49:51 +00:00
Just require it before your files in your `spec/spec_helper.cr`
2016-04-09 14:37:46 +00:00
2016-04-09 14:49:51 +00:00
```crystal
require "spec-kemal"
require "../src/your-kemal-app"
```
2016-04-09 14:37:46 +00:00
2016-04-09 14:58:56 +00:00
Your Kemal application
```crystal
# src/your-kemal-app.cr
require "kemal"
get "/" do
"Hello World!"
end
Kemal.run
```
Now you can easily test your `Kemal` application in your `spec`s.
2016-04-09 14:37:46 +00:00
2016-04-09 14:49:51 +00:00
```crystal
# spec/your-kemal-app-spec.cr
2016-04-09 14:37:46 +00:00
2016-04-09 14:49:51 +00:00
describe "Your::Kemal::App" do
2016-04-10 14:35:14 +00:00
# Be sure to start your app in test mode
start
2016-04-09 14:49:51 +00:00
it "renders #index" do
response = HTTP::Client.get "http://localhost:3000/"
response.body.should eq "Hello World!"
end
2016-04-10 14:35:14 +00:00
# Be sure to stop your app after the specs
stop
2016-04-09 14:49:51 +00:00
end
```
2016-04-09 14:37:46 +00:00
## Contributing
2016-04-09 14:49:51 +00:00
1. Fork it ( https://github.com/sdogruyol/spec-kemal/fork )
2016-04-09 14:37:46 +00:00
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
2016-04-09 14:49:51 +00:00
- [sdogruyol](https://github.com/sdogruyol) Sdogruyol - creator, maintainer