mirage 1.0.1 → 1.0.2
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/features/server/web_user_interface.feature +2 -0
- data/lib/mirage/core.rb +8 -9
- data/lib/view/mirage/index.xhtml +7 -2
- data/mirage.gemspec +1 -1
- metadata +4 -4
@@ -2,6 +2,8 @@ Feature: Mirage's home page allows you to see what response are currently being
|
|
2
2
|
From this page you can:
|
3
3
|
- Peek at a responses content
|
4
4
|
- Track the response to see if a request has been made to it
|
5
|
+
|
6
|
+
#TODO tests needed for displaying pattern and delay values
|
5
7
|
|
6
8
|
Background: There are already a couple of responses hosted on he Mirage server
|
7
9
|
Given I hit 'http://localhost:7001/mirage/set/greeting' with parameters:
|
data/lib/mirage/core.rb
CHANGED
@@ -67,11 +67,11 @@ module Mirage
|
|
67
67
|
@responses = {}
|
68
68
|
|
69
69
|
RESPONSES.each do |name, responses|
|
70
|
-
@responses[name]=responses.default unless responses.default.nil?
|
71
|
-
|
72
70
|
responses.each do |pattern, response|
|
73
|
-
pattern = pattern.is_a?(Regexp) ? pattern.source :
|
74
|
-
|
71
|
+
pattern = pattern.is_a?(Regexp) ? "pattern = #{pattern.source}" : ''
|
72
|
+
delay = response.delay > 0 ? "delay = #{response.delay}" : ''
|
73
|
+
pattern << ' ,' unless pattern.empty? || delay.empty?
|
74
|
+
@responses["#{name}#{'/*' if response.default?}: #{pattern} #{delay}"] = response
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -79,8 +79,7 @@ module Mirage
|
|
79
79
|
def peek response_id
|
80
80
|
peeked_response = nil
|
81
81
|
RESPONSES.values.each do |responses|
|
82
|
-
peeked_response = responses
|
83
|
-
peeked_response = responses.values.find { |response| response.response_id == response_id.to_i } if peeked_response.nil?
|
82
|
+
peeked_response = responses.values.find { |response| response.response_id == response_id.to_i }
|
84
83
|
break unless peeked_response.nil?
|
85
84
|
end
|
86
85
|
respond("Can not peek reponse, id:#{response_id} does not exist}", 404) unless peeked_response
|
@@ -89,7 +88,7 @@ module Mirage
|
|
89
88
|
|
90
89
|
def set *args
|
91
90
|
delay = (request['delay']||0)
|
92
|
-
pattern = request['pattern'] ? /#{request['pattern']}/ : :
|
91
|
+
pattern = request['pattern'] ? /#{request['pattern']}/ : :basic
|
93
92
|
name = args.join('/')
|
94
93
|
is_default = request['default'] == 'true'
|
95
94
|
|
@@ -173,8 +172,8 @@ module Mirage
|
|
173
172
|
|
174
173
|
private
|
175
174
|
def find_response(body, query_string, stored_responses)
|
176
|
-
pattern_match = stored_responses.keys.find_all { |pattern| pattern != :
|
177
|
-
record = pattern_match ? stored_responses[pattern_match] : stored_responses[:
|
175
|
+
pattern_match = stored_responses.keys.find_all { |pattern| pattern != :basic }.find { |pattern| body =~ pattern || query_string =~ pattern }
|
176
|
+
record = pattern_match ? stored_responses[pattern_match] : stored_responses[:basic]
|
178
177
|
record
|
179
178
|
end
|
180
179
|
|
data/lib/view/mirage/index.xhtml
CHANGED
@@ -9,8 +9,13 @@
|
|
9
9
|
<body>
|
10
10
|
<h1>Welcome to Mirage</h1>
|
11
11
|
|
12
|
-
<p>Below are any responses you are currently hosting. Click the response itself to peek at it and click
|
13
|
-
|
12
|
+
<p>Below are any responses you are currently hosting. Click the response itself to peek at it and click 'track' to view the last request that triggered it.<br/>
|
13
|
+
<br/>
|
14
|
+
Patterns and delays are shown for responses that have them.<br/>
|
15
|
+
<br/>
|
16
|
+
Responses with '*' at the end are default responses. I.e. they will be returned, where appropriate, for requests to a sub endpoint if a response is not found at that level.<br/>
|
17
|
+
<br/>
|
18
|
+
<strong>Note:</strong> if requests or responses contain xml, you will need to view page source to see it properly.</p>
|
14
19
|
|
15
20
|
<?r unless @responses.empty? ?>
|
16
21
|
<table border="1" width='100%'>
|
data/mirage.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mirage'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.2'
|
4
4
|
s.authors = ["Leon Davis"]
|
5
5
|
s.homepage = 'https://github.com/lashd/mirage'
|
6
6
|
s.description = 'Mirage aids testing of your applications by hosting mock responses so that your applications do not have to talk to real endpoints. Its accessible via HTTP and has a RESTful interface.'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mirage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Leon Davis
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-30 00:00:00 +01:00
|
14
14
|
default_executable: mirage
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -144,7 +144,7 @@ licenses: []
|
|
144
144
|
|
145
145
|
post_install_message: "\n\
|
146
146
|
===============================================================================\n\
|
147
|
-
Thanks you for installing mirage-1.0.
|
147
|
+
Thanks you for installing mirage-1.0.2. \n\n\
|
148
148
|
Run Mirage with:\n\n\
|
149
149
|
mirage start \n\n\
|
150
150
|
For more information go to: https://github.com/lashd/mirage/wiki\n\
|
@@ -171,7 +171,7 @@ rubyforge_project:
|
|
171
171
|
rubygems_version: 1.6.1
|
172
172
|
signing_key:
|
173
173
|
specification_version: 3
|
174
|
-
summary: mirage-1.0.
|
174
|
+
summary: mirage-1.0.2
|
175
175
|
test_files:
|
176
176
|
- features/client/clear.feature
|
177
177
|
- features/client/get.feature
|