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.
Files changed (76) hide show
  1. checksums.yaml +8 -8
  2. metadata +1 -75
  3. data/.ruby-gemset +0 -1
  4. data/.ruby-version +0 -1
  5. data/.simplecov +0 -6
  6. data/.travis.yml +0 -4
  7. data/Gemfile +0 -27
  8. data/Gemfile.lock +0 -142
  9. data/HISTORY +0 -24
  10. data/Rakefile +0 -10
  11. data/VERSION +0 -1
  12. data/features/.nav +0 -29
  13. data/features/client/clear.feature +0 -78
  14. data/features/client/configure.feature +0 -72
  15. data/features/client/model.feature +0 -95
  16. data/features/client/preview_responses.feature +0 -33
  17. data/features/client/prime.feature +0 -32
  18. data/features/client/put.feature +0 -111
  19. data/features/client/readme.md +0 -3
  20. data/features/client/requests.feature +0 -20
  21. data/features/client/running.feature +0 -51
  22. data/features/client/save_and_revert.feature +0 -39
  23. data/features/client/start.feature +0 -46
  24. data/features/client/stop.feature +0 -53
  25. data/features/commandline_interface/help.feature +0 -17
  26. data/features/commandline_interface/readme.md +0 -1
  27. data/features/commandline_interface/start.feature +0 -18
  28. data/features/commandline_interface/stop.feature +0 -42
  29. data/features/logging.feature +0 -6
  30. data/features/prime.feature +0 -35
  31. data/features/readme.md +0 -7
  32. data/features/requests/delete.feature +0 -48
  33. data/features/requests/get.feature +0 -36
  34. data/features/save_and_revert.feature +0 -35
  35. data/features/step_definitions/my_steps.rb +0 -97
  36. data/features/step_definitions/observation_steps.rb +0 -102
  37. data/features/support/command_line.rb +0 -37
  38. data/features/support/env.rb +0 -22
  39. data/features/support/hooks.rb +0 -26
  40. data/features/support/mirage.rb +0 -12
  41. data/features/support/web.rb +0 -19
  42. data/features/templates/delete.feature +0 -45
  43. data/features/templates/get.feature +0 -54
  44. data/features/templates/path_wildcards.feature +0 -10
  45. data/features/templates/preview.feature +0 -18
  46. data/features/templates/put.feature +0 -77
  47. data/features/templates/put_with_substitutions.feature +0 -22
  48. data/features/templates/readme.md +0 -4
  49. data/features/templates/required_content.feature +0 -113
  50. data/features/web_user_interface.feature +0 -44
  51. data/full_build.sh +0 -100
  52. data/mirage.gemspec +0 -174
  53. data/spec/mirage/client/cli_bridge_spec.rb +0 -63
  54. data/spec/mirage/client/client_spec.rb +0 -179
  55. data/spec/mirage/client/helpers/method_builder_spec.rb +0 -48
  56. data/spec/mirage/client/request_spec.rb +0 -44
  57. data/spec/mirage/client/requests_spec.rb +0 -9
  58. data/spec/mirage/client/runner_spec.rb +0 -138
  59. data/spec/mirage/client/template/configuration_spec.rb +0 -32
  60. data/spec/mirage/client/template/model/common_methods_spec.rb +0 -25
  61. data/spec/mirage/client/template/model/instance_methods_spec.rb +0 -169
  62. data/spec/mirage/client/template/model_spec.rb +0 -119
  63. data/spec/mirage/client/template_spec.rb +0 -146
  64. data/spec/mirage/client/templates_spec.rb +0 -197
  65. data/spec/mirage/wait_methods_spec.rb +0 -42
  66. data/spec/resources/binary.file +0 -0
  67. data/spec/server/binary_data_checker_spec.rb +0 -21
  68. data/spec/server/helpers/http_headers_spec.rb +0 -20
  69. data/spec/server/helpers/template_requirements_spec.rb +0 -34
  70. data/spec/server/mock_response_set_spec.rb +0 -57
  71. data/spec/server/mock_response_spec.rb +0 -577
  72. data/spec/server/server_spec.rb +0 -156
  73. data/spec/spec_helper.rb +0 -85
  74. data/tasks/application.rake +0 -7
  75. data/tasks/packaging.rake +0 -28
  76. data/tasks/tests.rake +0 -25
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
- describe 'CommonMethods' do
3
- let!(:model) do
4
- Class.new do
5
- include Template::Model::CommonMethods
6
- end
7
- end
8
-
9
- let!(:instance) do
10
- model.new
11
- end
12
- it 'should provide methods for customising the model' do
13
- instance.methods.should include(:content_type,
14
- :http_method,
15
- :default,
16
- :status,
17
- :delay,
18
- :required_parameters,
19
- :required_body_content,
20
- :required_headers,
21
- :endpoint,
22
- :headers,
23
- :body)
24
- end
25
- end
@@ -1,169 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Template::Model::InstanceMethods do
4
-
5
-
6
- let!(:model) do
7
- Class.new do
8
- include Template::Model::InstanceMethods
9
- end
10
- end
11
-
12
- let!(:instance) do
13
- model.new '', ''
14
- end
15
-
16
-
17
- context 'initialize' do
18
-
19
- it 'requires an endpoint' do
20
- endpoint = 'value'
21
- instance = model.new endpoint
22
- instance.endpoint.should == endpoint
23
- end
24
-
25
- it 'requires an endpoint and value to be provided' do
26
- endpoint, value = 'endpoint', 'value'
27
- instance = model.new endpoint, value
28
- instance.endpoint.should == endpoint
29
- instance.body.should == value
30
- end
31
-
32
- it 'can use configuration for all http related config' do
33
- config = Mirage::Template::Configuration.new
34
- config.content_type 'content_type'
35
- config.http_method 'method'
36
- config.status 'status'
37
- config.default true
38
-
39
- instance = model.new 'endpoint', 'value', config
40
- instance.content_type.should == config.content_type
41
- instance.http_method.should == config.http_method
42
- instance.status.should == config.status
43
- instance.default.should == config.default
44
-
45
- instance = model.new 'endpoint', config
46
- instance.content_type.should == config.content_type
47
- instance.http_method.should == config.http_method
48
- instance.status.should == config.status
49
- instance.default.should == config.default
50
- end
51
- end
52
-
53
- context 'to_json' do
54
- describe 'response body' do
55
- it 'should base64 encode response values' do
56
- value = "value"
57
- response = model.new "endpoint", value
58
- JSON.parse(response.to_json)["response"]["body"].should == Base64.encode64(value)
59
- end
60
- end
61
-
62
- describe 'required request parameters' do
63
-
64
- it 'should contain expected request parameters' do
65
- required_parameters = {:key => "value"}
66
- instance.required_parameters required_parameters
67
- JSON.parse(instance.to_json)["request"]["parameters"].should == convert_keys_to_strings(required_parameters)
68
- end
69
-
70
- it 'should encode parameter requirements that are regexs' do
71
- instance.required_parameters({:key => /regex/})
72
- JSON.parse(instance.to_json)["request"]["parameters"].should == convert_keys_to_strings({:key => "%r{regex}"})
73
- end
74
- end
75
-
76
- describe 'required body content' do
77
- it 'should contain expected body content' do
78
- required_body_content = ["body content"]
79
- instance.required_body_content required_body_content
80
- JSON.parse(instance.to_json)["request"]["body_content"].should == required_body_content
81
- end
82
-
83
- it 'should encode body content requirements that are regexs' do
84
- instance.required_body_content [/regex/]
85
- JSON.parse(instance.to_json)["request"]["body_content"].should == %w(%r{regex})
86
- end
87
- end
88
-
89
- describe 'required headers' do
90
- it 'should contain expected headers' do
91
- required_headers = {:header => "value"}
92
- instance.required_headers required_headers
93
- JSON.parse(instance.to_json)["request"]["headers"].should == convert_keys_to_strings(required_headers)
94
- end
95
-
96
- it 'should encode header requirements that are regexs' do
97
- instance.required_headers({:header => /regex/})
98
- JSON.parse(instance.to_json)["request"]["headers"].should == convert_keys_to_strings(:header => "%r{regex}")
99
- end
100
- end
101
-
102
- describe 'delay' do
103
- it 'should default to 0' do
104
- JSON.parse(instance.to_json)["response"]["delay"].should == 0
105
- end
106
-
107
- it 'should set the delay' do
108
- delay = 5
109
- instance.delay delay
110
- JSON.parse(instance.to_json)["response"]["delay"].should == delay
111
- end
112
- end
113
-
114
- describe 'status code' do
115
- it 'should default to 200' do
116
- JSON.parse(instance.to_json)["response"]["status"].should == 200
117
- end
118
-
119
- it 'should set the status' do
120
- status = 404
121
- instance.status status
122
- JSON.parse(instance.to_json)["response"]["status"].should == status
123
- end
124
- end
125
-
126
- describe 'http method' do
127
- it 'should default to get' do
128
- JSON.parse(instance.to_json)["request"]["http_method"].should == "get"
129
- end
130
-
131
- it 'should set the http method' do
132
- method = :post
133
- instance.http_method(method)
134
- JSON.parse(instance.to_json)["request"]["http_method"].should == "post"
135
- end
136
- end
137
-
138
- describe 'response as default' do
139
- it 'should be false by default' do
140
- JSON.parse(instance.to_json, symbolize_names: true)[:response][:default].should == false
141
- end
142
-
143
- it 'should set the default value' do
144
- default = true
145
- instance.default(default)
146
- JSON.parse(instance.to_json)["response"]["default"].should == default
147
- end
148
- end
149
-
150
- describe 'content type' do
151
- it 'should be text/plain by default' do
152
- JSON.parse(instance.to_json)["response"]["content_type"].should == "text/plain"
153
- end
154
-
155
- it 'should set the default value' do
156
- content_type = "application/json"
157
- instance.content_type content_type
158
- JSON.parse(instance.to_json)["response"]["content_type"].should == content_type
159
- end
160
- end
161
-
162
- it 'should set headers' do
163
- header, value = 'header', 'value'
164
- instance.headers[header] = value
165
- JSON.parse(instance.to_json)["response"]["headers"].should == {header => value}
166
- end
167
- end
168
-
169
- end
@@ -1,119 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Template::Model do
4
- let(:endpoint) { 'endpoint' }
5
- let!(:test_class) do
6
- Class.new do
7
- extend Template::Model
8
-
9
- endpoint 'endpoint'
10
-
11
- def initialize
12
- super
13
- end
14
- end
15
- end
16
- context 'class' do
17
- it 'should extend MethodBuilder and CommonMethods' do
18
- test_class.is_a?(Helpers::MethodBuilder).should == true
19
- test_class.is_a?(Template::Model::CommonMethods).should == true
20
- end
21
-
22
- it 'should include Instance methods' do
23
- test_class.is_a?(Template::Model::CommonMethods).should == true
24
- end
25
-
26
- context 'inherited constructor' do
27
- it 'should set the endpoint of the class' do
28
- test_class.new.endpoint.should == 'endpoint'
29
- end
30
-
31
- it 'calls to super should not fail if a constructor has been defined that takes args' do
32
- test_class.class_eval do
33
- def initialize arg
34
- super
35
- end
36
- end
37
- test_class.new('arg').endpoint.should == endpoint
38
-
39
- end
40
- end
41
-
42
- end
43
-
44
- context 'instances' do
45
- it 'should have instance methods included' do
46
- test_class.ancestors.should include(Template::Model::InstanceMethods)
47
- end
48
-
49
-
50
- it 'should include httparty' do
51
- test_class.ancestors.should include(HTTParty)
52
- end
53
-
54
- describe 'defaults' do
55
-
56
- it 'should be default the endpoint' do
57
- endpoint = 'endpoint'
58
- test_class.endpoint endpoint
59
- test_class.new.endpoint.should == endpoint
60
- end
61
-
62
- it 'should be default the status' do
63
- status = 404
64
- test_class.status status
65
- test_class.new.status.should == status
66
- end
67
-
68
- it 'should be default the content-type' do
69
- content_type = 'application/json'
70
- test_class.content_type content_type
71
- test_class.new.content_type.should == content_type
72
- end
73
-
74
- it 'should be default the http_method' do
75
- method = :post
76
- test_class.http_method method
77
- test_class.new.http_method.should == method
78
- end
79
-
80
- it 'should be default the default status' do
81
- default = true
82
- test_class.default default
83
- test_class.new.default.should == default
84
- end
85
-
86
- it 'should be default the required parameters' do
87
- required_parameters = {name: 'joe'}
88
- test_class.required_parameters required_parameters
89
- test_class.new.required_parameters.should == required_parameters
90
- end
91
-
92
- it 'should be default the required headers' do
93
- headers = {name: 'joe'}
94
- test_class.required_headers headers
95
- test_class.new.required_headers.should == headers
96
- end
97
-
98
- it 'should be default the required body content' do
99
- content = ['content']
100
- test_class.required_body_content content
101
- test_class.new.required_body_content.should == content
102
- end
103
-
104
- it 'should be default the headers' do
105
- headers = {name: 'joe'}
106
- test_class.headers headers
107
- test_class.new.headers.should == headers
108
- end
109
-
110
- it 'should be default the delay' do
111
- delay = 4
112
- test_class.delay delay
113
- test_class.new.delay.should == delay
114
- end
115
- end
116
-
117
- end
118
-
119
- end
@@ -1,146 +0,0 @@
1
- require 'spec_helper'
2
- require 'mirage/client'
3
-
4
-
5
- describe Mirage::Template do
6
-
7
- describe 'get' do
8
- it 'should load a template given its id' do
9
- endpoint = "endpoint"
10
- id = 1
11
- requests_url = 'request_url'
12
- body = "Hello"
13
- default = true
14
- delay = 1.2
15
- content_type = "application/json"
16
- status = 201
17
- headers = {'header' => 'value'}
18
-
19
-
20
- required_parameters = {"name" => 'joe'}
21
- required_body_content = %{content}
22
- required_headers = {"header" => 'value'}
23
- http_method = "get"
24
-
25
- template_json = {
26
- endpoint: endpoint,
27
- id: id,
28
- requests_url: requests_url,
29
- response:{
30
- default: default,
31
- body: Base64.encode64(body),
32
- delay: delay,
33
- content_type: content_type,
34
- status: status,
35
- headers: headers
36
- },
37
- request: {
38
- parameters: required_parameters,
39
- body_content: required_body_content,
40
- headers: required_headers,
41
- http_method: http_method
42
- }
43
- }
44
- template_json.should_receive(:code).and_return 200
45
-
46
- template_url = "url"
47
- Template.should_receive(:backedup_get).with(template_url, :format => :json).and_return(template_json)
48
-
49
- template = Template.get(template_url)
50
- template.body.should == body
51
- template.endpoint.should == endpoint
52
- template.id.should == id
53
-
54
- template.default.should == default
55
- template.delay.should == delay
56
- template.content_type.should == content_type
57
- template.status.should == status
58
- template.headers.should == headers
59
-
60
- template.required_parameters.should == required_parameters
61
- template.required_body_content.should == required_body_content
62
- template.required_headers.should == required_headers
63
- template.http_method.should == http_method
64
- template.url.should == template_url
65
- template.requests_url.should == requests_url
66
- end
67
-
68
- it 'should raise an error if the template is not found' do
69
- template_url = 'url'
70
- response = double(code: 404)
71
- Template.should_receive(:backedup_get).with(template_url, :format => :json).and_return response
72
- expect{Template.get(template_url)}.to raise_error Mirage::TemplateNotFound
73
- end
74
- end
75
-
76
- describe 'initialize' do
77
- it 'throws and exception if an endpoint is not supplied as the first parameter' do
78
- expect{Template.new}.to raise_error(ArgumentError)
79
- end
80
-
81
- it 'throws and exception if first argument is not a string' do
82
- expect{Template.new(:endpoint)}.to raise_error(ArgumentError)
83
- end
84
- end
85
-
86
-
87
- describe 'creating' do
88
- json = "reponse json"
89
- endpoint = "greeting"
90
-
91
- it 'should create a template on mirage' do
92
- template = Template.new(endpoint,json)
93
-
94
- template.should_receive(:to_json).and_return(json)
95
- Template.should_receive(:put).with(endpoint, :body => json, :headers => {'content-type' => 'application/json'}).and_return(convert_keys_to_strings({:id => 1}))
96
- template.create
97
- template.id.should == 1
98
- end
99
-
100
- it 'should have default values set' do
101
- template = Template.new(endpoint,json)
102
- template.http_method.should == :get
103
- template.status.should == 200
104
- template.content_type.should == "text/plain"
105
- template.default.should == false
106
- template.delay.should == 0
107
- end
108
- end
109
-
110
-
111
- describe 'deleting' do
112
-
113
- it 'should clear a response' do
114
- id = 1
115
- template_url = "base_url/templates/#{id}"
116
- request_url = "base_url/requests/#{id}"
117
-
118
- template = Template.new("", "")
119
- template.url template_url
120
- template.requests_url request_url
121
-
122
-
123
- template.stub(:id).and_return(id)
124
-
125
- Template.should_receive(:delete).with(template_url)
126
-
127
- Mirage::Request.should_receive(:delete).with(request_url)
128
- template.delete
129
- end
130
-
131
- end
132
-
133
- describe 'method missing' do
134
- it 'should delagate to the caller if it is set' do
135
- caller = Object.new
136
- caller.should_receive(:some_method)
137
- template = Template.new('endpoint')
138
- template.caller_binding = caller
139
- template.some_method
140
- end
141
-
142
- it 'should throw a standard method missing error if a caller binding is not set' do
143
- expect{Template.new('endpoint').some_method}.to raise_error(NameError)
144
- end
145
- end
146
- end