README.md in rambo_ruby-0.1.0 vs README.md in rambo_ruby-0.2.0
- old
+ new
@@ -1,36 +1,86 @@
# Rambo
-[![Build Status](https://travis-ci.org/danascheider/rambo.svg?branch=master)](https://travis-ci.org/danascheider/rambo) [![Code Climate](https://codeclimate.com/github/danascheider/rambo/badges/gpa.svg)](https://codeclimate.com/github/danascheider/rambo) [![Dependency Status](https://gemnasium.com/badges/github.com/danascheider/rambo.svg)](https://gemnasium.com/github.com/danascheider/rambo)
+[![Gem Version](https://badge.fury.io/rb/rambo_ruby.svg)](https://badge.fury.io/rb/rambo_ruby) [![Build Status](https://travis-ci.org/danascheider/rambo.svg?branch=master)](https://travis-ci.org/danascheider/rambo) [![Code Climate](https://codeclimate.com/github/danascheider/rambo/badges/gpa.svg)](https://codeclimate.com/github/danascheider/rambo) [![Dependency Status](https://gemnasium.com/badges/github.com/danascheider/rambo.svg)](https://gemnasium.com/github.com/danascheider/rambo)
[![Coverage Status](https://coveralls.io/repos/github/danascheider/rambo/badge.svg?branch=dev)](https://coveralls.io/github/danascheider/rambo?branch=master)
-Rambo is a gem that generates API contract tests from API docs in [RAML](http://raml.org/).
+Rambo is a gem that generates API contract tests from API docs in [RAML](http://raml.org/). Rambo is being developed to test APIs complying with standard REST practices. Mileage may vary with other architectures, but I'm happy to consider pull requests.
-#### The current version of Rambo is 0.1.0. It is highly unstable and has a limited feature set. Use at your own risk and please file issue reports if they come up!
+#### The current version of Rambo is 0.2.0. It is highly unstable and has a limited feature set. Use at your own risk and please file issue reports if they come up!
## Usage
You can install Rambo using:
```ruby
gem install rambo_ruby
```
You can also add it to your project's Gemfile: <
```ruby
group :development, :test do
- gem 'rambo_ruby', '~> 0.0.1'
+ gem 'rambo_ruby', '~> 0.2.0'
end
```
-To run Rambo, from the root directory of your project, run:
-```
-$ rambo foobar.raml
-```
+There are three options for generating tests from Rambo: The command line tool, the rake task, and the Ruby API. In all cases, Rambo will look for a `.rambo.yml` file in the root directory of your project for configuration options. Options may also be passed in through the command line as arguments or the Ruby API as a hash. There is currently no option to pass arguments to the Rake task, but Rambo comes pre-loaded with sensible defaults, and the `.rambo.yml` file is always an option.
+
Rambo will create `spec/contract` directory and a `spec/rambo_helper.rb` file if they don't exist, and will create a `spec/contract/foobar_spec.rb` file. The latter will overwrite any existing spec file by the same name. This is intentional behavior and will not change in future versions.
+The Rack::Test API uses different syntax for Rails and non-Rails Rack apps. By default, Rambo assumes it is dealing with a Rails app, but this is easily modified by passing options or using a .rambo.yml file.
+
To run the RSpec examples Rambo generates, you will need to have `require`s in your `spec_helper.rb` or `rambo_helper.rb` file:
- `require "rack/test"`
- `require "json"`
- `require "json-schema"`
-Rambo is being developed to test APIs complying with standard REST practices. Mileage may vary with other architectures, but I'm happy to consider pull requests.
+### The Command Line Tool
+To use the command line tool, simply `cd` into the root directory of your project and run
+```
+$ rambo foobar.raml
+```
+Replace `foobar.raml` with the path of the actual RAML file from which you want to generate tests.
+
+#### Options
+By default, Rambo assumes you are testing a Rails app and generates tests using the Rails Rack::Test syntax. If you are testing a non-Rails Rack app, you can use the `--no-rails` switch to use the non-Rails syntax. Rambo does not currently support non-Rack-based frameworks.
+
+### The Rake Task
+After adding `rambo_ruby` to your Gemfile or gemspec, you will need to add the following to your Rakefile:
+```ruby
+require "rambo"
+
+Rambo::Rake::Task.new
+```
+This will create a Rake task called `rambo`. Now, you can generate tests by running:
+```
+rake rambo
+```
+
+### The Ruby API
+You can generate Rambo tests from a Ruby script using:
+```ruby
+require "rambo"
+
+Rambo.generate_contract_tests!(File.expand_path("doc/foobar.raml"), {})
+```
+You can pass any options in as a hash. Currently, the only supported option is `"rails"`, which can be set to `true` or `false`, with `true` being the default value. Set `"rails"` to `false` if your app is built with a different Rack-based framework. Currently, Non-Rack-based frameworks are not supported, but pull requests are welcome if your use case requires such support.
+
+## The .rambo.yml File
+By default, Rambo will always check for a `.rambo.yml` file in the root directory of your projects and load options from there. If there is no `.rambo.yml` file, default values will be used (see below).
+
+A sample `.rambo.yml` file could look like this:
+```yaml
+raml: docs/contracts/foobar.raml
+rails: false
+```
+The two possible keys are:
+ - `raml` - specifies the RAML file to use to generate the tests. The default, relative
+ to the root of your project directory, is `doc/raml/foobar.raml`, where `foobar.raml` is the first RAML file found in the `doc/raml` directory.
+ - `rails` - specifies whether your app is a Rails app. The default value is `true`.
+
+## Default Behavior
+In order to provide the best user experience to a majority of users, Rambo comes with some sensible defaults that are easily overridden in an optional `.rambo.yml` file, or by using command line flags or a Ruby option hash (see above).
+
+### RAML File
+In the present version, Rambo only generates tests from a single RAML file. If you're using the command line tool, the name of this file is passed in as an argument. If you're not using the command line tool and don't specify by another means (Ruby hash, `.rambo.yml` file) which RAML file to use, Rambo will look in `your_project/doc/raml` and use the first RAML file it finds.
+
+As noted above, Rambo currently supports only Rack-based apps. Since Rails is the most popular Ruby framework, it assumes your app is a Rails app unless specified otherwise. Since Rack::Test syntax differs when testing Rails and non-Rails apps, you will need to tell Rambo if your app is not a Rails app using the `--no-rails` switch on the command line, the `{ rails: false }` option hash for the Ruby API, or specifying `rails: false` in your `.rambo.yml` file.
## About the Project
I started Rambo in March of 2016 as part of my work at [Renew Financial](http://renewfinancial.com). RF has since put a second full-time engineer on the project. For this reason, our primary focus is on adding the features and functionality that are most important for testing RF's back-end services. One of these services, Repaymnt Estimatr, forms the basis for the Rambo MVP.
Although the Repaymnt Estimatr repo is private, the key technical considerations here are that it is built with Rails 4 and documented using RAML 1.0. Rambo, therefore, considers these the default, and support for other frameworks and for RAML 0.8 is incidental and lower priority. We would be delighted to merge pull requests adding such support, as long as they don't adversely affect the features we need most.