mirage 3.0.13 → 3.0.14
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.
- checksums.yaml +8 -8
- metadata +1 -75
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.simplecov +0 -6
- data/.travis.yml +0 -4
- data/Gemfile +0 -27
- data/Gemfile.lock +0 -142
- data/HISTORY +0 -24
- data/Rakefile +0 -10
- data/VERSION +0 -1
- data/features/.nav +0 -29
- data/features/client/clear.feature +0 -78
- data/features/client/configure.feature +0 -72
- data/features/client/model.feature +0 -95
- data/features/client/preview_responses.feature +0 -33
- data/features/client/prime.feature +0 -32
- data/features/client/put.feature +0 -111
- data/features/client/readme.md +0 -3
- data/features/client/requests.feature +0 -20
- data/features/client/running.feature +0 -51
- data/features/client/save_and_revert.feature +0 -39
- data/features/client/start.feature +0 -46
- data/features/client/stop.feature +0 -53
- data/features/commandline_interface/help.feature +0 -17
- data/features/commandline_interface/readme.md +0 -1
- data/features/commandline_interface/start.feature +0 -18
- data/features/commandline_interface/stop.feature +0 -42
- data/features/logging.feature +0 -6
- data/features/prime.feature +0 -35
- data/features/readme.md +0 -7
- data/features/requests/delete.feature +0 -48
- data/features/requests/get.feature +0 -36
- data/features/save_and_revert.feature +0 -35
- data/features/step_definitions/my_steps.rb +0 -97
- data/features/step_definitions/observation_steps.rb +0 -102
- data/features/support/command_line.rb +0 -37
- data/features/support/env.rb +0 -22
- data/features/support/hooks.rb +0 -26
- data/features/support/mirage.rb +0 -12
- data/features/support/web.rb +0 -19
- data/features/templates/delete.feature +0 -45
- data/features/templates/get.feature +0 -54
- data/features/templates/path_wildcards.feature +0 -10
- data/features/templates/preview.feature +0 -18
- data/features/templates/put.feature +0 -77
- data/features/templates/put_with_substitutions.feature +0 -22
- data/features/templates/readme.md +0 -4
- data/features/templates/required_content.feature +0 -113
- data/features/web_user_interface.feature +0 -44
- data/full_build.sh +0 -100
- data/mirage.gemspec +0 -174
- data/spec/mirage/client/cli_bridge_spec.rb +0 -63
- data/spec/mirage/client/client_spec.rb +0 -179
- data/spec/mirage/client/helpers/method_builder_spec.rb +0 -48
- data/spec/mirage/client/request_spec.rb +0 -44
- data/spec/mirage/client/requests_spec.rb +0 -9
- data/spec/mirage/client/runner_spec.rb +0 -138
- data/spec/mirage/client/template/configuration_spec.rb +0 -32
- data/spec/mirage/client/template/model/common_methods_spec.rb +0 -25
- data/spec/mirage/client/template/model/instance_methods_spec.rb +0 -169
- data/spec/mirage/client/template/model_spec.rb +0 -119
- data/spec/mirage/client/template_spec.rb +0 -146
- data/spec/mirage/client/templates_spec.rb +0 -197
- data/spec/mirage/wait_methods_spec.rb +0 -42
- data/spec/resources/binary.file +0 -0
- data/spec/server/binary_data_checker_spec.rb +0 -21
- data/spec/server/helpers/http_headers_spec.rb +0 -20
- data/spec/server/helpers/template_requirements_spec.rb +0 -34
- data/spec/server/mock_response_set_spec.rb +0 -57
- data/spec/server/mock_response_spec.rb +0 -577
- data/spec/server/server_spec.rb +0 -156
- data/spec/spec_helper.rb +0 -85
- data/tasks/application.rake +0 -7
- data/tasks/packaging.rake +0 -28
- data/tasks/tests.rake +0 -25
@@ -1,72 +0,0 @@
|
|
1
|
-
Feature: Configuring Templates
|
2
|
-
|
3
|
-
If you find yourself setting the same basic http settings for templates, the client can be configured to preset these.
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given the following require statements are needed:
|
7
|
-
"""
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rspec/expectations'
|
10
|
-
require 'mirage/client'
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: configuring the client on instance
|
14
|
-
Given I run
|
15
|
-
"""
|
16
|
-
client = Mirage::Client.new do
|
17
|
-
http_method :post
|
18
|
-
status 202
|
19
|
-
default true
|
20
|
-
delay 2
|
21
|
-
content_type "text/xml"
|
22
|
-
end
|
23
|
-
|
24
|
-
client.put('greeting','hello')
|
25
|
-
"""
|
26
|
-
When POST is sent to '/responses/greeting/for/someone'
|
27
|
-
Then 'hello' should be returned
|
28
|
-
And a 202 should be returned
|
29
|
-
Then it should take at least '2' seconds
|
30
|
-
And the response 'content-type' should be 'text/xml'
|
31
|
-
|
32
|
-
Scenario: Configuring a client after it has been created
|
33
|
-
Given I run
|
34
|
-
"""
|
35
|
-
client = Mirage::Client.new
|
36
|
-
client.configure do
|
37
|
-
http_method :post
|
38
|
-
status 202
|
39
|
-
default false
|
40
|
-
delay 2
|
41
|
-
content_type "text/xml"
|
42
|
-
end
|
43
|
-
|
44
|
-
client.put('greeting','hello')
|
45
|
-
"""
|
46
|
-
When POST is sent to '/responses/greeting'
|
47
|
-
Then 'hello' should be returned
|
48
|
-
And a 202 should be returned
|
49
|
-
Then it should take at least '2' seconds
|
50
|
-
And the response 'content-type' should be 'text/xml'
|
51
|
-
|
52
|
-
Scenario: resetting defaults
|
53
|
-
Given I run
|
54
|
-
"""
|
55
|
-
client = Mirage::Client.new
|
56
|
-
client.configure do
|
57
|
-
http_method :post
|
58
|
-
status 202
|
59
|
-
default true
|
60
|
-
delay 2
|
61
|
-
content_type "text/xml"
|
62
|
-
end
|
63
|
-
|
64
|
-
client.reset
|
65
|
-
client.put('greeting','hello')
|
66
|
-
"""
|
67
|
-
When GET is sent to '/responses/greeting'
|
68
|
-
Then 'hello' should be returned
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
@@ -1,95 +0,0 @@
|
|
1
|
-
Feature: Template Models
|
2
|
-
|
3
|
-
Use Models to for an object oriented approach to defining Templates.
|
4
|
-
|
5
|
-
The Mirage client provides the Mirage::Template::Model module that can be used to define your own model classes.
|
6
|
-
|
7
|
-
Having extended this module you must provide a 'body' method to customise the body of the response
|
8
|
-
|
9
|
-
The Model module provides class level methods for:
|
10
|
-
|
11
|
-
* Defaulting characteristics such as HTTP status code and Content-type
|
12
|
-
|
13
|
-
* Defining instance level methods that can set and get values.
|
14
|
-
|
15
|
-
Instances of classes that extend this module will also have all of the standard methods of a Mirage Template and hence you can also set your request requirements directly on them too.
|
16
|
-
|
17
|
-
Any defaults set using methods provided can be overridden after instances are created and when the client is used to add them as Templates to Mirage. See below for examples.
|
18
|
-
|
19
|
-
|
20
|
-
Background:
|
21
|
-
Given the following require statements are needed:
|
22
|
-
"""
|
23
|
-
require 'rubygems'
|
24
|
-
require 'mirage/client'
|
25
|
-
"""
|
26
|
-
|
27
|
-
|
28
|
-
Scenario: Defining a Model
|
29
|
-
Given I run
|
30
|
-
"""
|
31
|
-
class UserProfile
|
32
|
-
extend Mirage::Template::Model
|
33
|
-
|
34
|
-
endpoint '/users'
|
35
|
-
http_method :get
|
36
|
-
status 202
|
37
|
-
content_type 'text/html'
|
38
|
-
|
39
|
-
def body
|
40
|
-
"Joe Blogs"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
Mirage::Client.new.put UserProfile.new
|
45
|
-
"""
|
46
|
-
When GET is sent to '/responses/users'
|
47
|
-
Then 'Joe Blogs' should be returned
|
48
|
-
And a 202 should be returned
|
49
|
-
And the content-type should be 'text/html'
|
50
|
-
|
51
|
-
|
52
|
-
Scenario: Defining builder methods
|
53
|
-
Given I run
|
54
|
-
"""
|
55
|
-
class UserProfile
|
56
|
-
extend Mirage::Template::Model
|
57
|
-
endpoint '/users'
|
58
|
-
|
59
|
-
builder_methods :firstname, :surname
|
60
|
-
|
61
|
-
def body
|
62
|
-
"#{firstname} #{surname}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
Mirage::Client.new.put UserProfile.new.firstname('Joe').surname('Blogs')
|
67
|
-
"""
|
68
|
-
When GET is sent to '/responses/users'
|
69
|
-
Then 'Joe Blogs' should be returned
|
70
|
-
|
71
|
-
Scenario: Overriding model defaults
|
72
|
-
Given I run
|
73
|
-
"""
|
74
|
-
class UserProfile
|
75
|
-
extend Mirage::Template::Model
|
76
|
-
endpoint '/users'
|
77
|
-
|
78
|
-
builder_methods :firstname, :surname
|
79
|
-
status '200'
|
80
|
-
|
81
|
-
def body
|
82
|
-
"Joe Blogs"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
Mirage::Client.new.put '/profiles', UserProfile.new do
|
87
|
-
status 202
|
88
|
-
end
|
89
|
-
"""
|
90
|
-
When GET is sent to '/responses/profiles'
|
91
|
-
Then 'Joe Blogs' should be returned
|
92
|
-
And a 202 should be returned
|
93
|
-
|
94
|
-
|
95
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
Feature: Inspecting Templates
|
2
|
-
|
3
|
-
The client can be used to retrieve a template stored on Mirage.
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given the following require statements are needed:
|
7
|
-
"""
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rspec/expectations'
|
10
|
-
require 'mirage/client'
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: retrieving a Template
|
14
|
-
Given a template for 'greeting' has been set with a value of 'Hello'
|
15
|
-
|
16
|
-
When I run
|
17
|
-
"""
|
18
|
-
Mirage::Client.new.templates(1).body.should == 'Hello'
|
19
|
-
"""
|
20
|
-
|
21
|
-
When GET is sent to '/requests/1'
|
22
|
-
Then a 404 should be returned
|
23
|
-
|
24
|
-
Scenario: retrieving a Template that does not exist
|
25
|
-
Given I run
|
26
|
-
"""
|
27
|
-
begin
|
28
|
-
Mirage::Client.new.templates(2).should == 'this should not have happened'
|
29
|
-
fail("Error should have been thrown")
|
30
|
-
rescue Exception => e
|
31
|
-
e.is_a?(Mirage::TemplateNotFound).should == true
|
32
|
-
end
|
33
|
-
"""
|
@@ -1,32 +0,0 @@
|
|
1
|
-
Feature: Priming Mirage
|
2
|
-
|
3
|
-
The client can be used to prime Mirage with Templates found in the templates directory that was configured when Mirage was started.
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given the following require statements are needed:
|
7
|
-
"""
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rspec/expectations'
|
10
|
-
require 'mirage/client'
|
11
|
-
"""
|
12
|
-
|
13
|
-
Scenario: Priming Mirage
|
14
|
-
Given Mirage is not running
|
15
|
-
And I run 'mirage start'
|
16
|
-
|
17
|
-
When the file 'mirage/default_greetings.rb' contains:
|
18
|
-
"""
|
19
|
-
prime do |mirage|
|
20
|
-
mirage.put('greeting', 'hello')
|
21
|
-
mirage.put('leaving', 'goodbye')
|
22
|
-
end
|
23
|
-
"""
|
24
|
-
And I run
|
25
|
-
"""
|
26
|
-
Mirage::Client.new.prime
|
27
|
-
"""
|
28
|
-
And GET is sent to '/responses/greeting'
|
29
|
-
Then 'hello' should be returned
|
30
|
-
|
31
|
-
When GET is sent to '/responses/leaving'
|
32
|
-
Then 'goodbye' should be returned
|
data/features/client/put.feature
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
Feature: Adding Templates
|
2
|
-
|
3
|
-
The Mirage client provides methods for setting Templates.
|
4
|
-
|
5
|
-
The client will escape all data for you so your free to just get on with using Mirage :)
|
6
|
-
|
7
|
-
Body, Header, and Parameter requirements can be specified as either a String or Regexp
|
8
|
-
|
9
|
-
Background:
|
10
|
-
Given the following require statements are needed:
|
11
|
-
"""
|
12
|
-
require 'rubygems'
|
13
|
-
require 'rspec/expectations'
|
14
|
-
require 'mirage/client'
|
15
|
-
"""
|
16
|
-
|
17
|
-
|
18
|
-
Scenario: Setting a Template on Mirage
|
19
|
-
Given I run
|
20
|
-
"""
|
21
|
-
Mirage::Client.new.put('greeting','hello')
|
22
|
-
"""
|
23
|
-
When GET is sent to '/responses/greeting'
|
24
|
-
Then 'hello' should be returned
|
25
|
-
|
26
|
-
Scenario: Setting the required HTTP method
|
27
|
-
Given I run
|
28
|
-
"""
|
29
|
-
Mirage::Client.new.put('greeting', 'Hello Leon') do
|
30
|
-
http_method 'POST'
|
31
|
-
end
|
32
|
-
"""
|
33
|
-
When GET is sent to '/responses/greeting'
|
34
|
-
Then a 404 should be returned
|
35
|
-
When POST is sent to '/responses/greeting'
|
36
|
-
Then 'Hello Leon' should be returned
|
37
|
-
|
38
|
-
|
39
|
-
Scenario: Setting a requirement on body content
|
40
|
-
Given I run
|
41
|
-
"""
|
42
|
-
Mirage::Client.new.put('greeting', 'Hello Leon') do
|
43
|
-
http_method 'POST'
|
44
|
-
required_body_content << /leon/
|
45
|
-
end
|
46
|
-
"""
|
47
|
-
When POST is sent to '/responses/greeting'
|
48
|
-
Then a 404 should be returned
|
49
|
-
When I send POST to '/responses/greeting' with request entity
|
50
|
-
"""
|
51
|
-
<greetingRequest>
|
52
|
-
<name>leon</name>
|
53
|
-
</greetingRequest>
|
54
|
-
"""
|
55
|
-
Then 'Hello Leon' should be returned
|
56
|
-
|
57
|
-
Scenario: Setting a requirement on requests parameters
|
58
|
-
Given I run
|
59
|
-
"""
|
60
|
-
Mirage::Client.new.put('greeting', 'Hello Leon') do
|
61
|
-
http_method 'POST'
|
62
|
-
required_parameters[:name] = /leon/
|
63
|
-
end
|
64
|
-
"""
|
65
|
-
When POST is sent to '/responses/greeting'
|
66
|
-
Then a 404 should be returned
|
67
|
-
When I send POST to '/responses/greeting' with parameters:
|
68
|
-
| name | leon |
|
69
|
-
|
70
|
-
Then 'Hello Leon' should be returned
|
71
|
-
|
72
|
-
Scenario: setting a response as default
|
73
|
-
Given I run
|
74
|
-
"""
|
75
|
-
Mirage.start.clear
|
76
|
-
|
77
|
-
Mirage::Client.new.put('greeting', 'default greeting') do
|
78
|
-
default true
|
79
|
-
end
|
80
|
-
"""
|
81
|
-
When GET is sent to '/responses/greeting/for/joel'
|
82
|
-
Then 'default greeting' should be returned
|
83
|
-
|
84
|
-
|
85
|
-
Scenario: Setting the content type
|
86
|
-
Given I run
|
87
|
-
"""
|
88
|
-
Mirage::Client.new.put('greeting', '<xml></xml>') do
|
89
|
-
content_type 'text/xml'
|
90
|
-
end
|
91
|
-
"""
|
92
|
-
When GET is sent to '/responses/greeting'
|
93
|
-
And the response 'content-type' should be 'text/xml'
|
94
|
-
|
95
|
-
|
96
|
-
Scenario: Setting the HTTP status code
|
97
|
-
Given I run
|
98
|
-
"""
|
99
|
-
Mirage::Client.new.put('greeting', 'hello'){status 203}
|
100
|
-
"""
|
101
|
-
When GET is sent to '/responses/greeting'
|
102
|
-
Then a 203 should be returned
|
103
|
-
|
104
|
-
|
105
|
-
Scenario: Setting a delay
|
106
|
-
Given I run
|
107
|
-
"""
|
108
|
-
Mirage::Client.new.put('greeting', 'hello'){delay 2}
|
109
|
-
"""
|
110
|
-
When GET is sent to '/responses/greeting'
|
111
|
-
Then it should take at least '2' seconds
|
data/features/client/readme.md
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Feature: Retrieving tracked requests
|
2
|
-
|
3
|
-
Requests made to the Mirage Server can be retrieved using the Mirage client
|
4
|
-
|
5
|
-
Background:
|
6
|
-
Given the following require statements are needed:
|
7
|
-
"""
|
8
|
-
require 'rubygems'
|
9
|
-
require 'mirage/client'
|
10
|
-
"""
|
11
|
-
|
12
|
-
Scenario: Retrieving request data
|
13
|
-
Given a template for 'greeting' has been set with a value of 'Hello'
|
14
|
-
|
15
|
-
When I send GET to '/responses/greeting' with parameters:
|
16
|
-
| name | leon |
|
17
|
-
Then I run
|
18
|
-
"""
|
19
|
-
Mirage::Client.new.requests(1).parameters.should == {'name' => 'leon'}
|
20
|
-
"""
|
@@ -1,51 +0,0 @@
|
|
1
|
-
@command_line
|
2
|
-
Feature: How to check if Mirage is running
|
3
|
-
|
4
|
-
Use the Mirage client api to check if Mirage is running either on the local machine or on a remote host.
|
5
|
-
|
6
|
-
|
7
|
-
Background:
|
8
|
-
Given the following require statements are needed:
|
9
|
-
"""
|
10
|
-
require 'rubygems'
|
11
|
-
require 'rspec/expectations'
|
12
|
-
require 'mirage/client'
|
13
|
-
"""
|
14
|
-
|
15
|
-
|
16
|
-
Scenario: Check if mirage is running on the local machine on the default port
|
17
|
-
Given Mirage is not running
|
18
|
-
Then I run
|
19
|
-
"""
|
20
|
-
Mirage.running?.should == false
|
21
|
-
"""
|
22
|
-
Given Mirage is running
|
23
|
-
Then I run
|
24
|
-
"""
|
25
|
-
Mirage.running?.should == true
|
26
|
-
"""
|
27
|
-
|
28
|
-
|
29
|
-
Scenario: Check if mirage is running on the local machine on a non standard port
|
30
|
-
Given I run 'mirage start -p 9001'
|
31
|
-
Then I run
|
32
|
-
"""
|
33
|
-
Mirage.running?(:port => 9001).should == true
|
34
|
-
"""
|
35
|
-
|
36
|
-
|
37
|
-
Scenario: Checking if mirage is running on remote machine
|
38
|
-
Given I run 'mirage start -p 9001'
|
39
|
-
Then I run
|
40
|
-
"""
|
41
|
-
Mirage.running? "http://localhost:9001"
|
42
|
-
"""
|
43
|
-
|
44
|
-
|
45
|
-
Scenario: Check if mirage is running using the client directly
|
46
|
-
Given I run 'mirage start -p 9001'
|
47
|
-
Then I run
|
48
|
-
"""
|
49
|
-
client = Mirage::Client.new "http://localhost:9001"
|
50
|
-
client.running?.should == true
|
51
|
-
"""
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Feature: Creating snapshots
|
2
|
-
|
3
|
-
The client can be used to snapshot and rollback the Mirage server
|
4
|
-
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given the following require statements are needed:
|
8
|
-
"""
|
9
|
-
require 'rubygems'
|
10
|
-
require 'rspec/expectations'
|
11
|
-
require 'mirage/client'
|
12
|
-
"""
|
13
|
-
And a template for 'greeting' has been set with a value of 'The default greeting'
|
14
|
-
|
15
|
-
|
16
|
-
Scenario: Creating a snapshot and rolling back
|
17
|
-
Given I run
|
18
|
-
"""
|
19
|
-
Mirage::Client.new.save
|
20
|
-
"""
|
21
|
-
And I send PUT to '/templates/leaving' with request entity
|
22
|
-
"""
|
23
|
-
Goodbye
|
24
|
-
"""
|
25
|
-
|
26
|
-
And I send PUT to '/templates/greeting' with request entity
|
27
|
-
"""
|
28
|
-
Changed
|
29
|
-
"""
|
30
|
-
|
31
|
-
When I run
|
32
|
-
"""
|
33
|
-
Mirage::Client.new.revert
|
34
|
-
"""
|
35
|
-
And GET is sent to '/responses/leaving'
|
36
|
-
Then a 404 should be returned
|
37
|
-
|
38
|
-
When GET is sent to '/responses/greeting'
|
39
|
-
Then 'The default greeting' should be returned
|