Skip to content
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

Rspec Documentation for Sinatra #10

Open
ChrisCPO opened this issue Sep 13, 2017 · 3 comments
Open

Rspec Documentation for Sinatra #10

ChrisCPO opened this issue Sep 13, 2017 · 3 comments

Comments

@ChrisCPO
Copy link

ChrisCPO commented Sep 13, 2017

Hi I have a rather simple service Sinatra, tested via Rspec, The Other API are Node applications and are using API Blueprints. I would like all of the documentation to match, so I found this little awesome gem you made.

the only issue I'm having is when I run rspec spec --tag apidoc -f ApiBlueprint --out spec/apispec.md in the console I get an empty spec/apispec.md file.

my spec_helper.rb there is no rails_helper.rb as this is sinatra could that be a problem?

require 'rack/test'
require 'rspec'
require "pry"

ENV['RACK_ENV'] = 'test'

Dir["#{Dir.pwd}/spec/support/**/*.rb"].sort.each { |file| require file }
require File.expand_path '../../app.rb', __FILE__

module Requests
  include ResponseHelpers

end

module RSpecMixin
  include Rack::Test::Methods
  include Requests
  def app() API end
end

# For RSpec 2.x and 3.x
RSpec.configure do |config|
  config.include RSpecMixin

  config.around(:each) do |example|
    DB.transaction(:rollback=>:always, :auto_savepoint=>true){example.run}
  end
end

UPDATE

digging into this a little bit in ApiBlueprint#example_passed the following line is rasing an error
@example_group_instance = notification.example.example_group_instance notification is undefined.

@nambrot
Copy link
Owner

nambrot commented Sep 13, 2017

Chris, thank you for opening this issue. I unfortunately am not really familiar with Sinatra, my guess would be that the gem is assuming certain fields to be accessible that come from the Rails request cycle. There is nothing inherent that requires it to be like that, I imagine we could make it Rack compliant, so definitely feel free to open a PR if end up going down that route.

@ChrisCPO
Copy link
Author

@nambrot I have updated my comment, with a possible issue I'm not familiar with implementing plugins for Rspec. Any documentation you can point me to would be awesome.

Thanks for the quick response!

@nambrot
Copy link
Owner

nambrot commented Sep 13, 2017

It's not a super complex gem, the main logic is in https://github.com/nambrot/rspec-api-blueprint-formatter/blob/master/lib/api_blueprint/example_formatter.rb

Basically at the end of a test, we just look for metadata on it, and if it matches we print it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants