http_stub 0.13.5 → 0.14.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/http_stub.rb +13 -4
  3. data/lib/http_stub/configurer.rb +9 -63
  4. data/lib/http_stub/configurer/deprecated_dsl.rb +57 -0
  5. data/lib/http_stub/configurer/request/stub.rb +7 -13
  6. data/lib/http_stub/configurer/request/stub_activator.rb +8 -4
  7. data/lib/http_stub/configurer/request/stub_activator_payload_builder.rb +25 -0
  8. data/lib/http_stub/configurer/request/stub_payload_builder.rb +44 -0
  9. data/lib/http_stub/configurer/server/buffered_command_processor.rb +24 -0
  10. data/lib/http_stub/configurer/server/command.rb +18 -0
  11. data/lib/http_stub/configurer/server/command_processor.rb +38 -0
  12. data/lib/http_stub/configurer/server/dsl.rb +56 -0
  13. data/lib/http_stub/configurer/server/facade.rb +57 -0
  14. data/lib/http_stub/configurer/server/request_processor.rb +30 -0
  15. data/lib/http_stub/models/registry.rb +4 -0
  16. data/lib/http_stub/models/stub.rb +2 -1
  17. data/lib/http_stub/models/stub_registry.rb +29 -0
  18. data/lib/http_stub/models/stub_triggers.rb +23 -0
  19. data/lib/http_stub/rake/server_tasks.rb +2 -5
  20. data/lib/http_stub/server.rb +14 -4
  21. data/lib/http_stub/version.rb +1 -1
  22. data/lib/http_stub/views/_stub.haml +7 -0
  23. data/spec/lib/http_stub/configurer/deprecated_dsl_spec.rb +232 -0
  24. data/spec/lib/http_stub/configurer/request/controllable_value_spec.rb +8 -8
  25. data/spec/lib/http_stub/configurer/request/omittable_spec.rb +8 -8
  26. data/spec/lib/http_stub/configurer/request/regexpable_spec.rb +14 -14
  27. data/spec/lib/http_stub/configurer/request/stub_activator_payload_builder_spec.rb +74 -0
  28. data/spec/lib/http_stub/configurer/request/stub_activator_spec.rb +19 -26
  29. data/spec/lib/http_stub/configurer/request/stub_payload_builder_spec.rb +203 -0
  30. data/spec/lib/http_stub/configurer/request/stub_spec.rb +18 -157
  31. data/spec/lib/http_stub/configurer/server/buffered_command_processor_spec.rb +35 -0
  32. data/spec/lib/http_stub/configurer/server/command_processor_integration_spec.rb +62 -0
  33. data/spec/lib/http_stub/configurer/server/command_spec.rb +25 -0
  34. data/spec/lib/http_stub/configurer/server/dsl_spec.rb +241 -0
  35. data/spec/lib/http_stub/configurer/server/facade_spec.rb +253 -0
  36. data/spec/lib/http_stub/configurer/server/request_processor_spec.rb +99 -0
  37. data/spec/lib/http_stub/configurer_integration_spec.rb +172 -122
  38. data/spec/lib/http_stub/configurer_spec.rb +4 -4
  39. data/spec/lib/http_stub/controllers/stub_activator_controller_spec.rb +25 -25
  40. data/spec/lib/http_stub/controllers/stub_controller_spec.rb +22 -22
  41. data/spec/lib/http_stub/hash_extensions_spec.rb +24 -24
  42. data/spec/lib/http_stub/models/exact_value_matcher_spec.rb +4 -4
  43. data/spec/lib/http_stub/models/hash_with_string_value_matchers_spec.rb +29 -29
  44. data/spec/lib/http_stub/models/headers_spec.rb +10 -10
  45. data/spec/lib/http_stub/models/omitted_value_matcher_spec.rb +8 -8
  46. data/spec/lib/http_stub/models/regexp_value_matcher_spec.rb +6 -6
  47. data/spec/lib/http_stub/models/registry_spec.rb +71 -28
  48. data/spec/lib/http_stub/models/request_header_parser_spec.rb +4 -4
  49. data/spec/lib/http_stub/models/request_pipeline_spec.rb +2 -2
  50. data/spec/lib/http_stub/models/response_spec.rb +38 -38
  51. data/spec/lib/http_stub/models/string_value_matcher_spec.rb +25 -25
  52. data/spec/lib/http_stub/models/stub_activator_spec.rb +15 -15
  53. data/spec/lib/http_stub/models/stub_headers_spec.rb +18 -18
  54. data/spec/lib/http_stub/models/stub_parameters_spec.rb +16 -16
  55. data/spec/lib/http_stub/models/stub_registry_integration_spec.rb +62 -0
  56. data/spec/lib/http_stub/models/stub_registry_spec.rb +152 -0
  57. data/spec/lib/http_stub/models/stub_spec.rb +67 -43
  58. data/spec/lib/http_stub/models/stub_triggers_spec.rb +64 -0
  59. data/spec/lib/http_stub/models/stub_uri_spec.rb +9 -9
  60. data/spec/lib/http_stub/rake/server_daemon_tasks_smoke_spec.rb +7 -7
  61. data/spec/lib/http_stub/rake/server_tasks_smoke_spec.rb +5 -5
  62. data/spec/lib/http_stub/rake/server_tasks_spec.rb +17 -15
  63. data/spec/lib/http_stub/server_daemon_spec.rb +16 -16
  64. data/spec/lib/http_stub/server_integration_spec.rb +112 -65
  65. data/spec/lib/http_stub/server_spec.rb +134 -96
  66. data/spec/spec_helper.rb +1 -1
  67. data/spec/support/http_stub/configurer/request/stub_payload_builder_shared_context.rb +27 -0
  68. data/spec/support/server_integration.rb +2 -2
  69. metadata +69 -30
  70. data/lib/http_stub/configurer/command.rb +0 -26
  71. data/lib/http_stub/configurer/command_processor.rb +0 -36
  72. data/lib/http_stub/configurer/impatient_command_chain.rb +0 -13
  73. data/lib/http_stub/configurer/patient_command_chain.rb +0 -25
  74. data/spec/lib/http_stub/configurer/command_processor_integration_spec.rb +0 -63
  75. data/spec/lib/http_stub/configurer/command_spec.rb +0 -40
  76. data/spec/lib/http_stub/configurer/impatient_command_chain_spec.rb +0 -17
  77. data/spec/lib/http_stub/configurer/patient_command_chain_spec.rb +0 -73
@@ -1,40 +0,0 @@
1
- describe HttpStub::Configurer::Command do
2
-
3
- let(:processor) { double(HttpStub::Configurer::CommandProcessor) }
4
- let(:args) { { processor: processor, request: double("HttpRequest"), description: "Some Description" } }
5
-
6
- let(:command) { HttpStub::Configurer::Command.new(args) }
7
-
8
- describe "#execute" do
9
-
10
- it "should delegate to the provided processor" do
11
- processor.should_receive(:process).with(command)
12
-
13
- command.execute
14
- end
15
-
16
- end
17
-
18
- describe "#resetable" do
19
-
20
- describe "when created with a resetable flag that is true" do
21
-
22
- before(:each) { args.merge!(resetable: true) }
23
-
24
- it "should return true" do
25
- command.resetable?.should be_true
26
- end
27
-
28
- end
29
-
30
- describe "when created without a resetable flag" do
31
-
32
- it "should return false" do
33
- command.resetable?.should be_false
34
- end
35
-
36
- end
37
-
38
- end
39
-
40
- end
@@ -1,17 +0,0 @@
1
- describe HttpStub::Configurer::ImpatientCommandChain do
2
-
3
- let(:command) { double(HttpStub::Configurer::Command) }
4
-
5
- let(:command_chain) { HttpStub::Configurer::ImpatientCommandChain.new() }
6
-
7
- describe "#<<" do
8
-
9
- it "should immediately execute the provided command" do
10
- command.should_receive(:execute)
11
-
12
- command_chain << command
13
- end
14
-
15
- end
16
-
17
- end
@@ -1,73 +0,0 @@
1
- describe HttpStub::Configurer::PatientCommandChain do
2
-
3
- let(:command_chain) { HttpStub::Configurer::PatientCommandChain.new }
4
-
5
- describe "#execute" do
6
-
7
- describe "when a number of commands have been added" do
8
-
9
- let(:commands) do
10
- (1..3).map { |i| double("Command#{i}") }
11
- end
12
-
13
- before(:each) do
14
- commands.each { |command| command_chain << command }
15
- end
16
-
17
- it "should execute each command added" do
18
- commands.each { |command| command.should_receive(:execute) }
19
-
20
- command_chain.execute()
21
- end
22
-
23
- end
24
-
25
- describe "when no commands have been added" do
26
-
27
- it "should execute without error" do
28
- lambda { command_chain.execute() }.should_not raise_error
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- describe "#filter" do
36
-
37
- describe "when a number of command have been added" do
38
-
39
- let(:commands) do
40
- (1..5).map { |i| double("Command#{i}", occasional_match_flag?: i % 2 == 0, no_match_flag?: false) }
41
- end
42
-
43
- before(:each) do
44
- commands.each { |command| command_chain << command }
45
- end
46
-
47
- describe "when some commands match the filter provided" do
48
-
49
- it "should return a chain containing the matching commands" do
50
- [commands[1], commands[3]].each { |command| command.should_receive(:execute) }
51
-
52
- filter_chain = command_chain.filter(&:occasional_match_flag?)
53
-
54
- filter_chain.execute()
55
- end
56
-
57
- end
58
-
59
- describe "when no commands match the filter provided" do
60
-
61
- it "should return an empty chain" do
62
- filter_chain = command_chain.filter(&:no_match_flag?)
63
-
64
- filter_chain.execute()
65
- end
66
-
67
- end
68
-
69
- end
70
-
71
- end
72
-
73
- end