mirage 3.0.0.alpha.17 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile.lock +107 -76
- data/README.md +2 -1
- data/{rakefile → Rakefile} +0 -0
- data/VERSION +1 -1
- data/features/.nav +10 -0
- data/features/client/clear.feature +5 -3
- data/features/client/configure.feature +4 -2
- data/features/client/model.feature +95 -0
- data/features/client/preview_responses.feature +7 -6
- data/features/client/prime.feature +32 -0
- data/features/client/put.feature +14 -43
- data/features/client/readme.md +3 -0
- data/features/client/requests.feature +3 -1
- data/features/client/running.feature +4 -2
- data/features/client/save_and_revert.feature +5 -3
- data/features/client/start.feature +3 -1
- data/features/client/stop.feature +3 -1
- data/features/commandline_interface/help.feature +1 -1
- data/features/prime.feature +5 -5
- data/features/step_definitions/my_steps.rb +3 -0
- data/features/templates/preview.feature +2 -2
- data/features/templates/put_with_substitutions.feature +1 -1
- data/features/templates/readme.md +0 -3
- data/features/web_user_interface.feature +39 -27
- data/lib/mirage/client/client.rb +0 -1
- data/lib/mirage/client/error.rb +2 -2
- data/lib/mirage/client/runner.rb +1 -1
- data/lib/mirage/client/template.rb +1 -1
- data/lib/mirage/client/templates.rb +1 -1
- data/mirage.gemspec +12 -11
- data/server/extensions/hash.rb +1 -1
- data/spec/client/cli_bridge_spec.rb +2 -2
- data/spec/client/client_spec.rb +4 -4
- data/spec/client/runner_spec.rb +13 -12
- data/spec/client/template/model/instance_methods_spec.rb +1 -1
- data/spec/client/template_spec.rb +1 -1
- data/spec/client/templates_spec.rb +7 -7
- data/spec/server/server_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/{responses/default_responses.rb → todo.list} +0 -0
- metadata +14 -13
- data/.rvmrc +0 -1
- data/profiles.rb +0 -1
- data/test.html +0 -12
- data/test.rb +0 -5
- data/todo.lst +0 -2
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
mirage
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,104 +1,135 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
addressable (2.3.5)
|
5
|
+
backports (3.3.5)
|
6
|
+
bouncy-castle-java (1.5.0147)
|
7
|
+
builder (3.2.2)
|
8
|
+
childprocess (0.3.9)
|
9
|
+
ffi (~> 1.0, >= 1.0.11)
|
10
|
+
cucumber (1.3.8)
|
10
11
|
builder (>= 2.1.2)
|
11
|
-
diff-lcs (>= 1.1.
|
12
|
-
gherkin (~> 2.
|
13
|
-
|
14
|
-
|
15
|
-
diff-lcs (1.
|
16
|
-
domain_name (0.5.
|
17
|
-
unf (
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ffi (1.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
12
|
+
diff-lcs (>= 1.1.3)
|
13
|
+
gherkin (~> 2.12.1)
|
14
|
+
multi_json (>= 1.7.5, < 2.0)
|
15
|
+
multi_test (>= 0.0.2)
|
16
|
+
diff-lcs (1.2.4)
|
17
|
+
domain_name (0.5.14)
|
18
|
+
unf (>= 0.0.5, < 1.0.0)
|
19
|
+
faraday (0.8.8)
|
20
|
+
multipart-post (~> 1.2.0)
|
21
|
+
ffi (1.9.1)
|
22
|
+
ffi (1.9.1-java)
|
23
|
+
gherkin (2.12.2)
|
24
|
+
multi_json (~> 1.3)
|
25
|
+
gherkin (2.12.2-java)
|
26
|
+
multi_json (~> 1.3)
|
27
|
+
gherkin (2.12.2-x86-mingw32)
|
28
|
+
multi_json (~> 1.3)
|
29
|
+
git (1.2.6)
|
30
|
+
github_api (0.10.1)
|
31
|
+
addressable
|
32
|
+
faraday (~> 0.8.1)
|
33
|
+
hashie (>= 1.2)
|
34
|
+
multi_json (~> 1.4)
|
35
|
+
nokogiri (~> 1.5.2)
|
36
|
+
oauth2
|
37
|
+
haml (4.0.3)
|
31
38
|
tilt
|
32
|
-
hashie (2.0.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
hashie (2.0.5)
|
40
|
+
highline (1.6.20)
|
41
|
+
http-cookie (1.0.2)
|
42
|
+
domain_name (~> 0.5)
|
43
|
+
httparty (0.12.0)
|
44
|
+
json (~> 1.8)
|
45
|
+
multi_xml (>= 0.5.2)
|
46
|
+
httpauth (0.2.0)
|
47
|
+
jeweler (1.8.8)
|
48
|
+
builder
|
37
49
|
bundler (~> 1.0)
|
38
50
|
git (>= 1.2.5)
|
51
|
+
github_api (= 0.10.1)
|
52
|
+
highline (>= 1.6.15)
|
53
|
+
nokogiri (= 1.5.10)
|
39
54
|
rake
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
json (1.
|
44
|
-
|
55
|
+
rdoc
|
56
|
+
jruby-openssl (0.9.4)
|
57
|
+
bouncy-castle-java (>= 1.5.0147)
|
58
|
+
json (1.8.1)
|
59
|
+
json (1.8.1-java)
|
60
|
+
jwt (0.1.8)
|
61
|
+
multi_json (>= 1.5)
|
62
|
+
mechanize (2.7.2)
|
45
63
|
domain_name (~> 0.5, >= 0.5.1)
|
64
|
+
http-cookie (~> 1.0.0)
|
65
|
+
mime-types (~> 1.17, >= 1.17.2)
|
46
66
|
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
47
|
-
net-http-persistent (~> 2.
|
67
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
48
68
|
nokogiri (~> 1.4)
|
49
69
|
ntlm-http (~> 0.1, >= 0.1.1)
|
50
|
-
webrobots (
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
70
|
+
webrobots (>= 0.0.9, < 0.2)
|
71
|
+
mime-types (1.25)
|
72
|
+
multi_json (1.8.2)
|
73
|
+
multi_test (0.0.2)
|
74
|
+
multi_xml (0.5.5)
|
75
|
+
multipart-post (1.2.0)
|
76
|
+
net-http-digest_auth (1.4)
|
77
|
+
net-http-persistent (2.9)
|
78
|
+
nokogiri (1.5.10)
|
79
|
+
nokogiri (1.5.10-java)
|
80
|
+
nokogiri (1.5.10-x86-mingw32)
|
58
81
|
ntlm-http (0.1.1)
|
82
|
+
oauth2 (0.9.2)
|
83
|
+
faraday (~> 0.8)
|
84
|
+
httpauth (~> 0.2)
|
85
|
+
jwt (~> 0.1.4)
|
86
|
+
multi_json (~> 1.0)
|
87
|
+
multi_xml (~> 0.5)
|
88
|
+
rack (~> 1.2)
|
59
89
|
ptools (1.2.2)
|
60
90
|
ptools (1.2.2-x86-mingw32)
|
61
91
|
win32-file (>= 0.5.4)
|
62
|
-
rack (1.
|
63
|
-
rack-protection (1.
|
92
|
+
rack (1.5.2)
|
93
|
+
rack-protection (1.5.1)
|
64
94
|
rack
|
65
|
-
rack-test (0.6.
|
95
|
+
rack-test (0.6.2)
|
66
96
|
rack (>= 1.0)
|
67
|
-
rake (
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rspec-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
rspec-
|
76
|
-
|
97
|
+
rake (10.1.0)
|
98
|
+
rdoc (4.0.1)
|
99
|
+
json (~> 1.4)
|
100
|
+
rspec (2.14.1)
|
101
|
+
rspec-core (~> 2.14.0)
|
102
|
+
rspec-expectations (~> 2.14.0)
|
103
|
+
rspec-mocks (~> 2.14.0)
|
104
|
+
rspec-core (2.14.6)
|
105
|
+
rspec-expectations (2.14.3)
|
106
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
107
|
+
rspec-mocks (2.14.4)
|
108
|
+
simplecov (0.7.1)
|
77
109
|
multi_json (~> 1.0)
|
78
|
-
simplecov-html (~> 0.
|
79
|
-
simplecov-html (0.
|
80
|
-
sinatra (1.
|
81
|
-
rack (~> 1.
|
82
|
-
rack-protection (~> 1.
|
83
|
-
tilt (~> 1.3, >= 1.3.
|
84
|
-
sinatra-contrib (1.
|
110
|
+
simplecov-html (~> 0.7.1)
|
111
|
+
simplecov-html (0.7.1)
|
112
|
+
sinatra (1.4.4)
|
113
|
+
rack (~> 1.4)
|
114
|
+
rack-protection (~> 1.4)
|
115
|
+
tilt (~> 1.3, >= 1.3.4)
|
116
|
+
sinatra-contrib (1.4.1)
|
85
117
|
backports (>= 2.0)
|
86
|
-
|
118
|
+
multi_json
|
87
119
|
rack-protection
|
88
120
|
rack-test
|
89
|
-
sinatra (~> 1.
|
121
|
+
sinatra (~> 1.4.0)
|
90
122
|
tilt (~> 1.3)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
unf (0.0.4)
|
123
|
+
thor (0.18.1)
|
124
|
+
tilt (1.4.1)
|
125
|
+
unf (0.1.3)
|
95
126
|
unf_ext
|
96
|
-
|
97
|
-
unf_ext (0.0.
|
127
|
+
unf (0.1.3-java)
|
128
|
+
unf_ext (0.0.6)
|
129
|
+
unf_ext (0.0.6-x86-mingw32)
|
98
130
|
waitforit (0.0.1)
|
99
|
-
webrobots (0.
|
100
|
-
|
101
|
-
win32-api (1.4.8-x86-mingw32)
|
131
|
+
webrobots (0.1.1)
|
132
|
+
win32-api (1.5.0-x86-mingw32)
|
102
133
|
win32-file (0.6.8)
|
103
134
|
win32-api (>= 1.2.1)
|
104
135
|
win32-file-stat (>= 1.3.2)
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/lashd/mirage.png)](https://travis-ci.org/lashd/mirage)
|
1
2
|
Mirage
|
2
3
|
======
|
3
4
|
Mirage aids testing of your applications by hosting mock responses so that your applications do not have to talk to real endpoints. It's accessible via HTTP and has a RESTful interface.
|
@@ -10,7 +11,7 @@ I hope you find it useful,
|
|
10
11
|
|
11
12
|
Leon
|
12
13
|
|
13
|
-
P.s. Mirage runs on Linux,MacOSX and Windows; Rubies 1.
|
14
|
+
P.s. Mirage runs on Linux,MacOSX and Windows; Rubies 1.9.3+ and JRuby.
|
14
15
|
|
15
16
|
Installation
|
16
17
|
------------
|
data/{rakefile → Rakefile}
RENAMED
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.0
|
1
|
+
3.0.0
|
data/features/.nav
CHANGED
@@ -17,3 +17,13 @@
|
|
17
17
|
- logging.feature (Logs)
|
18
18
|
- web_user_interface.feature
|
19
19
|
- client (Ruby client):
|
20
|
+
- start.feature
|
21
|
+
- stop.feature
|
22
|
+
- running.feature
|
23
|
+
- put.feature
|
24
|
+
- configure.feature
|
25
|
+
- clear.feature
|
26
|
+
- preview_responses.feature
|
27
|
+
- model.feature
|
28
|
+
- requests.feature
|
29
|
+
- save_and_revert.feature
|
@@ -1,6 +1,8 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: Clearing Templates
|
2
2
|
|
3
|
-
|
3
|
+
The client can be used to clear responses and tracked request data from Mirage.
|
4
|
+
|
5
|
+
Like when calling Mirage's own interface directly, clearing a template also clears any associated request data
|
4
6
|
|
5
7
|
Background:
|
6
8
|
Given the following require statements are needed:
|
@@ -35,7 +37,7 @@ Feature: The client can be used for clearing down Mirage.
|
|
35
37
|
Then a 200 should be returned
|
36
38
|
|
37
39
|
|
38
|
-
Scenario:
|
40
|
+
Scenario: Clearing a request
|
39
41
|
Given I run
|
40
42
|
"""
|
41
43
|
Mirage::Client.new.requests(1).delete
|
@@ -1,10 +1,12 @@
|
|
1
|
-
Feature:
|
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.
|
2
4
|
|
3
5
|
Background:
|
4
6
|
Given the following gems are required to run the Mirage client test code:
|
5
7
|
"""
|
6
8
|
require 'rubygems'
|
7
|
-
require 'rspec'
|
9
|
+
require 'rspec/expectations'
|
8
10
|
require 'mirage/client'
|
9
11
|
"""
|
10
12
|
|
@@ -0,0 +1,95 @@
|
|
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 gems are required to run the Mirage client test code:
|
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,14 +1,16 @@
|
|
1
|
-
Feature:
|
1
|
+
Feature: Inspecting Templates
|
2
|
+
|
3
|
+
The client can be used to retrieve a template stored on Mirage.
|
2
4
|
|
3
5
|
Background:
|
4
6
|
Given the following gems are required to run the Mirage client test code:
|
5
7
|
"""
|
6
8
|
require 'rubygems'
|
7
|
-
require 'rspec'
|
9
|
+
require 'rspec/expectations'
|
8
10
|
require 'mirage/client'
|
9
11
|
"""
|
10
12
|
|
11
|
-
Scenario:
|
13
|
+
Scenario: retrieving a Template
|
12
14
|
Given a template for 'greeting' has been set with a value of 'Hello'
|
13
15
|
|
14
16
|
When I run
|
@@ -19,14 +21,13 @@ Feature: the client can be used for peeking at responses hosted on Mirage.
|
|
19
21
|
When GET is sent to '/requests/1'
|
20
22
|
Then a 404 should be returned
|
21
23
|
|
22
|
-
Scenario:
|
24
|
+
Scenario: retrieving a Template that does not exist
|
23
25
|
Given I run
|
24
26
|
"""
|
25
27
|
begin
|
26
28
|
Mirage::Client.new.templates(2).should == 'this should not have happened'
|
27
29
|
fail("Error should have been thrown")
|
28
30
|
rescue Exception => e
|
29
|
-
|
30
|
-
e.is_a?(Mirage::ResponseNotFound).should == true
|
31
|
+
e.is_a?(Mirage::TemplateNotFound).should == true
|
31
32
|
end
|
32
33
|
"""
|
@@ -0,0 +1,32 @@
|
|
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 gems are required to run the Mirage client test code:
|
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
|