Skip to content

Commit

Permalink
Don't require webmock unless OAuth2MACClient is used
Browse files Browse the repository at this point in the history
Closes #89
  • Loading branch information
oestrich committed Oct 29, 2013
1 parent 843866b commit d48c626
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ PATH
json (>= 1.4.6)
mustache (>= 0.99.4)
rspec (>= 2.14.0)
webmock (>= 1.7.0)

GEM
remote: http://rubygems.org/
Expand Down Expand Up @@ -105,3 +104,4 @@ DEPENDENCIES
rake
rspec_api_documentation!
sinatra
webmock (>= 1.7.0)
6 changes: 5 additions & 1 deletion lib/rspec_api_documentation/dsl/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def self.define_action(method)
define_action :patch

def callback(*args, &block)
require 'webmock'
begin
require 'webmock'
rescue LoadError
raise "Callbacks require webmock to be installed"
end
self.send(:include, WebMock::API)

options = if args.last.is_a?(Hash) then args.pop else {} end
Expand Down
12 changes: 10 additions & 2 deletions lib/rspec_api_documentation/oauth2_mac_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
rescue LoadError
# ActiveSupport::SecureRandom not provided in activesupport >= 3.2
end
require "webmock"
require "rack/oauth2"
begin
require "webmock"
rescue LoadError
raise "Webmock needs to be installed before using the OAuth2MACClient"
end
begin
require "rack/oauth2"
rescue LoadError
raise "Rack OAuth2 needs to be installed before using the OAuth2MACClient"
end

module RspecApiDocumentation
class OAuth2MACClient < ClientBase
Expand Down
2 changes: 1 addition & 1 deletion rspec_api_documentation.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "activesupport", ">= 3.0.0"
s.add_runtime_dependency "i18n", ">= 0.1.0"
s.add_runtime_dependency "mustache", ">= 0.99.4"
s.add_runtime_dependency "webmock", ">= 1.7.0"
s.add_runtime_dependency "json", ">= 1.4.6"

s.add_development_dependency "fakefs"
Expand All @@ -27,6 +26,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake"
s.add_development_dependency "rack-test", ">= 0.6.2"
s.add_development_dependency "rack-oauth2", ">= 0.14.4"
s.add_development_dependency "webmock", ">= 1.7.0"

s.files = Dir.glob("lib/**/*") + Dir.glob("templates/**/*")
s.require_path = 'lib'
Expand Down

0 comments on commit d48c626

Please sign in to comment.