lib/stub_requests/dsl.rb in stub_requests-0.1.9 vs lib/stub_requests/dsl.rb in stub_requests-0.1.10
- old
+ new
@@ -27,19 +27,19 @@
# # This turns the module Stubs into the following:
#
# Stubs.instance_methods #=> [:stub_documents_show, :stub_documents_index, :stub_documents_create]
# module Stubs
# def stub_documents_show(id:, &block)
- # stub_endpoint(:documents, :show, id: id, &block)
+ # stub_endpoint(:documents_show, id: id, &block)
# end
#
# def stub_documents_index(&block)
- # stub_endpoint(:documents, :index, &block)
+ # stub_endpoint(:documents_index, &block)
# end
#
# def stub_documents_create(&block)
- # stub_endpoint(:documents, :create, &block)
+ # stub_endpoint(:documents_create, &block)
# end
# end
#
# @example **Use the helper methods in your tests**
# include Stubs
@@ -88,13 +88,12 @@
#
# @param [Symbol] service_id the id of a registered service
# @param [Module] receiver the receiver of the stub methods
#
def initialize(service_id, receiver: nil)
- @service = StubRequests::ServiceRegistry.instance.find!(service_id)
+ @endpoints = StubRequests::EndpointRegistry[service_id]
@receiver = receiver
- @endpoints = service.endpoints.endpoints.values
end
#
# Defines stub methods for #endpoints in the #receiver
#
@@ -121,10 +120,10 @@
end
end
def method_definitions
@method_definitions ||= endpoints.map do |endpoint|
- MethodDefinition.new(service.id, endpoint.id, endpoint.route_params)
+ MethodDefinition.new(endpoint.id, endpoint.route_params)
end
end
end
end