mirage 3.0.0.alpha.12 → 3.0.0.alpha.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -38,6 +38,10 @@ Templates are now scored to find the most appropriate template when finding a ma
38
38
  if there was a more appropriate template.
39
39
 
40
40
  Litteral matchers are worth more in the scoring process than regex based ones for example.
41
+ ##### 6. The url has changed
42
+ Mirage is now accessible via: http://localhost:7001. I.e. 'mirage' has been removed from all resources
43
+
44
+ e.g. responses are now under http://localhost:7001/responses
41
45
  #### What's new in the Client:
42
46
  ##### 1. Template Models
43
47
  Perhaps the biggest addition to the client. Simply mixin Mirage::Template::Model in to a class, give it a method called body and there you have it... a class that can be used to put objects straight on to Mirage.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0.alpha.12
1
+ 3.0.0.alpha.13
@@ -0,0 +1,18 @@
1
+ Feature: Retrieving
2
+ A Templates body can be previewed
3
+
4
+
5
+ Scenario: Preview template body
6
+ Given the following template template:
7
+ """
8
+ {
9
+ "response":{
10
+ "body":"SGVsbG8="
11
+ },
12
+ "request":{
13
+ }
14
+ }
15
+ """
16
+ And the template is sent using PUT to '/templates/greeting'
17
+ When GET is sent to '/templates/1/body'
18
+ Then 'Hello' should be returned
data/mirage.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mirage"
8
- s.version = "3.0.0.alpha.12"
8
+ s.version = "3.0.0.alpha.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leon Davis"]
@@ -50,6 +50,7 @@ Gem::Specification.new do |s|
50
50
  "features/support/hooks.rb",
51
51
  "features/support/mirage.rb",
52
52
  "features/support/web.rb",
53
+ "features/templates/body.feature",
53
54
  "features/templates/delete.feature",
54
55
  "features/templates/get.feature",
55
56
  "features/templates/put.feature",
data/server/server.rb CHANGED
@@ -38,6 +38,12 @@ module Mirage
38
38
  end
39
39
  end
40
40
 
41
+ get '/templates/:id/body' do
42
+ response = MockResponse.find_by_id(response_id)
43
+ content_type(response.response_spec['content_type'])
44
+ response.value '', {}, ''
45
+ end
46
+
41
47
  delete '/templates/:id' do
42
48
  MockResponse.delete(response_id)
43
49
  REQUESTS.delete(response_id)
@@ -32,6 +32,20 @@ describe "Mirage Server" do
32
32
 
33
33
  end
34
34
 
35
+ context '/templates' do
36
+ describe ':id/body' do
37
+ it 'should give the value' do
38
+ response_body = 'hello'
39
+ content_type = 'application/javascript'
40
+ response_id = JSON.parse(put('/templates/greeting', {:response => {:body => Base64.encode64(response_body), :content_type => content_type}}.to_json).body)['id']
41
+ response = get("/templates/#{response_id}/body")
42
+ response.body.should == response_body
43
+ response.content_type.should include(content_type)
44
+ end
45
+ end
46
+ end
47
+
48
+
35
49
 
36
50
  describe 'matching templates' do
37
51
  before :each do
data/test.rb CHANGED
@@ -1,3 +1,3 @@
1
- require '/home/team/Projects/mirage/lib/mirage/client'
1
+ require 'mirage/client'
2
2
 
3
- puts "{\"id\":1,\"endpoint\":\"greeting\",\"requests_url\":\"http://localhost:7001/requests/1\",\"response\":{\"default\":false,\"body\":\"Hello\",\"delay\":0,\"content_type\":\"text/plain\",\"status\":200},\"request\":{\"parameters\":{},\"body_content\":[],\"http_method\":\"get\",\"headers\":{}}}"
3
+ Mirage.start.put('greeting', 'hello')
data/views/response.haml CHANGED
@@ -3,11 +3,16 @@
3
3
  %div
4
4
  %label{:style => 'font-weight: bold'}
5
5
  endpoint:
6
- #{response.name}
6
+ %a{href: "/templates/#{response.response_id}/body"} #{response.name}
7
7
  %br
8
8
  %label{:style => 'font-weight: bold'}
9
9
  status:
10
10
  #{response.response_spec.status}
11
+ %br
12
+ %label{:style => 'font-weight: bold'}
13
+ Content-Type:
14
+ #{response.response_spec[:content_type]}
15
+
11
16
  %br
12
17
  %label{:style => 'font-weight: bold'}
13
18
  delay:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mirage
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha.12
4
+ version: 3.0.0.alpha.13
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -279,6 +279,7 @@ files:
279
279
  - features/support/hooks.rb
280
280
  - features/support/mirage.rb
281
281
  - features/support/web.rb
282
+ - features/templates/body.feature
282
283
  - features/templates/delete.feature
283
284
  - features/templates/get.feature
284
285
  - features/templates/put.feature
@@ -353,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
353
354
  version: '0'
354
355
  segments:
355
356
  - 0
356
- hash: 158416820586937306
357
+ hash: -834089398035739627
357
358
  required_rubygems_version: !ruby/object:Gem::Requirement
358
359
  none: false
359
360
  requirements: