http_stub 0.24.3 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/http_stub.rb +8 -2
  3. data/lib/http_stub/server/application/application.rb +16 -4
  4. data/lib/http_stub/server/request/request.rb +6 -1
  5. data/lib/http_stub/server/response.rb +5 -3
  6. data/lib/http_stub/server/scenario/controller.rb +2 -2
  7. data/lib/http_stub/server/scenario/parser.rb +1 -3
  8. data/lib/http_stub/server/stub/controller.rb +8 -6
  9. data/lib/http_stub/server/stub/empty.rb +9 -5
  10. data/lib/http_stub/server/stub/match/controller.rb +22 -0
  11. data/lib/http_stub/server/stub/match/{result.rb → match.rb} +9 -1
  12. data/lib/http_stub/server/stub/match/miss.rb +19 -0
  13. data/lib/http_stub/server/stub/match/rules.rb +33 -0
  14. data/lib/http_stub/server/stub/parser.rb +1 -1
  15. data/lib/http_stub/server/stub/payload.rb +20 -0
  16. data/lib/http_stub/server/stub/payload/base_uri_modifier.rb +17 -0
  17. data/lib/http_stub/server/stub/payload/response_body_modifier.rb +19 -0
  18. data/lib/http_stub/server/stub/response/base.rb +5 -1
  19. data/lib/http_stub/server/stub/response/file.rb +5 -0
  20. data/lib/http_stub/server/stub/response/text.rb +4 -0
  21. data/lib/http_stub/server/stub/stub.rb +8 -18
  22. data/lib/http_stub/server/stub/triggers.rb +1 -1
  23. data/lib/http_stub/server/views/_activate_scenario.haml +17 -4
  24. data/lib/http_stub/server/views/_stub.haml +2 -2
  25. data/lib/http_stub/server/views/{_match.haml → _stub_match.haml} +1 -1
  26. data/lib/http_stub/server/views/_stub_miss.haml +3 -0
  27. data/lib/http_stub/server/views/index.haml +4 -2
  28. data/lib/http_stub/server/views/stub_matches.haml +4 -0
  29. data/lib/http_stub/server/views/stub_misses.haml +4 -0
  30. data/lib/http_stub/version.rb +1 -1
  31. data/spec/acceptance/stub_match_last_spec.rb +170 -0
  32. data/spec/acceptance/stub_match_list_spec.rb +115 -0
  33. data/spec/acceptance/stub_miss_list_spec.rb +58 -0
  34. data/spec/lib/http_stub/server/application/application_spec.rb +57 -13
  35. data/spec/lib/http_stub/server/request/request_spec.rb +41 -1
  36. data/spec/lib/http_stub/server/response_spec.rb +18 -12
  37. data/spec/lib/http_stub/server/scenario/controller_spec.rb +4 -4
  38. data/spec/lib/http_stub/server/scenario/parser_spec.rb +30 -27
  39. data/spec/lib/http_stub/server/stub/controller_spec.rb +45 -26
  40. data/spec/lib/http_stub/server/stub/empty_spec.rb +14 -14
  41. data/spec/lib/http_stub/server/stub/match/controller_spec.rb +69 -0
  42. data/spec/lib/http_stub/server/stub/match/match_spec.rb +146 -0
  43. data/spec/lib/http_stub/server/stub/match/miss_spec.rb +15 -0
  44. data/spec/lib/http_stub/server/stub/match/rules_spec.rb +247 -0
  45. data/spec/lib/http_stub/server/stub/parser_spec.rb +12 -14
  46. data/spec/lib/http_stub/server/stub/payload/base_uri_modifier_spec.rb +23 -0
  47. data/spec/lib/http_stub/server/{payload_file_consolidator_spec.rb → stub/payload/response_body_modifier_spec.rb} +22 -14
  48. data/spec/lib/http_stub/server/stub/payload_spec.rb +33 -0
  49. data/spec/lib/http_stub/server/stub/response/base_spec.rb +22 -0
  50. data/spec/lib/http_stub/server/stub/response/file_spec.rb +29 -1
  51. data/spec/lib/http_stub/server/stub/response/text_spec.rb +18 -0
  52. data/spec/lib/http_stub/server/stub/stub_spec.rb +48 -145
  53. data/spec/lib/http_stub/server/stub/triggers_spec.rb +14 -0
  54. data/spec/spec_helper.rb +7 -3
  55. data/spec/support/{configurer_integration.rb → http_stub/configurer_integration.rb} +3 -2
  56. data/spec/support/http_stub/html_view_excluding_request_details.rb +11 -0
  57. data/spec/support/http_stub/html_view_including_request_details.rb +47 -0
  58. data/spec/support/http_stub/server/scenario/scenario_fixture.rb +1 -1
  59. data/spec/support/http_stub/server/stub/match/match_fixture.rb +21 -0
  60. data/spec/support/http_stub/server/stub/match/miss_fixture.rb +17 -0
  61. data/spec/support/{server_integration.rb → http_stub/server_integration.rb} +0 -0
  62. data/spec/support/http_stub/stub_fixture.rb +1 -0
  63. data/spec/support/http_stub/stub_registrator.rb +83 -0
  64. metadata +47 -19
  65. data/lib/http_stub/server/stub/payload_file_consolidator.rb +0 -18
  66. data/lib/http_stub/server/views/_miss.haml +0 -7
  67. data/lib/http_stub/server/views/match_results.haml +0 -7
  68. data/spec/acceptance/stub_match_spec.rb +0 -252
  69. data/spec/lib/http_stub/server/stub/match/result_spec.rb +0 -33
  70. data/spec/support/http_stub/server/stub/match/result_fixture.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae298667f0d24ef61eee93ad2a8a9daa92d5ed87
