Commit e1eb984c by andrew morton Committed by GitHub

Merge pull request #6 from drewish/rename-rspec-rails-swagger

Rename to rspec-rails-swagger
parents c6b2d183 5e1f4157
# RSpec Swagger
[![Build Status](https://travis-ci.org/drewish/rspec-swagger.svg?branch=master)](https://travis-ci.org/drewish/rspec-swagger)
[![Code Climate](https://codeclimate.com/github/drewish/rspec-swagger/badges/gpa.svg)](https://codeclimate.com/github/drewish/rspec-swagger)
[![Build Status](https://travis-ci.org/drewish/rspec-rails-swagger.svg?branch=master)](https://travis-ci.org/drewish/rspec-rails-swagger)
[![Code Climate](https://codeclimate.com/github/drewish/rspec-rails-swagger/badges/gpa.svg)](https://codeclimate.com/github/drewish/rspec-rails-swagger)
This gem helps you generate Swagger docs by using RSpec to document the paths.
You execute a command to run the tests and generate the `.json` output. Running
......@@ -15,7 +15,7 @@ The design of this was heavily influenced by the awesome [swagger_rails gem](htt
- Add the gem to your Rails app's `Gemfile`:
```rb
group :development, :test do
gem 'rspec-swagger'
gem 'rspec-rails-swagger'
end
```
- If you don't already have a `spec/rails_helper.rb` file run:
......@@ -23,7 +23,7 @@ end
rails generate rspec:install
```
- Create `spec/swagger_helper.rb` file (eventually [this will become a
generator](https://github.com/drewish/rspec-swagger/issues/3)):
generator](https://github.com/drewish/rspec-rails-swagger/issues/3)):
```rb
require 'rspec/swagger'
require 'rails_helper'
......@@ -55,7 +55,7 @@ end
## Generate the docs
Eventually [this will become a rake task](https://github.com/drewish/rspec-swagger/issues/2):
Eventually [this will become a rake task](https://github.com/drewish/rspec-rails-swagger/issues/2):
```
bundle exec rspec -f RSpec::Swagger::Formatter --order defined -t swagger_object
```
......
require 'rspec/core'
require 'rspec/rails/swagger/configuration'
require 'rspec/rails/swagger/document'
require 'rspec/rails/swagger/formatter'
require 'rspec/rails/swagger/helpers'
require 'rspec/rails/swagger/request_builder'
require 'rspec/rails/swagger/version'
module RSpec
module Rails
module Swagger
initialize_configuration RSpec.configuration
end
end
end
module RSpec
module Rails
module Swagger
# Fake class to document RSpec Swagger configuration options.
class Configuration
......@@ -11,4 +12,5 @@ module RSpec
Helpers.add_swagger_type_configurations(config)
end
end
end
end
module RSpec
module Rails
module Swagger
class Document
attr_accessor :data
......@@ -27,4 +28,5 @@ module RSpec
end
end
end
end
end
require 'rspec/core/formatters/base_text_formatter'
module RSpec
module Rails
module Swagger
class Formatter < RSpec::Core::Formatters::BaseTextFormatter
RSpec::Core::Formatters.register self, :example_finished, :close
......@@ -100,4 +101,5 @@ module RSpec
end
end
end
end
end
module RSpec
module Rails
module Swagger
module Helpers
# paths: (Paths)
......@@ -253,4 +254,5 @@ module RSpec
end
end
end
end
end
module RSpec
module Rails
module Swagger
class RequestBuilder
attr_reader :metadata, :instance
......@@ -86,4 +87,5 @@ module RSpec
end
end
end
end
end
module RSpec
module Rails
# Version information for RSpec Swagger.
module Swagger
module Version
STRING = '0.1.0'
end
end
end
end
require 'rspec/core'
require 'rspec/swagger/configuration'
require 'rspec/swagger/document'
require 'rspec/swagger/formatter'
require 'rspec/swagger/helpers'
require 'rspec/swagger/request_builder'
require 'rspec/swagger/version'
module RSpec
module Swagger
initialize_configuration RSpec.configuration
end
end
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "rspec/swagger/version"
require "rspec/rails/swagger/version"
Gem::Specification.new do |s|
s.name = 'rspec-swagger'
s.version = RSpec::Swagger::Version::STRING
s.name = 'rspec-rails-swagger'
s.version = RSpec::Rails::Swagger::Version::STRING
s.licenses = ['MIT']
s.summary = "Generate Swagger docs from RSpec integration tests"
s.description = "Inspired by swagger_rails"
s.author = "andrew morton"
s.email = 'drewish@katherinehouse.com'
s.files = [
'lib/rspec/swagger.rb',
'lib/rspec/swagger/configuration.rb',
'lib/rspec/swagger/document.rb',
'lib/rspec/swagger/formatter.rb',
'lib/rspec/swagger/helpers.rb',
'lib/rspec/swagger/request_builder.rb',
'lib/rspec/swagger/version.rb',
'lib/rspec/rails/swagger.rb',
'lib/rspec/rails/swagger/configuration.rb',
'lib/rspec/rails/swagger/document.rb',
'lib/rspec/rails/swagger/formatter.rb',
'lib/rspec/rails/swagger/helpers.rb',
'lib/rspec/rails/swagger/request_builder.rb',
'lib/rspec/rails/swagger/version.rb',
]
s.homepage = 'https://github.com/drewish/rspec-swagger'
s.homepage = 'https://github.com/drewish/rspec-rails-swagger'
s.required_ruby_version = '~> 2.0'
s.add_runtime_dependency 'rails', '>= 3.1'
......
require 'swagger_helper'
RSpec.describe RSpec::Swagger::Document do
RSpec.describe RSpec::Rails::Swagger::Document do
subject { described_class.new(data) }
let(:data) { minimial_example }
......@@ -53,10 +53,10 @@ RSpec.describe RSpec::Swagger::Document do
end
def minimial_example
YAML.load_file(File.expand_path('../../../fixtures/files/minimal.yml', __FILE__))
YAML.load_file(File.expand_path('../../../../fixtures/files/minimal.yml', __FILE__))
end
def instagram_example
YAML.load_file(File.expand_path('../../../fixtures/files/instagram.yml', __FILE__))
YAML.load_file(File.expand_path('../../../../fixtures/files/instagram.yml', __FILE__))
end
end
require 'swagger_helper'
RSpec.describe RSpec::Swagger::Formatter do
RSpec.describe RSpec::Rails::Swagger::Formatter do
let(:output) { StringIO.new }
let(:formatter) { described_class.new(output) }
let(:documents) { {'minimal.json' => minimal} }
......
require 'swagger_helper'
RSpec.describe RSpec::Swagger::Helpers::Paths do
RSpec.describe RSpec::Rails::Swagger::Helpers::Paths do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::Paths
include RSpec::Rails::Swagger::Helpers::Paths
attr_accessor :metadata
def describe *args ; end
end
......@@ -36,10 +36,10 @@ RSpec.describe RSpec::Swagger::Helpers::Paths do
end
end
RSpec.describe RSpec::Swagger::Helpers::PathItem do
RSpec.describe RSpec::Rails::Swagger::Helpers::PathItem do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::PathItem
include RSpec::Rails::Swagger::Helpers::PathItem
attr_accessor :metadata
def describe *args ; end
end
......@@ -97,10 +97,10 @@ RSpec.describe RSpec::Swagger::Helpers::PathItem do
end
end
RSpec.describe RSpec::Swagger::Helpers::Parameters do
RSpec.describe RSpec::Rails::Swagger::Helpers::Parameters do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::Parameters
include RSpec::Rails::Swagger::Helpers::Parameters
attr_accessor :metadata
def describe *args ; end
def resolve_document *args ; end
......@@ -176,10 +176,10 @@ RSpec.describe RSpec::Swagger::Helpers::Parameters do
end
RSpec.describe RSpec::Swagger::Helpers::Operation do
RSpec.describe RSpec::Rails::Swagger::Helpers::Operation do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::Operation
include RSpec::Rails::Swagger::Helpers::Operation
attr_accessor :metadata
def describe *args ; end
end
......@@ -207,10 +207,10 @@ RSpec.describe RSpec::Swagger::Helpers::Operation do
end
end
RSpec.describe RSpec::Swagger::Helpers::Response do
RSpec.describe RSpec::Rails::Swagger::Helpers::Response do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::Response
include RSpec::Rails::Swagger::Helpers::Response
attr_accessor :metadata
def describe *args ; end
end
......
require 'swagger_helper'
RSpec.describe RSpec::Swagger::RequestBuilder do
RSpec.describe RSpec::Rails::Swagger::RequestBuilder do
describe '#initialize' do
it 'stores metadata and instance' do
metadata = { foo: :bar }
......
require 'swagger_helper'
RSpec.describe RSpec::Swagger do
RSpec.describe RSpec::Rails::Swagger do
it "loads" do
expect(RSpec::Swagger::Version::STRING).to eq '0.1.0'
expect(RSpec::Rails::Swagger::Version::STRING).to eq '0.1.0'
end
end
require 'rspec/swagger'
require 'rspec/rails/swagger'
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
......
require 'rspec/swagger'
require 'rspec/rails/swagger'
require 'rails_helper'
RSpec.configure do |config|
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment