Coder Social home page Coder Social logo

rspec_api_blueprint's People

Contributors

xyzjace avatar zdne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rspec_api_blueprint's Issues

Response body not generated when request not present

The default rspec request content_type is application/x-www-form-urlencoded, so the response body is not generated.

# GET /v2/connections{?from,to}

+ Response 200 application/json

I think line 69 should read response.content_type instead of request.content_type.

  if response.body.present? && response.content_type == 'application/json'

Allow markdown docs to be inserted in the generated blueprint

So, we have this idea for the ideal workflow:

  1. Write your request specs
  2. Run your request specs and the whole apib file will be generated for you

There are two things missing to get to this state:

  • copy markdown docs to the generated txt (or better .md)
  • concat generated files to one apib file (will open another issue)

I can imagine the docs would either be in the source file (controller) or spec file. I'd probably go with the spec file as it will keep the information in one place, and also implementation will be easier.

The gem should copy the markdown docs from comments and place them in the generated file.

# Arena represents a combat room.
#
# Attributes:
#
# - `name` - arena name
# - `owner` - user who created the arena
describe 'Arenas Requests' do

  # Fetch information about an arena.
  describe 'GET /v1/arenas/{id}' do
    it 'responds with the requested arena' do
      arena = create :arena, foursquare_id: '5104'
      get v1_arena_path(arena)

      response.status.should eq(200)
    end
  end

end

Would generate

# Group Arenas
Arena represents a combat room.

Attributes:

- `name` - arena name
- `owner` - user who created the arena

## GET /v1/arenas/{id}
Fetch information about an arena.

+ Response 200 (application/json)

    {
      "arena": {
        "id": "4e9dbbc2-830b-41a9-b7db-9987735a0b2a",
        "name": "Clinton St. Baking Co. & Restaurant",
        "latitude": 40.721294,
        "longitude": -73.983994,
        "foursquare_id": "5104"
      }
    }

Rspec error when used with Rack::Test::Methods

The following error occurs when I try to test my JSON API with Rack::Test::Methods and the last_response variable:

Failure/Error: Unable to find matching line from backtrace 'example' is not available from within an example (e.g. an 'it' block) or from constructs that run in the scope of an example (e.g. 'before', 'let', etc). It is only available on an example group (e.g. a 'describe' or 'context' block).

Any idea how I can solve this issue?

Is this still maintained?

Hey @matteodepalo, is this gem still maintained? If you're not using it anymore, can you maybe provide someone admin rights so issues/PRs don't stale? There are things from 2013 here.

I need this for my project and I'd love to see this moving forward.

undefined local variable or method `last_response'

Hi, I'm trying use this gem to generate a blueprint.

When I execute bundle exec rspec, show this error:

undefined local variable or method `last_response' for #RSpec::ExampleGroups::UsersRequests::GETApiUsers:0x007fafa6bde540

I'm using Rails 4.1.4, Rspec 3.0.0

output, and example scope issue.

I must be missing something or/but the documentation is poor on this subject.

How do I actually create the output file? and where does it create it at?

cheers

UPDATE
ok I see it creates a folder ./api_docs in the app's root directory, I was using git status to check for file modifications. Why does this folder not show up in git? my .gitignore has not been modified.

UPDATE
til: git does not track empty folders.

Upon getting the gem to work in Sinatra app, I came across a few issues,
in my app I have a simple around(:each) hook

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

which when used in conjunction with this gem was rasing the following error:

        `example` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).
     # ./spec/spec_helper.rb:27:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:27:in `block (2 levels) in <top (required)>'

spec was trying to call example from within another example.
This is a simple fix.

I have opened a pr that address this issue and a allows this gem to work in a non Rails app, though still needs to be tested with Rack::Test and rspec.

pr #19

@controller is nil

I have model's controller in the path app/controller/v1/models_controller.rb and setup my tests as:
describe "Models Requests" do
describe 'POST /v1/model' do
end
end

When I run bundle exec rspec

I receive a RuntimeError:@controller is nil: make sure you set it in your test's setup method.

Info: Matter Compiler

For what it's worth I just wanted to let you know that I have finished a gem that converts AST and AST serialization media types into the API Blueprint format โ€“ Matter Compiler.

You can feed it with a JSON, YAML or in your case directly build the AST at runtime and then just call Blueprint.serialize to get the formatted API Blueprint Markdown.

Using the Matter Compiler would essentially nullify the need for Rspec Api Blueprint to understand the API Blueprint syntax, it would only need to build its AST.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.