4
- data.tar.gz: 82479a4ed23ef2173f90a9f19504fdaa72377f50
3
+ metadata.gz: 89ef636d0f034ff2c6ad0966f3becc70899c8ca8
4
+ data.tar.gz: e2dd710bf4504f1ec6799a4717b0ed493a94a858
5
5
  SHA512:
6
- metadata.gz: 5f81e67a3de971f554b81ce98e0d0fdd49534d855ae524466ee030ea46eedfd63baafd5900f37795daabddfbe4ef75071834dcf2d5e6110b01a826c1e9358b2a
7
- data.tar.gz: b0858d659ce4bacb911d4b16e7ab870219384901881668ee181c7a68285b6d6291114f568c4be25ecdcca8318b1b4b5af796495bc411ddd92f3bf0d40b2d7ae3
6
+ metadata.gz: c221e672a19916af0902c7a54eccd1cfe58d01f3a6b9ca1be504056079fdc193e09156bbe086634807e72975d5e065c48fa41c7c20d113183181b304736df632
7
+ data.tar.gz: 2061dd82264cfcba3b0cc3aa177086d1dde71407d32430242530464c3ac1b4de021e71fb7e9b0b6a5c529353aee6d9900baa552546264f03bee0b175af43e896
@@ -16,6 +16,7 @@ require 'active_support/core_ext/string/inflections'
16
16
  require 'active_support/core_ext/hash/slice'
17
17
  require 'active_support/core_ext/hash/deep_merge'
18
18
  require 'active_support/core_ext/hash/indifferent_access'
19
+ require 'active_support/json/encoding'
19
20
 
20
21
  require_relative 'http_stub/extensions/core/hash/formatted'
21
22
  require_relative 'http_stub/extensions/core/hash/indifferent_and_insensitive_access'
@@ -40,6 +41,7 @@ require_relative 'http_stub/server/stub/match/rule/parameters'
40
41
  require_relative 'http_stub/server/stub/match/rule/simple_body'
41
42
  require_relative 'http_stub/server/stub/match/rule/json_body'
42
43
  require_relative 'http_stub/server/stub/match/rule/body'
44
+ require_relative 'http_stub/server/stub/match/rules'
43
45
  require_relative 'http_stub/server/stub/response/attribute/interpolator/headers'
44
46
  require_relative 'http_stub/server/stub/response/attribute/interpolator/parameters'
45
47
  require_relative 'http_stub/server/stub/response/attribute/interpolator'
@@ -51,11 +53,15 @@ require_relative 'http_stub/server/stub/response/file'
51
53
  require_relative 'http_stub/server/stub/response'
52
54
  require_relative 'http_stub/server/response'
53
55
  require_relative 'http_stub/server/stub/triggers'
54
- require_relative 'http_stub/server/stub/payload_file_consolidator'
56
+ require_relative 'http_stub/server/stub/payload/base_uri_modifier'
57
+ require_relative 'http_stub/server/stub/payload/response_body_modifier'
58
+ require_relative 'http_stub/server/stub/payload'
55
59
  require_relative 'http_stub/server/stub/parser'
56
60
  require_relative 'http_stub/server/stub/stub'
57
61
  require_relative 'http_stub/server/stub/empty'
58
- require_relative 'http_stub/server/stub/match/result'
62
+ require_relative 'http_stub/server/stub/match/match'
63
+ require_relative 'http_stub/server/stub/match/miss'
64
+ require_relative 'http_stub/server/stub/match/controller'
59
65
  require_relative 'http_stub/server/stub/registry'
60
66
  require_relative 'http_stub/server/stub/controller'
61
67
  require_relative 'http_stub/server/stub'
@@ -23,11 +23,14 @@ module HttpStub
23
23
 
24
24
  def initialize
25
25
  super()
26
- @stub_registry = HttpStub::Server::Stub::Registry.new
27
26
  @scenario_registry = HttpStub::Server::Registry.new("scenario")
28
- @match_result_registry = HttpStub::Server::Registry.new("match result")
29
- @stub_controller = HttpStub::Server::Stub::Controller.new(@stub_registry, @match_result_registry)
27
+ @stub_registry = HttpStub::Server::Stub::Registry.new
28
+ @stub_match_registry = HttpStub::Server::Registry.new("stub match")
29
+ @stub_miss_registry = HttpStub::Server::Registry.new("stub miss")
30
30
  @scenario_controller = HttpStub::Server::Scenario::Controller.new(@scenario_registry, @stub_registry)
31
+ @stub_controller =
32
+ HttpStub::Server::Stub::Controller.new(@stub_registry, @stub_match_registry, @stub_miss_registry)
33
+ @stub_match_controller = HttpStub::Server::Stub::Match::Controller.new(@stub_match_registry)
31
34
  end
32
35
 
33
36
  before do
@@ -66,7 +69,16 @@ module HttpStub
66
69
  end
67
70
 
68
71
  get "/http_stub/stubs/matches" do
69
- haml :match_results, {}, match_results: @match_result_registry.all
72
+ haml :stub_matches, {}, matches: @stub_match_registry.all
73
+ end
74
+
75
+ get "/http_stub/stubs/matches/last" do
76
+ response = @stub_match_controller.find_last(@http_stub_request, logger)
77
+ @response_pipeline.process(response)
78
+ end
79
+
80
+ get "/http_stub/stubs/misses" do
81
+ haml :stub_misses, {}, misses: @stub_miss_registry.all
70
82
  end
71
83
 
72
84
  get "/http_stub/stubs/:id" do
@@ -4,9 +4,10 @@ module HttpStub
4
4
 
5
5
  class Request
6
6
 
7
- attr_reader :uri, :method, :headers, :parameters, :body
7
+ attr_reader :base_uri, :uri, :method, :headers, :parameters, :body
8
8
 
9
9
  def initialize(rack_request)
10
+ @base_uri = rack_request.base_url
10
11
  @uri = rack_request.path_info
11
12
  @method = rack_request.request_method.downcase
12
13
  @headers = HttpStub::Server::Request::Headers.create(rack_request)
@@ -14,6 +15,10 @@ module HttpStub
14
15
  @body = rack_request.body.read
15
16
  end
16
17
 
18
+ def to_hash
19
+ { uri: @uri, method: @method, headers: @headers, parameters: @parameters, body: @body }
20
+ end
21
+
17
22
  end
18
23
 
19
24
  end
@@ -3,11 +3,13 @@ module HttpStub
3
3
 
4
4
  class Response
5
5
 
6
- def self.success(headers={})
7
- HttpStub::Server::Stub::Response::Text.new("status" => 200, "headers" => headers, "body" => "OK")
6
+ def self.ok(opts={})
7
+ HttpStub::Server::Stub::Response::Text.new(
8
+ { "headers" => {}, "body" => "OK" }.merge(opts).merge("status" => 200)
9
+ )
8
10
  end
9
11
 
10
- SUCCESS = success.freeze
12
+ OK = ok.freeze
11
13
  NOT_FOUND = HttpStub::Server::Stub::Response::Text.new("status" => 404, "body" => "NOT FOUND").freeze
12
14
  EMPTY = HttpStub::Server::Stub::Response::Text.new.freeze
13
15
 
@@ -12,14 +12,14 @@ module HttpStub
12
12
  def register(request, logger)
13
13
  scenario = HttpStub::Server::Scenario.create(HttpStub::Server::Scenario::Parser.parse(request))
14
14
  @scenario_registry.add(scenario, logger)
15
- HttpStub::Server::Response::SUCCESS
15
+ HttpStub::Server::Response::OK
16
16
  end
17
17
 
18
18
  def activate(name, logger)
19
19
  scenario = @scenario_registry.find(name, logger)
20
20
  if scenario
21
21
  @scenario_activator.activate(scenario, logger)
22
- HttpStub::Server::Response::SUCCESS
22
+ HttpStub::Server::Response::OK
23
23
  else
24
24
  HttpStub::Server::Response::NOT_FOUND
25
25
  end
@@ -6,9 +6,7 @@ module HttpStub
6
6
 
7
7
  def self.parse(request)
8
8
  JSON.parse(request.parameters["payload"]).tap do |payload|
9
- payload["stubs"].each do |stub_payload|
10
- HttpStub::Server::Stub::PayloadFileConsolidator.consolidate!(stub_payload, request)
11
- end
9
+ payload["stubs"].each { |stub_payload| HttpStub::Server::Stub::Payload.modify!(stub_payload, request) }
12
10
  end
13
11
  end
14
12
 
@@ -4,26 +4,28 @@ module HttpStub
4
4
 
5
5
  class Controller
6
6
 
7
- def initialize(stub_registry, match_result_registry)
8
- @stub_registry = stub_registry
9
- @match_result_registry = match_result_registry
7
+ def initialize(stub_registry, match_registry, miss_registry)
8
+ @stub_registry = stub_registry
9
+ @match_registry = match_registry
10
+ @miss_registry = miss_registry
10
11
  end
11
12
 
12
13
  def register(request, logger)
13
14
  stub = HttpStub::Server::Stub.create(HttpStub::Server::Stub::Parser.parse(request))
14
15
  @stub_registry.add(stub, logger)
15
- HttpStub::Server::Response.success("location" => stub.stub_uri)
16
+ HttpStub::Server::Response.ok("headers" => { "location" => stub.uri })
16
17
  end
17
18
 
18
19
  def match(request, logger)
19
20
  stub = @stub_registry.match(request, logger)
20
21
  response = stub ? stub.response_for(request) : HttpStub::Server::Response::NOT_FOUND
21
- @match_result_registry.add(HttpStub::Server::Stub::Match::Result.new(request, response, stub), logger)
22
+ @match_registry.add(HttpStub::Server::Stub::Match::Match.new(request, response, stub), logger) if stub
23
+ @miss_registry.add(HttpStub::Server::Stub::Match::Miss.new(request), logger) unless stub
22
24
  response
23
25
  end
24
26
 
25
27
  def clear(logger)
26
- [ @stub_registry, @match_result_registry ].each { |registry| registry.clear(logger) }
28
+ [ @stub_registry, @match_registry, @miss_registry ].each { |registry| registry.clear(logger) }
27
29
  end
28
30
 
29
31
  end
@@ -7,15 +7,15 @@ module HttpStub
7
7
  private
8
8
 
9
9
  def initialize
10
- @uri = @method = @body = @stub_uri = ""
11
- @headers = @parameters = {}
12
- @triggers = []
13
- @response = HttpStub::Server::Response::EMPTY
10
+ @uri = ""
11
+ @match_rules = HttpStub::Server::Stub::Match::Rules::EMPTY
12
+ @response = HttpStub::Server::Response::EMPTY
13
+ @triggers = []
14
14
  end
15
15
 
16
16
  public
17
17
 
18
- attr_reader :uri, :method, :headers, :parameters, :body, :response, :triggers, :stub_uri
18
+ attr_reader :uri, :match_rules, :response, :triggers
19
19
 
20
20
  def matches?(_criteria, _logger)
21
21
  false
@@ -25,6 +25,10 @@ module HttpStub
25
25
  self
26
26
  end
27
27
 
28
+ def to_hash
29
+ {}
30
+ end
31
+
28
32
  def to_s
29
33
  ""
30
34
  end
@@ -0,0 +1,22 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+ module Match
5
+
6
+ class Controller
7
+
8
+ def initialize(result_registry)
9
+ @result_registry = result_registry
10
+ end
11
+
12
+ def find_last(request, logger)
13
+ result = @result_registry.find(request.parameters.slice(:method, :uri), logger)
14
+ result ? HttpStub::Server::Response.ok("body" => result.to_json) : HttpStub::Server::Response::NOT_FOUND
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -3,7 +3,7 @@ module HttpStub
3
3
  module Stub
4
4
  module Match
5
5
 
6
- class Result
6
+ class Match
7
7
 
8
8
  attr_reader :request, :response, :stub
9
9
 
@@ -13,6 +13,14 @@ module HttpStub
13
13
  @stub = stub
14
14
  end
15
15
 
16
+ def matches?(criteria, _logger)
17
+ @request.uri.include?(criteria[:uri]) && @request.method.casecmp(criteria[:method]).zero?
18
+ end
19
+
20
+ def to_hash
21
+ { request: @request, response: @response, stub: @stub }
22
+ end
23
+
16
24
  end
17
25
 
18
26
  end
@@ -0,0 +1,19 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+ module Match
5
+
6
+ class Miss
7
+
8
+ attr_reader :request
9
+
10
+ def initialize(request)
11
+ @request = request
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+ module Match
5
+
6
+ class Rules
7
+
8
+ attr_reader :uri, :method, :headers, :parameters, :body
9
+
10
+ def initialize(args)
11
+ @uri = HttpStub::Server::Stub::Match::Rule::Uri.new(args["uri"])
12
+ @method = HttpStub::Server::Stub::Match::Rule::Method.new(args["method"])
13
+ @headers = HttpStub::Server::Stub::Match::Rule::Headers.new(args["headers"])
14
+ @parameters = HttpStub::Server::Stub::Match::Rule::Parameters.new(args["parameters"])
15
+ @body = HttpStub::Server::Stub::Match::Rule::Body.create(args["body"])
16
+ end
17
+
18
+ EMPTY = self.new("uri" => "", "method" => "", "headers" => {}, "parameters" => {}, "body" => "").freeze
19
+
20
+ def matches?(request, logger)
21
+ [ @uri, @method, @headers, @parameters, @body ].all? { |matcher| matcher.matches?(request, logger) }
22
+ end
23
+
24
+ def to_hash
25
+ { uri: @uri, method: @method, headers: @headers, parameters: @parameters, body: @body }
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -5,7 +5,7 @@ module HttpStub
5
5
  class Parser
6
6
 
7
7
  def self.parse(request)
