Skip to content

Commit

Permalink
Merge pull request westfieldlabs#83 from gwshaw/82_allow_use_of_full_…
Browse files Browse the repository at this point in the history
…url_for_consistency_check

82 Allow use for full URL for consistency check
  • Loading branch information
gwshaw committed Mar 28, 2016
2 parents 7af6390 + 2198aea commit ab8c884
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apivore.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = 'apivore'
s.version = '1.5.0'
s.version = '1.6.0'
s.date = '2016-02-24'
s.summary = "Tests your API against its OpenAPI (Swagger) 2.0 spec"
s.description = "Tests your rails API using its OpenAPI (Swagger) description of end-points, models, and query parameters."
Expand Down
16 changes: 13 additions & 3 deletions lib/apivore/rspec_matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Apivore
module RspecMatchers
extend RSpec::Matchers::DSL
matcher :be_consistent_with_swagger_definitions do |master_swagger_host, current_service|
matcher :be_consistent_with_swagger_definitions do |master_swagger_url, current_service|

attr_reader :actual, :expected

Expand All @@ -22,8 +22,18 @@ module RspecMatchers
end

define_method :fetch_master_swagger do
req = Net::HTTP.get(master_swagger_host, "/swagger.json")
JSON.parse(req)
res =
if master_swagger_url.starts_with? 'http'
Net::HTTP.get_response(URI(master_swagger_url))
else
Net::HTTP.get_response(master_swagger_url, "/swagger.json")
end

unless res.is_a? Net::HTTPSuccess
message = "Master swagger at #{master_swagger_url} not accessible\n"
fail (message + res.body)
end
JSON.parse(res.body)
end

define_method :master_swagger do
Expand Down

0 comments on commit ab8c884

Please sign in to comment.