lib/fdoc/spec_watcher.rb in fdoc-0.2.5 vs lib/fdoc/spec_watcher.rb in fdoc-0.2.6
- old
+ new
@@ -1,14 +1,16 @@
+require 'json'
+
module Fdoc
module SpecWatcher
VERBS = [:get, :post, :put, :delete]
VERBS.each do |verb|
define_method(verb) do |*params|
action, request_params = params
- request_params = if request_params.kind_of(Hash)
+ request_params = if request_params.kind_of?(Hash)
request_params
else
begin
JSON.parse(request_params)
rescue
@@ -34,25 +36,14 @@
JSON.parse(response.body)
rescue
{}
end
successful = Fdoc.decide_success(response_params, response.status)
- verify!(verb, path, request_params, response_params, response.status,
- successful)
+ Service.verify!(verb, path, request_params, response_params,
+ response.status, successful)
end
result
end
- end
-
- private
-
- def verify!(verb, path, request_params, response_params, response_status,
- successful)
- service = Service.new(Fdoc.service_path)
- endpoint = service.open(verb, path)
- endpoint.consume_request(request_params, successful)
- endpoint.consume_response(response_params, response_status, successful)
- endpoint.persist! if endpoint.respond_to?(:persist!)
end
end
end