8
- HttpStub::Server::Stub::PayloadFileConsolidator.consolidate!(
8
+ HttpStub::Server::Stub::Payload.modify!(
9
9
  JSON.parse(request.parameters["payload"] || request.body), request
10
10
  )
11
11
  end
@@ -0,0 +1,20 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+
5
+ module Payload
6
+
7
+ MODIFIERS = [ HttpStub::Server::Stub::Payload::BaseUriModifier,
8
+ HttpStub::Server::Stub::Payload::ResponseBodyModifier ].freeze
9
+
10
+ private_constant :MODIFIERS
11
+
12
+ def self.modify!(payload, request)
13
+ payload.tap { MODIFIERS.each { |modifier| modifier.modify!(payload, request) } }
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+ module Payload
5
+
6
+ class BaseUriModifier
7
+
8
+ def self.modify!(payload, request)
9
+ payload["base_uri"] = request.base_uri
10
+ end
11
+
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module HttpStub
2
+ module Server
3
+ module Stub
4
+ module Payload
5
+
6
+ class ResponseBodyModifier
7
+
8
+ def self.modify!(payload, request)
9
+ response_file = request.parameters["response_file_#{payload["id"]}"]
10
+ payload["response"]["body"] = response_file if response_file
11
+ payload["triggers"].each { |trigger_payload| modify!(trigger_payload, request) } if payload["triggers"]
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -34,7 +34,7 @@ module HttpStub
34
34
  attr_reader :status, :headers, :delay_in_seconds
35
35
 
36
36
  def initialize(args={})
37
- @original_args = args
37
+ @original_args = args
38
38
  resolved_args = self.class.merge_defaults(args)
39
39
  @status = resolved_args["status"]
40
40
  @headers = HttpStub::Server::Stub::Response::Attribute::Headers.new(resolved_args["headers"])
@@ -45,6 +45,10 @@ module HttpStub
45
45
  self.class.name.demodulize.underscore
46
46
  end
47
47
 
48
+ def to_hash
49
+ { status: @status, headers: @headers, delay_in_seconds: @delay_in_seconds }
50
+ end
51
+
48
52
  end
49
53
 
50
54
  end
@@ -21,6 +21,11 @@ module HttpStub
21
21
 
22
22
  def serve_on(application)
23
23
  application.send_file(@file.path, send_options)
24
+ @status = application.response.status
25
+ end
26
+
27
+ def to_hash
28
+ super.merge(file_uri: @uri)
24
29
  end
25
30
 
26
31
  private
@@ -23,6 +23,10 @@ module HttpStub
23
23
  application.halt(@status, @headers.to_hash, @body)
24
24
  end
25
25
 
26
+ def to_hash
27
+ super.merge(body: @body)
28
+ end
29
+
26
30
  end
27
31
 
28
32
  end
@@ -4,41 +4,31 @@ module HttpStub
4
4
 
5
5
  class Stub
6
6
 
7
- attr_reader :uri, :method, :headers, :parameters, :body, :response, :triggers, :stub_uri
7
+ attr_reader :uri, :match_rules, :response, :triggers
8
8
 
9
9
  def initialize(args)
10
10
  @id = args["id"] || SecureRandom.uuid
11
- @uri = HttpStub::Server::Stub::Match::Rule::Uri.new(args["uri"])
12
- @method = HttpStub::Server::Stub::Match::Rule::Method.new(args["method"])
13
- @headers = HttpStub::Server::Stub::Match::Rule::Headers.new(args["headers"])
14
- @parameters = HttpStub::Server::Stub::Match::Rule::Parameters.new(args["parameters"])
15
- @body = HttpStub::Server::Stub::Match::Rule::Body.create(args["body"])
11
+ @uri = "#{args["base_uri"]}/http_stub/stubs/#{@id}"
12
+ @match_rules = HttpStub::Server::Stub::Match::Rules.new(args)
16
13
  @response = HttpStub::Server::Stub::Response.create(args["response"])
17
14
  @triggers = HttpStub::Server::Stub::Triggers.new(args["triggers"])
18
- @stub_uri = "/http_stub/stubs/#{@id}"
19
15
  @description = args.to_s
20
16
  end
21
17
 
22
18
  def matches?(criteria, logger)
23
- criteria.is_a?(String) ? matches_by_id?(criteria) : matches_by_rules?(criteria, logger)
19
+ criteria.is_a?(String) ? criteria == @id : @match_rules.matches?(criteria, logger)
24
20
  end
25
21
 
26
22
  def response_for(request)
27
23
  @response.with_values_from(request)
28
24
  end
29
25
 
30
- def to_s
31
- @description
26
+ def to_hash
27
+ { id: @id, uri: @uri, match_rules: @match_rules, response: @response, triggers: @triggers }
32
28
  end
33
29
 
34
- private
35
-
36
- def matches_by_id?(criteria)
37
- criteria == @id
38
- end
39
-
40
- def matches_by_rules?(request, logger)
41
- [ @uri, @method, @headers, @parameters, @body ].all? { |matcher| matcher.matches?(request, logger) }
30
+ def to_s
31
+ @description
42
32
  end
43
33
 
44
34
  end