Permalink
Browse files

Merge pull request #4 from seomoz/message-type-and-status-code

Message type and status code
  • Loading branch information...
2 parents 2494741 + f5a48f6 commit 301263d4eac4c35bca3e9aca647b6914f1f7d503 proby committed Jun 12, 2012
View
13 README.md
@@ -51,7 +51,9 @@ name: user_projects
route: /users/:user_id/projects
method: GET
definitions:
- - versions: ["1.0"]
+ - message_type: response
+ versions: ["1.0"]
+ status_codes: ["2xx", "404"]
schema:
description: Returns a list of projects for the given user.
type: object
@@ -94,8 +96,17 @@ Let's look at this YAML file, point-by-point:
* The `definitions` array contains a list of versioned schema definitions, with
corresponding examples. Everytime you modify your schema and change the version,
you should add a new entry here.
+* The `message_type` describes whether the following schema is for requests or responses.
+ It is an optional attribute that when omitted defaults to response. The only valid values
+ are `request` and `response`.
* The `versions` array lists the endpoint versions that should be associated with a
particular schema definition.
+* The `status_codes` is an optional array of status code strings describing for which
+ status code or codes this schema applies to. `status_codes` is ignored if used with the
+ `request` `message_type`. When used with the `response` `message_type` it is an optional
+ attribute that defaults to all status codes. Valid formats for a status code are 3
+ characters. Each character must be a digit (0-9) or 'x' (wildcard). The following strings
+ are all valid: "200", "4xx", "x0x".
* The `schema` contains a [JSON schema](http://tools.ietf.org/html/draft-zyp-json-schema-03)
description of the contents of the endpoint. This schema definition is used by the
`SchemaValidation` middleware to ensure that your implementation of the endpoint
View
2 Rakefile 100644 → 100755
@@ -12,7 +12,7 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' # MRI only
desc "Run cane to check quality metrics"
Cane::RakeTask.new(:quality) do |cane|
- cane.abc_max = 12
+ cane.abc_max = 16
cane.add_threshold 'coverage/coverage_percent.txt', :==, 100
cane.style_measure = 100
end
View
87 example/definitions/add_address.yml
@@ -0,0 +1,87 @@
+---
+name: add_contact_address
+route: /contacts/:contact_id/address
+method: PUT
+definitions:
+ - message_type: request
+ versions: ["1.0"]
+ schema:
+ description: Adds a new address for a contact.
+ type: object
+ properties:
+ street:
+ description: "Street address"
+ type: string
+ city:
+ description: "The City"
+ type: string
+ state:
+ description: "The State"
+ type: string
+ zip:
+ description: "Zip code"
+ type: string
+ examples:
+ - street: 1300 Pine St.
+ city: Seattle
+ state: WA
+ zip: '98111'
+ - message_type: request
+ versions: ["2.0"]
+ schema:
+ description: Adds a new address for a contact.
+ type: object
+ properties:
+ street:
+ description: "Street address"
+ type: string
+ apartment:
+ description: "Apartment number"
+ type: string
+ optional: true
+ city:
+ description: "The City"
+ type: string
+ state:
+ description: "The State"
+ type: string
+ postal:
+ description: "Postal code"
+ type: string
+ examples:
+ - street: 1300 Pine St.
+ apartment: 'Suite 400'
+ city: Seattle
+ state: WA
+ postal: '98111'
+ - message_type: response
+ versions: ["1.0"]
+ status_codes: ["2xx"]
+ schema:
+ description: Successfully added an address for a contact.
+ type: object
+ properties:
+ added_address_id:
+ description: "The id of the newly added address"
+ type: integer
+ contact_address_count:
+ description: "The number of addresses for this contact after adding the new one"
+ type: integer
+ examples:
+ - added_address_id: 2185
+ contact_address_count: 5
+ - message_type: response
+ versions: ["1.0"]
+ schema:
+ description: Error messaging for failure to add the new address for a contact.
+ type: object
+ properties:
+ error_code:
+ description: "Error code value for the failure reason"
+ type: integer
+ error_message:
+ description: "Human readable failure message"
+ type: string
+ examples:
+ - error_code: 34
+ error_message: Address already exists for this contact
View
11 lib/interpol/configuration.rb
@@ -8,14 +8,21 @@ module DefinitionFinder
include HashFetcher
NoDefinitionFound = Class.new
- def find_definition(method, path)
+ def find_definition(method, path, message_type, status_code = nil)
with_endpoint_matching(method, path) do |endpoint|
version = yield endpoint
- endpoint.definitions.find { |d| d.version == version }
+ find_definitions_for(endpoint, version, message_type).find do |definition|
+ definition.matches_status_code?(status_code)
+ end
end
end
private
+ def find_definitions_for(endpoint, version, message_type)
+ endpoint.definitions.find do |d|
+ d.first.version == version && d.first.message_type == message_type
+ end || []
+ end
def with_endpoint_matching(method, path)
method = method.downcase.to_sym
View
16 lib/interpol/documentation_app/views/endpoint.erb
@@ -3,13 +3,15 @@
<h1><%= endpoint.name %></h1>
<h2><%= endpoint.method.to_s.upcase %> <%= endpoint.route %></h2>
- <% endpoint.definitions.reverse.each do |definition| %>
- <div class="versioned-endpoint-definition">
- <h3>Version <%= definition.version %></h3>
- <hr>
-
- <%= Interpol::Documentation.html_for_schema(definition.schema) %>
- </div>
+ <% endpoint.definitions.each do |definitions| %>
+ <% definitions.each do |definition| %>
+ <div class="versioned-endpoint-definition">
+ <h3><%= definition.message_type.capitalize %> - Version <%= definition.version %> - <%= definition.status_codes %></h3>
+ <br/>
+ <%= Interpol::Documentation.html_for_schema(definition.schema) %>
+ </div>
+ <hr/>
+ <% end %>
<% end %>
</div>
</div><!--/span-->
View
108 lib/interpol/endpoint.rb
@@ -27,23 +27,36 @@ def initialize(endpoint_hash)
validate_name!
end
- def find_definition!(version)
- @definitions.fetch(version) do
+ def find_definition!(version, message_type)
+ @definitions.fetch([message_type, version]) do
message = "No definition found for #{name} endpoint for version #{version}"
+ message << " and message_type #{message_type}"
raise ArgumentError.new(message)
end
end
- def find_example_for!(version)
- find_definition!(version).examples.first
+ def find_example_for!(version, message_type)
+ find_definition!(version, message_type).first.examples.first
+ end
+
+ def find_example_status_code_for!(version)
+ find_definition!(version, 'response').first.example_status_code
end
def available_versions
- definitions.map(&:version)
+ definitions.map { |d| d.first.version }
end
def definitions
- @definitions.values.sort_by(&:version)
+ # sort all requests before all responses
+ # sort higher version numbers before lower version numbers
+ @definitions.values.sort do |x,y|
+ if x.first.message_type == y.first.message_type
+ y.first.version <=> x.first.version
+ else
+ x.first.message_type <=> y.first.message_type
+ end
+ end
end
def route_matches?(path)
@@ -66,12 +79,16 @@ def route_regex
end
end
+ DEFAULT_MESSAGE_TYPE = 'response'
+
def extract_definitions_from(endpoint_hash)
- definitions = {}
+ definitions = Hash.new { |h, k| h[k] = [] }
fetch_from(endpoint_hash, 'definitions').each do |definition|
fetch_from(definition, 'versions').each do |version|
- definitions[version] = EndpointDefinition.new(name, version, definition)
+ message_type = definition.fetch('message_type', DEFAULT_MESSAGE_TYPE)
+ key = [message_type, version]
+ definitions[key] << EndpointDefinition.new(name, version, message_type, definition)
end
end
@@ -90,13 +107,15 @@ def validate_name!
# Provides the means to validate data against that version of the schema.
class EndpointDefinition
include HashFetcher
- attr_reader :endpoint_name, :version, :schema, :examples
-
- def initialize(endpoint_name, version, definition)
- @endpoint_name = endpoint_name
- @version = version
- @schema = fetch_from(definition, 'schema')
- @examples = fetch_from(definition, 'examples').map { |e| EndpointExample.new(e, self) }
+ attr_reader :endpoint_name, :message_type, :version, :schema, :examples
+
+ def initialize(endpoint_name, version, message_type, definition)
+ @endpoint_name = endpoint_name
+ @message_type = message_type
+ @status_codes = StatusCodeMatcher.new(definition['status_codes'])
+ @version = version
+ @schema = fetch_from(definition, 'schema')
+ @examples = fetch_from(definition, 'examples').map { |e| EndpointExample.new(e, self) }
make_schema_strict!(@schema)
end
@@ -108,7 +127,19 @@ def validate_data!(data)
end
def description
- "#{endpoint_name} (v. #{version})"
+ "#{endpoint_name} (v. #{version}, mt. #{message_type}, sc. #{status_codes})"
+ end
+
+ def status_codes
+ @status_codes.code_strings.join(',')
+ end
+
+ def matches_status_code?(status_code)
+ status_code.nil? || @status_codes.matches?(status_code)
+ end
+
+ def example_status_code
+ @example_status_code ||= @status_codes.example_status_code
end
private
@@ -127,6 +158,49 @@ def make_schema_strict!(raw_schema, modify_object=true)
end
end
+ # Holds the acceptable status codes for an enpoint entry
+ # Acceptable status code are either exact status codes (200, 404, etc)
+ # or partial status codes (2xx, 3xx, 4xx, etc). Currently, partial status
+ # codes can only be a digit followed by two lower-case x's.
+ class StatusCodeMatcher
+ attr_reader :code_strings
+
+ def initialize(codes)
+ codes = ["xxx"] if Array(codes).empty?
+ @code_strings = codes
+ validate!
+ end
+
+ def matches?(status_code)
+ code_regexes.any? { |re| re =~ status_code.to_s }
+ end
+
+ def example_status_code
+ example_status_code = "200"
+ code_strings.first.chars.each_with_index do |char, index|
+ example_status_code[index] = char if char != 'x'
+ end
+ example_status_code
+ end
+
+ private
+ def code_regexes
+ @code_regexes ||= code_strings.map do |string|
+ /\A#{string.gsub('x', '\d')}\z/
+ end
+ end
+
+ def validate!
+ code_strings.each do |code|
+ # ensure code is 3 characters and all chars are a number or 'x'
+ # http://rubular.com/r/4sl68Bb4XO
+ unless code =~ /\A[\dx]{3}\Z/
+ raise StatusCodeMatcherArgumentError, "#{code} is not a valid format"
+ end
+ end
+ end
+ end
+
# Wraps an example for a particular endpoint entry.
class EndpointExample
attr_reader :data, :definition
@@ -140,5 +214,3 @@ def validate!
end
end
end
-
-
View
3 lib/interpol/errors.rb
@@ -31,5 +31,8 @@ def initialize(errors = [], data = nil, endpoint_description = '')
# Error raised when the schema validator cannot find a matching
# endpoint definition for the request.
class NoEndpointDefinitionFoundError < Error; end
+
+ # Raised when an invalid status code is found during validate_codes!
+ class StatusCodeMatcherArgumentError < ArgumentError; end
end
View
3 lib/interpol/response_schema_validator.rb
@@ -67,7 +67,8 @@ def path
end
def validator
- @validator ||= @config.endpoints.find_definition(request_method, path) do |endpoint|
+ @validator ||= @config.endpoints.
+ find_definition(request_method, path, 'response', status) do |endpoint|
@config.api_version_for(env, endpoint)
end
end
View
8 lib/interpol/stub_app.rb
@@ -18,8 +18,8 @@ def interpol_config
self.class.interpol_config
end
- def example_for(endpoint, version)
- endpoint.find_example_for!(version)
+ def example_for(endpoint, version, message_type)
+ endpoint.find_example_for!(version, message_type)
rescue ArgumentError
interpol_config.request_version_unavailable(self, version, endpoint.available_versions)
end
@@ -49,8 +49,10 @@ def build
def endpoint_definition(endpoint)
lambda do
version = interpol_config.api_version_for(request.env, endpoint)
- example = example_for(endpoint, version)
+ message_type = 'response'
+ example = example_for(endpoint, version, message_type)
example.validate!
+ status endpoint.find_example_status_code_for!(version)
JSON.dump(example.data)
end
end
View
8 lib/interpol/test_helper.rb
@@ -5,9 +5,11 @@ module TestHelper
module Common
def each_example_from(endpoints)
endpoints.each do |endpoint|
- endpoint.definitions.each do |definition|
- definition.examples.each_with_index do |example, index|
- yield endpoint, definition, example, index
+ endpoint.definitions.each do |definitions|
+ definitions.each do |definition|
+ definition.examples.each_with_index do |example, index|
+ yield endpoint, definition, example, index
+ end
end
end
end
View
66 spec/unit/interpol/configuration_spec.rb
@@ -4,59 +4,89 @@
module Interpol
describe DefinitionFinder do
describe '#find_definition' do
- def endpoint(name, method, route, *versions)
+ def endpoint_def(message_type, status_codes, *versions)
+ {
+ 'versions' => versions,
+ 'message_type' => message_type,
+ 'status_codes' => status_codes,
+ 'schema' => {},
+ 'examples' => {}
+ }
+ end
+
+ def endpoint(name, method, route, *endpoint_defs)
Endpoint.new \
- 'name' => 'endpoint_name',
+ 'name' => name,
'route' => route,
'method' => method,
- 'definitions' => [{
- 'versions' => versions,
- 'schema' => {},
- 'examples' => {}
- }]
+ 'definitions' => endpoint_defs
end
- let(:endpoint_1) { endpoint 'e1', 'GET', '/users/:user_id/overview', '1.3' }
- let(:endpoint_2) { endpoint 'e2', 'POST', '/foo/bar', '2.3', '2.7' }
+ let(:endpoint_def_1a) { endpoint_def('response', ['2xx'], '1.3') }
+ let(:endpoint_def_1b) { endpoint_def('response', nil, '1.3') }
+ let(:endpoint_def_2a) { endpoint_def('request', nil, '2.3', '2.7') }
+
+ let(:endpoint_1) do
+ endpoint 'e1', 'GET', '/users/:user_id/overview', endpoint_def_1a, endpoint_def_1b
+ end
+ let(:endpoint_2) { endpoint 'e2', 'POST', '/foo/bar', endpoint_def_2a}
let(:all_endpoints) { [endpoint_1, endpoint_2].extend(DefinitionFinder) }
def find(options)
- all_endpoints.find_definition(options[:method], options[:path]) { |e| options[:version] }
+ find_with_status_code(nil, options)
+ end
+
+ def find_with_status_code(status_code, options)
+ all_endpoints.find_definition(options[:method], options[:path],
+ options[:message_type], status_code) { |e| options[:version] }
end
it 'finds a matching endpoint definition' do
- found = find(:method => 'POST', :path => '/foo/bar', :version => '2.3')
+ found = find(:method => 'POST', :path => '/foo/bar',
+ :version => '2.3', :message_type => 'request')
found.endpoint_name.should eq(endpoint_2.name)
found.version.should eq('2.3')
end
it 'finds the correct versioned definition of the endpoint' do
- found = find(:method => 'POST', :path => '/foo/bar', :version => '2.7')
+ found = find(:method => 'POST', :path => '/foo/bar',
+ :version => '2.7', :message_type => 'request')
found.version.should eq('2.7')
end
it 'calls the version block with the endpoint' do
endpoint = nil
- all_endpoints.find_definition('POST', '/foo/bar') do |e|
+ all_endpoints.find_definition('POST', '/foo/bar', 'request') do |e|
endpoint = e
end
endpoint.should be(endpoint_2)
end
it 'returns NoDefinitionFound if it cannot find a matching route' do
- result = find(:method => 'POST', :path => '/goo/bar', :version => '2.7')
+ result = find(:method => 'POST', :path => '/goo/bar',
+ :version => '2.7', :message_type => 'request')
result.should be(DefinitionFinder::NoDefinitionFound)
end
it 'returns nil if the endpoint does not have a matching version' do
- result = find(:method => 'POST', :path => '/foo/bar', :version => '13.7')
+ result = find(:method => 'POST', :path => '/foo/bar',
+ :version => '13.7', :message_type => 'request')
result.should be(DefinitionFinder::NoDefinitionFound)
end
it 'handles route params properly' do
- found = find(:method => 'GET', :path => '/users/17/overview', :version => '1.3')
+ found = find_with_status_code('200', :method => 'GET', :path => '/users/17/overview',
+ :version => '1.3', :message_type => 'response')
+ found.endpoint_name.should be(endpoint_1.name)
+ found.status_codes.should eq('2xx')
+ end
+
+ it 'handles status code params properly' do
+ found = find_with_status_code('403', :method => 'GET', :path => '/users/17/overview',
+ :version => '1.3', :message_type => 'response')
found.endpoint_name.should be(endpoint_1.name)
+ found.status_codes.should eq('xxx')
end
end
end
@@ -138,7 +168,9 @@ def find(options)
def assert_expected_endpoint
config.endpoints.size.should eq(1)
endpoint = config.endpoints.first
- endpoint.definitions.first.schema.fetch("properties").should have_key("name")
+ endpoint.definitions.first.each do |definitions|
+ definitions.schema.fetch("properties").should have_key("name")
+ end
end
it 'supports the merge keys when configured before the endpoint definition files' do
View
124 spec/unit/interpol/endpoint_spec.rb
@@ -54,31 +54,48 @@ def build_hash(hash = {})
'examples' => ['e1', 'e2']
}] end
+ let(:request_definition_array) do [{
+ 'versions' => ['1.1'],
+ 'message_type' => 'request',
+ 'schema' => {'a' => ' request schema'},
+ 'examples' => ['e1', 'e2']
+ }] end
+
describe "#definitions" do
it 'returns each definition object, ordered by version' do
endpoint = Endpoint.new(build_hash('definitions' => definitions_array))
- endpoint.definitions.map(&:version).should eq(%w[ 1.2 3.2 ])
+ endpoint.definitions.map{|d|d.first.version}.should eq(%w[ 3.2 1.2 ])
end
+
+ it 'returns each definition object, ordered by message type' do
+ full_definitions_array = (definitions_array + request_definition_array)
+ endpoint = Endpoint.new(build_hash('definitions' => full_definitions_array))
+ endpoint.definitions.map{|d|d.first.version}.should eq(%w[ 1.1 3.2 1.2 ])
+ endpoint.definitions.map{|d|d.first.message_type}.should eq(%w[ request response response ])
+ end
+
end
describe "#available_versions" do
it 'returns the list of available version strings, ordered by version' do
endpoint = Endpoint.new(build_hash('definitions' => definitions_array))
- endpoint.available_versions.should eq(%w[ 1.2 3.2 ])
+ endpoint.available_versions.should eq(%w[ 3.2 1.2 ])
end
end
describe "#find_definition!" do
let(:hash) { build_hash('definitions' => definitions_array) }
let(:endpoint) { Endpoint.new(hash) }
- it 'finds the definition matching the given version' do
- endpoint.find_definition!('1.2').version.should eq('1.2')
+ it 'finds the definition matching the given version and message_type' do
+ definitions = endpoint.find_definition!('1.2', 'response')
+ definitions.first.version.should eq('1.2')
+ definitions.first.message_type.should eq('response')
end
it 'raises an error when given a version that matches no definition' do
expect {
- endpoint.find_definition!('2.1')
+ endpoint.find_definition!('2.1', 'response')
}.to raise_error(ArgumentError)
end
end
@@ -88,12 +105,12 @@ def build_hash(hash = {})
let(:endpoint) { Endpoint.new(hash) }
it 'returns an example for the requested version' do
- endpoint.find_example_for!('1.2').data.should eq('e1')
+ endpoint.find_example_for!('1.2', 'response').data.should eq('e1')
end
it 'raises an error when given a version it does not have' do
expect {
- endpoint.find_example_for!('2.1')
+ endpoint.find_example_for!('2.1', 'response')
}.to raise_error(ArgumentError)
end
end
@@ -142,28 +159,43 @@ def build_hash(hash = {})
let(:version) { '1.0' }
it 'initializes the endpoint_name' do
- EndpointDefinition.new("e-name", version, build_hash).endpoint_name.should eq("e-name")
+ endpoint_def = EndpointDefinition.new("e-name", version, 'response', build_hash)
+ endpoint_def.endpoint_name.should eq("e-name")
end
it 'initializes the version' do
- EndpointDefinition.new("name", '2.3', build_hash).version.should eq('2.3')
+ endpoint_def = EndpointDefinition.new("name", '2.3', 'response', build_hash)
+ endpoint_def.version.should eq('2.3')
+ end
+
+ it 'default initialized the message type' do
+ endpoint_def = EndpointDefinition.new("name", '2.3', 'response', build_hash)
+ endpoint_def.message_type.should eq('response')
+ end
+
+ it 'initializes the message type' do
+ hash = build_hash('message_type' => 'request')
+ endpoint_def = EndpointDefinition.new("name", '2.3', 'request', hash)
+ endpoint_def.message_type.should eq('request')
end
it 'initializes the example data' do
- v = EndpointDefinition.new("name", version, build_hash('examples' => [{'a' => 5}]))
+ hash = build_hash('examples' => [{'a' => 5}])
+ v = EndpointDefinition.new("name", version, 'response', hash)
v.examples.map(&:data).should eq([{ 'a' => 5 }])
end
it 'initializes the schema' do
- v = EndpointDefinition.new("name", version, build_hash('schema' => {'the' => 'schema'}))
+ hash = build_hash('schema' => {'the' => 'schema'})
+ v = EndpointDefinition.new("name", version, 'response', hash)
v.schema['the'].should eq('schema')
end
%w[ examples schema ].each do |attr|
it "raises an error if not initialized with '#{attr}'" do
hash = build_hash.reject { |k, v| k == attr }
expect {
- EndpointDefinition.new("name", version, hash)
+ EndpointDefinition.new("name", version, 'response', hash)
}.to raise_error(/key not found.*#{attr}/)
end
end
@@ -174,7 +206,9 @@ def build_hash(hash = {})
'properties' => {'foo' => { 'type' => 'integer' } }
} end
- subject { EndpointDefinition.new("e-name", version, build_hash('schema' => schema)) }
+ subject {
+ EndpointDefinition.new("e-name", version, 'response', build_hash('schema' => schema))
+ }
it 'raises a validation error when given data of the wrong type' do
expect {
@@ -194,7 +228,8 @@ def build_hash(hash = {})
end
it 'rejects unrecognized data types' do
- pending "waiting for my json-schema PR to be merged: https://github.com/hoxworth/json-schema/pull/37" do
+ pending "waiting for my json-schema PR to be merged: " +
+ "https://github.com/hoxworth/json-schema/pull/37" do
schema['properties']['foo']['type'] = 'sting'
expect {
subject.validate_data!('foo' => 'bar')
@@ -288,6 +323,67 @@ def build_hash(hash = {})
end
end
+ describe StatusCodeMatcher do
+ describe "#new" do
+ it 'initializes the codes for nil' do
+ StatusCodeMatcher.new(nil).code_strings.should == ['xxx']
+ end
+
+ it 'initializs the codes for a single code' do
+ StatusCodeMatcher.new(['200']).code_strings.should == ["200"]
+ end
+
+ it 'initializs the codes for a multiple codes' do
+ StatusCodeMatcher.new(['200', '4xx', 'x0x']).code_strings.should == ['200', '4xx', 'x0x']
+ end
+
+ it 'should raise an error for invalid status code formats' do
+ expect {
+ StatusCodeMatcher.new(['200', '4y4'])
+ }.to raise_error(StatusCodeMatcherArgumentError)
+
+ expect {
+ StatusCodeMatcher.new(['2000', '404'])
+ }.to raise_error(StatusCodeMatcherArgumentError)
+ end
+ end
+
+ describe "#matches?" do
+ let(:nil_codes_subject) { StatusCodeMatcher.new(nil) }
+ it 'returns true when codes is nil' do
+ nil_codes_subject.matches?('200').should be_true
+ end
+
+ subject { StatusCodeMatcher.new(['200', '4xx', 'x5x']) }
+ it 'returns true for an exact match' do
+ subject.matches?('200').should be_true
+ end
+
+ it 'returns true for a partial matches' do
+ subject.matches?('401').should be_true
+ subject.matches?('454').should be_true
+ end
+
+ it 'returns false for no matches' do
+ subject.matches?('202').should be_false
+ end
+ end
+
+ describe '#example_status_code' do
+ it 'returns a valid example status code when a specific status code was given' do
+ StatusCodeMatcher.new(['404']).example_status_code.should == '404'
+ end
+
+ it 'returns a valid example status code when no status codes were given' do
+ StatusCodeMatcher.new(nil).example_status_code.should == '200'
+ end
+
+ it 'returns a valid example status code based on the first status code' do
+ StatusCodeMatcher.new(['4xx', 'x0x']).example_status_code.should == '400'
+ end
+ end
+ end
+
describe EndpointExample do
describe "#validate!" do
let(:definition) { fire_double("Interpol::EndpointDefinition") }
View
2 spec/unit/interpol/response_schema_validator_spec.rb
@@ -80,7 +80,7 @@ def stub_lookup(v = validator)
validator.should_receive(:validate_data!).with("a" => "b")
default_definition_finder.should_receive(:find_definition).
- with("GET", "/search/200/overview").
+ with("GET", "/search/200/overview", "response", 200).
and_return(validator)
get '/search/200/overview'
View
2 spec/unit/interpol/stub_app_spec.rb
@@ -101,7 +101,7 @@ def parsed_body
end
let(:endpoint_example) do
- endpoint.find_example_for!('1.0')
+ endpoint.find_example_for!('1.0', 'response')
end
it 'performs validations by default' do

0 comments on commit 301263d

Please sign in to comment.