Commit cf36412a by andrew morton

Add a test for capture_example

parent 27841825
......@@ -173,7 +173,7 @@ module RSpec
metadata[:swagger_operation][:produces] = mime_types
end
def response status_code, attributes = {}, params = {}, &block
def response status_code, attributes = {}, &block
attributes.symbolize_keys!
validate_status_code! status_code
......
......@@ -12,7 +12,7 @@ RSpec.describe "Requestsing", type: :request do
operation "GET", summary:"fetch list" do
produces 'application/json'
response(200, {description: "successful"}, {})
response(200, {description: "successful"})
end
post summary: "create" do
......@@ -22,8 +22,7 @@ RSpec.describe "Requestsing", type: :request do
parameter "body", in: :body, schema: { foo: :bar}
let(:body) { { post: { title: 'asdf', body: "blah" } } }
# TODO: it should pull the body from the params
response(201, {description: "successfully created"}, { post: { title: 'asdf', body: "blah" } }.to_json) do
response(201, {description: "successfully created"}) do
it "uses the body we passed in" do
post = JSON.parse(response.body)
expect(post["title"]).to eq('asdf')
......@@ -42,7 +41,7 @@ RSpec.describe "Requestsing", type: :request do
produces 'application/json'
before { Post.new.save }
response(200, {description: "success"}, {}) do
response(200, {description: "success"}) do
capture_example
end
end
......
......@@ -186,7 +186,7 @@ RSpec.describe RSpec::Swagger::Helpers::Operation do
end
subject { klass.new }
describe "#response" do
describe '#response' do
before { subject.metadata = {swagger_object: :operation} }
it "requires code be an integer 100...600 or :default" do
......@@ -206,3 +206,23 @@ RSpec.describe RSpec::Swagger::Helpers::Operation do
end
end
end
RSpec.describe RSpec::Swagger::Helpers::Response do
let(:klass) do
Class.new do
include RSpec::Swagger::Helpers::Response
attr_accessor :metadata
def describe *args ; end
end
end
subject { klass.new }
before { subject.metadata = {swagger_object: :response} }
describe '#capture_example' do
it "sets the capture metadata" do
expect{ subject.capture_example }
.to change{ subject.metadata[:capture_examples] }.to(true)
end
end
end
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