diff --git a/README.md b/README.md index 6fa4738..c330fca 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ Write tests using the following convention: - Tests must be placed in `spec/requests` folder or they have to be tagged with `type: :request` - Top level descriptions are named after the model (plural form) followed by the word “Requests”. For a example model called Arena it would be “Arenas Requests”. - Second level descriptions are actions in the form of “VERB path”. For the show action of the Arenas controller it would be “GET /arenas/{id}”. +- Run your specs as normal and files named after the plural form of the model will + be created in a folder at the root directory of your project named +'/api_docs'. The documentation for Arenas would be at +`/api_docs/arenas.txt` Example: diff --git a/lib/rspec_api_blueprint.rb b/lib/rspec_api_blueprint.rb index 35d8759..6c015b9 100644 --- a/lib/rspec_api_blueprint.rb +++ b/lib/rspec_api_blueprint.rb @@ -1,6 +1,8 @@ require "rspec_api_blueprint/version" require "rspec_api_blueprint/string_extensions" +require "active_support/all" + RSpec.configure do |config| config.before(:suite) do @@ -17,7 +19,7 @@ end end - config.after(:each, type: :request) do + config.after(:each, type: :request) do |example| response ||= last_response request ||= last_request @@ -27,7 +29,7 @@ while example_group example_groups << example_group - example_group = example_group[:example_group] + example_group = example_group[:parent_example_group] end action = example_groups[-2][:description_args].first if example_groups[-2] @@ -46,6 +48,9 @@ # Request request_body = request.body.read + if !request_body.present? + request_body = request.params.to_json + end authorization_header = request.env ? request.env['Authorization'] : request.headers['Authorization'] if request_body.present? || authorization_header.present? diff --git a/rspec_api_blueprint.gemspec b/rspec_api_blueprint.gemspec index 15cec02..71e2b9a 100644 --- a/rspec_api_blueprint.gemspec +++ b/rspec_api_blueprint.gemspec @@ -22,4 +22,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake" spec.add_dependency 'rspec-rails' -end \ No newline at end of file + spec.add_dependency 'activesupport' +end