mirage 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,7 @@ GEM
18
18
  multipart-post (~> 1.2.0)
19
19
  ffi (1.9.0)
20
20
  ffi (1.9.0-java)
21
+ ffi (1.9.0-x86-mingw32)
21
22
  gherkin (2.12.2)
22
23
  multi_json (~> 1.3)
23
24
  gherkin (2.12.2-java)
data/HISTORY CHANGED
@@ -1,3 +1,4 @@
1
+ V3.0.6 - bug fix
1
2
  V3.0.5 - fixed bug in builder methods
2
3
  V3.0.1 - updating gem post install message to point people towards the readme due checkout the differences between version 2 and 3 of Mirage
3
4
  V3.0.0 - Major update see README.md
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.6
1
+ 3.0.7
@@ -2,16 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: mirage 3.0.6 ruby lib
6
5
 
7
6
  Gem::Specification.new do |s|
8
7
  s.name = "mirage"
9
- s.version = "3.0.6"
8
+ s.version = "3.0.7"
10
9
 
11
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
11
  s.authors = ["Leon Davis"]
14
- s.date = "2014-01-23"
12
+ s.date = "2014-06-05"
15
13
  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."
16
14
  s.executables = ["mirage"]
17
15
  s.extra_rdoc_files = [
@@ -90,6 +88,8 @@ Gem::Specification.new do |s|
90
88
  "server/extensions/hash.rb",
91
89
  "server/extensions/object.rb",
92
90
  "server/helpers.rb",
91
+ "server/helpers/http_headers.rb",
92
+ "server/helpers/template_requirements.rb",
93
93
  "server/mock_response.rb",
94
94
  "server/server.rb",
95
95
  "spec/client/cli_bridge_spec.rb",
@@ -106,7 +106,8 @@ Gem::Specification.new do |s|
106
106
  "spec/client/templates_spec.rb",
107
107
  "spec/resources/binary.file",
108
108
  "spec/server/binary_data_checker_spec.rb",
109
- "spec/server/helpers_spec.rb",
109
+ "spec/server/helpers/http_headers_spec.rb",
110
+ "spec/server/helpers/template_requirements_spec.rb",
110
111
  "spec/server/mock_response_spec.rb",
111
112
  "spec/server/server_spec.rb",
112
113
  "spec/spec_helper.rb",
@@ -119,11 +120,12 @@ Gem::Specification.new do |s|
119
120
  s.homepage = "https://github.com/lashd/mirage"
120
121
  s.licenses = ["MIT"]
121
122
  s.post_install_message = "\n===============================================================================\nMirage v3:\n\nMirage has just gone up a major version from 2 to 3. If your project uses\na previous version take a look at https://github.com/lashd/mirage to see\nwhat's changed\n===============================================================================\n"
122
- s.rubygems_version = "2.2.0"
123
+ s.require_paths = ["lib"]
124
+ s.rubygems_version = "1.8.25"
123
125
  s.summary = "Mirage is a easy mock server for testing your applications"
124
126
 
125
127
  if s.respond_to? :specification_version then
126
- s.specification_version = 4
128
+ s.specification_version = 3
127
129
 
128
130
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
129
131
  s.add_runtime_dependency(%q<sinatra>, [">= 0"])
@@ -1,28 +1,3 @@
1
- require 'tempfile'
2
- require 'ptools'
3
- module Mirage
4
- class Server < Sinatra::Base
5
- module Helpers
6
- def convert_raw_required_params raw_requirements
7
- raw_requirements.collect { |requirement| requirement.split(":") }.inject({}) do |hash, pair|
8
- parameter, value = pair.collect { |string| string.strip }
9
- value = convert_value(value)
10
- hash[parameter] =value; hash
11
- end
12
- end
13
-
14
- def convert_raw_required_body_content_requirements raw_requirements
15
- raw_requirements.collect do |string|
16
- string.start_with?("%r{") && string.end_with?("}") ? eval(string) : string
17
- end
18
- end
19
-
20
-
21
-
22
- private
23
- def convert_value(value)
24
- value.start_with?("%r{") && value.end_with?("}") ? eval(value) : value
25
- end
26
- end
27
- end
28
- end
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ require 'helpers/template_requirements'
3
+ require 'helpers/http_headers'
@@ -0,0 +1,30 @@
1
+ require 'rack/utils'
2
+ require 'sinatra/base'
3
+ module Mirage
4
+ class Server < Sinatra::Base
5
+ module Helpers
6
+ module HttpHeaders
7
+ def extract_http_headers(env)
8
+ headers = env.reject do |k, v|
9
+ k.to_s.upcase != 'CONTENT_TYPE' && (!(/^HTTP_[A-Z_]+$/ === k) || v.nil?)
10
+ end.map do |k, v|
11
+ [reconstruct_header_name(k), v]
12
+ end.inject(Rack::Utils::HeaderHash.new) do |hash, k_v|
13
+ k, v = k_v
14
+ hash[k] = v
15
+ hash
16
+ end
17
+
18
+ x_forwarded_for = (headers["X-Forwarded-For"].to_s.split(/, +/) << env["REMOTE_ADDR"]).join(", ")
19
+
20
+ headers.merge!("X-Forwarded-For" => x_forwarded_for)
21
+ end
22
+
23
+ def reconstruct_header_name(name)
24
+ name.sub(/^HTTP_/, "").gsub("_", "-")
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,33 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ require 'tempfile'
3
+ require 'ptools'
4
+ require 'sinatra/base'
5
+ require 'helpers/http_headers'
6
+
7
+ module Mirage
8
+ class Server < Sinatra::Base
9
+ module Helpers
10
+ module TemplateRequirements
11
+ def convert_raw_required_params raw_requirements
12
+ raw_requirements.collect { |requirement| requirement.split(":") }.inject({}) do |hash, pair|
13
+ parameter, value = pair.collect { |string| string.strip }
14
+ value = convert_value(value)
15
+ hash[parameter] =value; hash
16
+ end
17
+ end
18
+
19
+ def convert_raw_required_body_content_requirements raw_requirements
20
+ raw_requirements.collect do |string|
21
+ string.start_with?("%r{") && string.end_with?("}") ? eval(string) : string
22
+ end
23
+ end
24
+
25
+
26
+ private
27
+ def convert_value(value)
28
+ value.start_with?("%r{") && value.end_with?("}") ? eval(value) : value
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -7,7 +7,7 @@ module Mirage
7
7
 
8
8
  REQUESTS = {}
9
9
 
10
- helpers Mirage::Server::Helpers
10
+ helpers Helpers::TemplateRequirements, Helpers::HttpHeaders
11
11
 
12
12
  put '/templates/*' do |name|
13
13
  content_type :json
@@ -23,7 +23,7 @@ module Mirage
23
23
  send(http_method, '/responses/*') do |name|
24
24
  body, query_string = Rack::Utils.unescape(request.body.read.to_s), request.query_string
25
25
 
26
- options = {:body => body,
26
+ options = {:body => body,
27
27
  :http_method => http_method,
28
28
  :endpoint => name,
29
29
  :params => request.params,
@@ -178,25 +178,7 @@ module Mirage
178
178
  mock_response.value(body, request, query_string)
179
179
  end
180
180
 
181
- def extract_http_headers(env)
182
- headers = env.reject do |k, v|
183
- !(/^HTTP_[A-Z_]+$/ === k) || v.nil?
184
- end.map do |k, v|
185
- [reconstruct_header_name(k), v]
186
- end.inject(Rack::Utils::HeaderHash.new) do |hash, k_v|
187
- k, v = k_v
188
- hash[k] = v
189
- hash
190
- end
191
-
192
- x_forwarded_for = (headers["X-Forwarded-For"].to_s.split(/, +/) << env["REMOTE_ADDR"]).join(", ")
193
181
 
194
- headers.merge!("X-Forwarded-For" => x_forwarded_for)
195
- end
196
-
197
- def reconstruct_header_name(name)
198
- name.sub(/^HTTP_/, "").gsub("_", "-")
199
- end
200
182
  end
201
183
  end
202
184
  end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'helpers/http_headers'
3
+ describe Mirage::Server::Helpers::HttpHeaders do
4
+ describe '#extract_http_headers' do
5
+ it 'returns content-type' do
6
+ helpers = Object.new
7
+ helpers.extend(described_class)
8
+ expected = {'CONTENT_TYPE' => 'application/json'}
9
+ expect(helpers.extract_http_headers(expected)['Content-Type']).to eq('application/json')
10
+ end
11
+
12
+ end
13
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'sinatra'
3
- require 'helpers'
3
+ require 'helpers/template_requirements'
4
4
 
5
5
 
6
6
  describe "helpers" do
@@ -8,7 +8,7 @@ describe "helpers" do
8
8
 
9
9
  before :each do
10
10
  @helper = Object.new
11
- @helper.extend(Mirage::Server::Helpers)
11
+ @helper.extend(Mirage::Server::Helpers::TemplateRequirements)
12
12
  end
13
13
 
14
14
  describe 'converting raw parameter requirements' do
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mirage
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.0.7
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Leon Davis
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-06-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sinatra
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: childprocess
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: waitforit
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: thor
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -69,6 +78,7 @@ dependencies:
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: ptools
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
83
  - - ! '>='
74
84
  - !ruby/object:Gem::Version
@@ -76,6 +86,7 @@ dependencies:
76
86
  type: :runtime
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
91
  - - ! '>='
81
92
  - !ruby/object:Gem::Version
@@ -83,6 +94,7 @@ dependencies:
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: httparty
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - ! '>='
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :runtime
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - ! '>='
95
108
  - !ruby/object:Gem::Version
@@ -97,6 +110,7 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: haml
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
115
  - - ! '>='
102
116
  - !ruby/object:Gem::Version
@@ -104,6 +118,7 @@ dependencies:
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
123
  - - ! '>='
109
124
  - !ruby/object:Gem::Version
@@ -111,6 +126,7 @@ dependencies:
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: hashie
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
131
  - - ! '>='
116
132
  - !ruby/object:Gem::Version
@@ -118,6 +134,7 @@ dependencies:
118
134
  type: :runtime
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
139
  - - ! '>='
123
140
  - !ruby/object:Gem::Version
@@ -125,6 +142,7 @@ dependencies:
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: rake
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
147
  - - ! '>='
130
148
  - !ruby/object:Gem::Version
@@ -132,6 +150,7 @@ dependencies:
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
155
  - - ! '>='
137
156
  - !ruby/object:Gem::Version
@@ -139,6 +158,7 @@ dependencies:
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: jeweler
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
163
  - - ! '>='
144
164
  - !ruby/object:Gem::Version
@@ -146,6 +166,7 @@ dependencies:
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
171
  - - ! '>='
151
172
  - !ruby/object:Gem::Version
@@ -153,6 +174,7 @@ dependencies:
153
174
  - !ruby/object:Gem::Dependency
154
175
  name: sinatra-contrib
155
176
  requirement: !ruby/object:Gem::Requirement
177
+ none: false
156
178
  requirements:
157
179
  - - ! '>='
158
180
  - !ruby/object:Gem::Version
@@ -160,6 +182,7 @@ dependencies:
160
182
  type: :development
161
183
  prerelease: false
162
184
  version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
163
186
  requirements:
164
187
  - - ! '>='
165
188
  - !ruby/object:Gem::Version
@@ -167,6 +190,7 @@ dependencies:
167
190
  - !ruby/object:Gem::Dependency
168
191
  name: jruby-openssl
169
192
  requirement: !ruby/object:Gem::Requirement
193
+ none: false
170
194
  requirements:
171
195
  - - ! '>='
172
196
  - !ruby/object:Gem::Version
@@ -174,6 +198,7 @@ dependencies:
174
198
  type: :development
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
177
202
  requirements:
178
203
  - - ! '>='
179
204
  - !ruby/object:Gem::Version
@@ -260,6 +285,8 @@ files:
260
285
  - server/extensions/hash.rb
261
286
  - server/extensions/object.rb
262
287
  - server/helpers.rb
288
+ - server/helpers/http_headers.rb
289
+ - server/helpers/template_requirements.rb
263
290
  - server/mock_response.rb
264
291
  - server/server.rb
265
292
  - spec/client/cli_bridge_spec.rb
@@ -276,7 +303,8 @@ files:
276
303
  - spec/client/templates_spec.rb
277
304
  - spec/resources/binary.file
278
305
  - spec/server/binary_data_checker_spec.rb
279
- - spec/server/helpers_spec.rb
306
+ - spec/server/helpers/http_headers_spec.rb
307
+ - spec/server/helpers/template_requirements_spec.rb
280
308
  - spec/server/mock_response_spec.rb
281
309
  - spec/server/server_spec.rb
282
310
  - spec/spec_helper.rb
@@ -288,7 +316,6 @@ files:
288
316
  homepage: https://github.com/lashd/mirage
289
317
  licenses:
290
318
  - MIT
291
- metadata: {}
292
319
  post_install_message: ! '
293
320
 
294
321
  ===============================================================================
@@ -309,19 +336,24 @@ rdoc_options: []
309
336
  require_paths:
310
337
  - lib
311
338
  required_ruby_version: !ruby/object:Gem::Requirement
339
+ none: false
312
340
  requirements:
313
341
  - - ! '>='
314
342
  - !ruby/object:Gem::Version
315
343
  version: '0'
344
+ segments:
345
+ - 0
346
+ hash: 823988503959653715
316
347
  required_rubygems_version: !ruby/object:Gem::Requirement
348
+ none: false
317
349
  requirements:
318
350
  - - ! '>='
319
351
  - !ruby/object:Gem::Version
320
352
  version: '0'
321
353
  requirements: []
322
354
  rubyforge_project:
323
- rubygems_version: 2.2.0
355
+ rubygems_version: 1.8.25
324
356
  signing_key:
325
- specification_version: 4
357
+ specification_version: 3
326
358
  summary: Mirage is a easy mock server for testing your applications
327
359
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDU3ZDM3N2QxMDg4MzZjY2EzZDk1NWNhYzc1ZTZlNWU5ZmJlZjk5Mg==
5
- data.tar.gz: !binary |-
6
- YzY2OTZjMTJjNDVkMDk3MDA5YmU4YzY4OWExNjUxNWZmOGNlNjIxNw==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- NzIxMDk3OThkNTgwOGQ0MDhhYThlZjNjNDk0MWI1ZmMxZWNiMjliZTE5M2Yw
10
- NjI3Y2EzZDI5MmNiNGFhYzFhMDBkODQyMjA0MDRlNmQ1NWZjNDNlMWJkYjg2
11
- NjgxNjRkYmNjMjM2MzA3Mzg1OTMwMGFlZjQ1Yjk4Yzc1NTZiNTQ=
12
- data.tar.gz: !binary |-
13
- MGUzZmQ1OTgyMDIwOTdjNWMwZmVkN2JjYjIyZWEyYTE1YWY2YWFlMDIwMTg5
14
- NGQwOWE0ZGY4MGIxMDg3YjUyNjZkMTU1ZDgzMDBlMDVkNGFlOWFlMzdiYjdk
15
- NmFkMzZmNmE5MWViODA4OTY1NWUxN2IxZTE5YTE5NGFmYjU2YmM=