Skip to content

Commit d48c626

Browse files
committed
Don't require webmock unless OAuth2MACClient is used
Closes #89
1 parent 843866b commit d48c626

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ PATH
77
json (>= 1.4.6)
88
mustache (>= 0.99.4)
99
rspec (>= 2.14.0)
10-
webmock (>= 1.7.0)
1110

1211
GEM
1312
remote: http://rubygems.org/
@@ -105,3 +104,4 @@ DEPENDENCIES
105104
rake
106105
rspec_api_documentation!
107106
sinatra
107+
webmock (>= 1.7.0)

lib/rspec_api_documentation/dsl/resource.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ def self.define_action(method)
2323
define_action :patch
2424

2525
def callback(*args, &block)
26-
require 'webmock'
26+
begin
27+
require 'webmock'
28+
rescue LoadError
29+
raise "Callbacks require webmock to be installed"
30+
end
2731
self.send(:include, WebMock::API)
2832

2933
options = if args.last.is_a?(Hash) then args.pop else {} end

lib/rspec_api_documentation/oauth2_mac_client.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
rescue LoadError
44
# ActiveSupport::SecureRandom not provided in activesupport >= 3.2
55
end
6-
require "webmock"
7-
require "rack/oauth2"
6+
begin
7+
require "webmock"
8+
rescue LoadError
9+
raise "Webmock needs to be installed before using the OAuth2MACClient"
10+
end
11+
begin
12+
require "rack/oauth2"
13+
rescue LoadError
14+
raise "Rack OAuth2 needs to be installed before using the OAuth2MACClient"
15+
end
816

917
module RspecApiDocumentation
1018
class OAuth2MACClient < ClientBase

rspec_api_documentation.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
1717
s.add_runtime_dependency "activesupport", ">= 3.0.0"
1818
s.add_runtime_dependency "i18n", ">= 0.1.0"
1919
s.add_runtime_dependency "mustache", ">= 0.99.4"
20-
s.add_runtime_dependency "webmock", ">= 1.7.0"
2120
s.add_runtime_dependency "json", ">= 1.4.6"
2221

2322
s.add_development_dependency "fakefs"
@@ -27,6 +26,7 @@ Gem::Specification.new do |s|
2726
s.add_development_dependency "rake"
2827
s.add_development_dependency "rack-test", ">= 0.6.2"
2928
s.add_development_dependency "rack-oauth2", ">= 0.14.4"
29+
s.add_development_dependency "webmock", ">= 1.7.0"
3030

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

0 commit comments

Comments
 (0)