Skip to content

Sinatra Support #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
`<project_root>/api_docs/arenas.txt`

Example:

Expand Down
9 changes: 7 additions & 2 deletions lib/rspec_api_blueprint.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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]
Expand All @@ -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?
Expand Down
3 changes: 2 additions & 1 deletion rspec_api_blueprint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake"

spec.add_dependency 'rspec-rails'
end
spec.add_dependency 'activesupport'
end