mirage 1.3.6 → 2.0.0.alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -4
- data/VERSION +1 -1
- data/bin/mirage +2 -0
- data/features/client/clear.feature +38 -20
- data/features/client/peek.feature +11 -11
- data/features/client/save_and_revert.feature +14 -8
- data/features/client/set.feature +59 -13
- data/features/client/track.feature +5 -3
- data/features/server/clear.feature +59 -47
- data/features/server/logging.feature +2 -3
- data/features/server/peek.feature +12 -10
- data/features/server/prime.feature +15 -13
- data/features/server/response_templates.feature +9 -16
- data/features/server/save_and_revert.feature +11 -14
- data/features/server/set.feature +44 -17
- data/features/server/set_default_response.feature +19 -25
- data/features/server/set_with_a_delay.feature +3 -5
- data/features/server/set_with_a_pattern.feature +24 -29
- data/features/server/track_requests.feature +71 -0
- data/features/server/web_user_interface.feature +7 -8
- data/features/step_definitions/my_steps.rb +83 -28
- data/features/support/env.rb +0 -14
- data/lib/mirage.rb +3 -0
- data/lib/mirage/client.rb +48 -43
- data/lib/mirage/core.rb +65 -152
- data/lib/mirage/mock_response.rb +49 -0
- data/lib/mirage/mock_responses_collection.rb +109 -0
- data/lib/mirage/object.rb +5 -0
- data/lib/mirage/web.rb +37 -28
- data/lib/start_mirage.rb +27 -5
- data/lib/{view/mirage/index.xhtml → views/index.erb} +5 -5
- data/mirage.gemspec +7 -7
- metadata +57 -23
- data/features/client/get.feature +0 -46
- data/features/server/file_responses.feature +0 -8
- data/features/server/track.feature +0 -74
data/features/client/get.feature
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
Feature: the Mirage client provides a method for getting responses
|
2
|
-
There is no need to escape any parameters before using the client api as this is done for you.
|
3
|
-
|
4
|
-
Background:
|
5
|
-
Given the following gems are required to run the Mirage client test code:
|
6
|
-
"""
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rspec'
|
9
|
-
require 'mirage'
|
10
|
-
"""
|
11
|
-
And I post to 'http://localhost:7001/mirage/set/greeting' with parameters:
|
12
|
-
| response | hello |
|
13
|
-
|
14
|
-
Scenario: getting a response
|
15
|
-
Given I run
|
16
|
-
"""
|
17
|
-
Mirage::Client.new.get('greeting').should == 'hello'
|
18
|
-
"""
|
19
|
-
|
20
|
-
Scenario: getting a response with parameters
|
21
|
-
Given I run
|
22
|
-
"""
|
23
|
-
Mirage::Client.new.get('greeting', :firstname => 'leon', :surname => 'davis').should == 'hello'
|
24
|
-
"""
|
25
|
-
And I hit 'http://localhost:7001/mirage/track/1'
|
26
|
-
Then 'firstname=leon&surname=davis' should be returned
|
27
|
-
|
28
|
-
Scenario: getting a response with a request body
|
29
|
-
Given I run
|
30
|
-
"""
|
31
|
-
Mirage::Client.new.get('greeting','<greetingRequest></greetingRequest>').should == 'hello'
|
32
|
-
"""
|
33
|
-
And I hit 'http://localhost:7001/mirage/track/1'
|
34
|
-
Then '<greetingRequest></greetingRequest>' should be returned
|
35
|
-
|
36
|
-
Scenario: getting a response that does not exist
|
37
|
-
Given I run
|
38
|
-
"""
|
39
|
-
begin
|
40
|
-
Mirage::Client.new.get('response_that_does_not_exits').should == 'hello'
|
41
|
-
fail("Error should have been thrown")
|
42
|
-
rescue Exception => e
|
43
|
-
e.is_a?(Mirage::ResponseNotFound).should == true
|
44
|
-
end
|
45
|
-
"""
|
46
|
-
|
@@ -1,8 +0,0 @@
|
|
1
|
-
Feature: Mirage can also be used to host files.
|
2
|
-
|
3
|
-
Scenario: A file is set as a response
|
4
|
-
Given I hit 'http://localhost:7001/mirage/set/some/location/download' with parameters:
|
5
|
-
| response | README.md |
|
6
|
-
|
7
|
-
When I hit 'http://localhost:7001/mirage/get/some/location/download'
|
8
|
-
Then the response should be a file the same as 'README.md'
|
@@ -1,74 +0,0 @@
|
|
1
|
-
Feature: After a response has been served from Mirage, the content of the request that triggered it can be retrieved. This is useful
|
2
|
-
for testing that the correct information was sent to the endpoint.
|
3
|
-
|
4
|
-
On setting a response, a unique id is returned which can be used to look up the last request made to get that response.
|
5
|
-
|
6
|
-
If the the response is reset then the same id is returned in order to make it easier to keep track of.
|
7
|
-
|
8
|
-
Responses hosted on the same endpoint but with a pattern are considered unique and so get their own ID.
|
9
|
-
|
10
|
-
If the request body contains content this is stored. Otherwise it is the query string that is stored.
|
11
|
-
|
12
|
-
If a response is 'peeked' this does not count as a request that should be stored.
|
13
|
-
|
14
|
-
Background: There is a response already on Mirage
|
15
|
-
Given I hit 'http://localhost:7001/mirage/set/greeting' with parameters:
|
16
|
-
| response | Hello |
|
17
|
-
|
18
|
-
|
19
|
-
Scenario: Tracking a response that was triggered by a request that had content in the body
|
20
|
-
Given I hit 'http://localhost:7001/mirage/get/greeting' with request body:
|
21
|
-
"""
|
22
|
-
Hello MockServer
|
23
|
-
"""
|
24
|
-
When I hit 'http://localhost:7001/mirage/track/1'
|
25
|
-
Then 'Hello MockServer' should be returned
|
26
|
-
|
27
|
-
|
28
|
-
Scenario: Tracking a response that was triggered by a request with a query string
|
29
|
-
Given I hit 'http://localhost:7001/mirage/get/greeting' with parameters:
|
30
|
-
| surname | Davis |
|
31
|
-
| firstname | Leon |
|
32
|
-
When I hit 'http://localhost:7001/mirage/track/1'
|
33
|
-
Then 'surname=Davis&firstname=Leon' should be returned
|
34
|
-
|
35
|
-
|
36
|
-
Scenario: Tracking a response that has not been served yet
|
37
|
-
Given I hit 'http://localhost:7001/mirage/track/1'
|
38
|
-
Then a 404 should be returned
|
39
|
-
|
40
|
-
|
41
|
-
Scenario: A response is peeked at
|
42
|
-
Given I hit 'http://localhost:7001/mirage/get/greeting' with request body:
|
43
|
-
"""
|
44
|
-
Hello
|
45
|
-
"""
|
46
|
-
And I hit 'http://localhost:7001/mirage/peek/1'
|
47
|
-
When I hit 'http://localhost:7001/mirage/track/1'
|
48
|
-
Then 'Hello' should be returned
|
49
|
-
|
50
|
-
|
51
|
-
Scenario: A default response and one for the same endpoint with a pattern are set
|
52
|
-
When I hit 'http://localhost:7001/mirage/set/greeting' with parameters:
|
53
|
-
| response | Hello who ever you are |
|
54
|
-
Then '1' should be returned
|
55
|
-
|
56
|
-
When I hit 'http://localhost:7001/mirage/set/greeting' with parameters:
|
57
|
-
| response | Hello Leon |
|
58
|
-
| pattern | Leon |
|
59
|
-
Then '3' should be returned
|
60
|
-
|
61
|
-
When I hit 'http://localhost:7001/mirage/get/greeting' with request body:
|
62
|
-
"""
|
63
|
-
My name is Joel
|
64
|
-
"""
|
65
|
-
And I hit 'http://localhost:7001/mirage/get/greeting' with request body:
|
66
|
-
"""
|
67
|
-
My name is Leon
|
68
|
-
"""
|
69
|
-
And I hit 'http://localhost:7001/mirage/track/1'
|
70
|
-
Then 'My name is Joel' should be returned
|
71
|
-
And I hit 'http://localhost:7001/mirage/track/3'
|
72
|
-
Then 'My name is Leon' should be returned
|
73
|
-
|
74
|
-
|