mirage 3.0.13 → 3.0.14

Sign up to get free protection for your applications and to get access to all the features.
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,179 +0,0 @@
1
- require 'spec_helper'
2
- require 'mirage/client'
3
-
4
- describe Mirage::Client do
5
-
6
-
7
- before :each do
8
- @response = double('response').as_null_object
9
- end
10
-
11
- describe 'configuration' do
12
- it 'is configured to connect to local host port 7001 by default' do
13
- Client.new.url.should == "http://localhost:7001"
14
- end
15
-
16
- it 'can be configured with a url pointing to Mirage' do
17
- mirage_url = "http://url.for.mirage"
18
- Client.new(mirage_url).url.should == mirage_url
19
-
20
- Client.new(:url => mirage_url).url.should == mirage_url
21
- end
22
-
23
- it 'can be configured with a port refering to which port Mirage is running on on localhost' do
24
- port = 9001
25
- Client.new(:port => port).url.should == "http://localhost:#{port}"
26
- end
27
-
28
- it 'raises an error if neither a port or url specified in the argument' do
29
- expect { Client.new({}) }.to raise_error()
30
- expect { Client.new("rubbish") }.to raise_error()
31
- end
32
-
33
-
34
- describe 'defaults' do
35
- it 'can be configured with template defaults on initialize' do
36
- templates, config = Templates.new("url"), proc {}
37
- Templates.should_receive(:new).and_return(templates)
38
- templates.should_receive(:default_config) do |&block|
39
- block.should == config
40
- end
41
- Client.new &config
42
- end
43
-
44
- it 'can be configured with template defaults on after initalize' do
45
- templates, config = Templates.new("url"), proc {}
46
- Templates.should_receive(:new).and_return(templates)
47
- templates.should_receive(:default_config) do |&block|
48
- block.should == config
49
- end
50
- Client.new.configure &config
51
- end
52
-
53
- it 'can be reset' do
54
- client = Client.new do
55
- http_method :post
56
- end
57
-
58
- client.reset
59
- client.templates.default_config.should == Template::Configuration.new
60
- end
61
-
62
- end
63
- end
64
-
65
- it 'should clear mirage' do
66
- templates_mock = double('templates')
67
- Templates.should_receive(:new).and_return(templates_mock)
68
- templates_mock.should_receive(:delete_all)
69
- Client.new.clear
70
- end
71
-
72
-
73
-
74
-
75
- it 'should prime mirage' do
76
- Client.should_receive(:put) do |url|
77
- url.should == "http://localhost:7001/defaults"
78
- end
79
- Client.new.prime
80
- end
81
-
82
- describe 'templates' do
83
- it 'should give access to templates' do
84
- mirage = Client.new
85
- mirage.templates.instance_of?(Templates).should == true
86
- end
87
-
88
- it 'The templates instance should be the one created on construction otherwise the defaults passed in will get lost' do
89
- mirage = Client.new
90
- mirage.templates.should == mirage.templates
91
- end
92
-
93
- it 'should find a template' do
94
- id = 1
95
- mirage = Client.new
96
- mock_template = double('template')
97
- Template.should_receive(:get).with("#{mirage.url}/templates/#{id}").and_return(mock_template)
98
- mirage.templates(1).should == mock_template
99
- end
100
-
101
-
102
- describe 'put' do
103
- it "should put a response on mirage by passing args on to template's put method " do
104
- endpoint, value, block = 'greeting', 'hello', Proc.new{}
105
-
106
- templates_mock = double('templates')
107
- Templates.should_receive(:new).and_return(templates_mock)
108
-
109
- templates_mock.should_receive(:put).with(endpoint, value, &block)
110
-
111
- mirage = Client.new
112
- mirage.put endpoint, value, &block
113
- end
114
- end
115
- end
116
-
117
- describe 'requests' do
118
- it 'should give access to requests' do
119
- mirage = Client.new
120
- mirage.requests.instance_of?(Requests).should == true
121
- end
122
-
123
- it 'should find a request' do
124
- id = 1
125
- mirage = Client.new
126
- Request.should_receive(:get).with("#{mirage.url}/requests/#{id}")
127
- mirage.requests(id)
128
- end
129
- end
130
-
131
- describe 'save' do
132
- it 'should save the current template setup of mirage' do
133
- mirage = Client.new
134
- Client.should_receive(:put).with("#{mirage.url}/backup", :body => "")
135
- mirage.save
136
- end
137
- end
138
-
139
- describe 'revert' do
140
- it 'should revert the current template set' do
141
- mirage = Client.new
142
- Client.should_receive(:put).with(mirage.url, :body => "")
143
- mirage.revert
144
- end
145
- end
146
-
147
- describe 'running?' do
148
- it 'should check if mirage is runing' do
149
- url = 'http://some_url'
150
-
151
- Mirage.should_receive(:running?).with url
152
- Client.new(url).running?
153
- end
154
- end
155
-
156
-
157
- describe 'interface to mirage' do
158
-
159
- after :each do
160
- Mirage.stop
161
- end
162
-
163
- it 'should set a response' do
164
- client = Mirage.start
165
- response = client.templates.put("greeting", "hello")
166
- response.id.should == 1
167
- end
168
-
169
- it 'should find mirage running' do
170
- Mirage.start
171
- Mirage.running?.should == true
172
- end
173
-
174
- it 'should not find mirage running' do
175
- Mirage.running?.should == false
176
- end
177
-
178
- end
179
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Helpers::MethodBuilder do
4
-
5
- describe 'a builder method' do
6
- let :model do
7
- model_class = Class.new do
8
- extend Helpers::MethodBuilder
9
-
10
- builder_method :name
11
- end
12
- model_class.new
13
- end
14
-
15
- context 'parameter is nil' do
16
- it 'should set the value to nil' do
17
- model.name(:joe)
18
- model.name(nil)
19
- expect(model.name).to be_nil
20
- end
21
- end
22
-
23
- it 'should set a value' do
24
- model.name(:joe)
25
- model.name.should == :joe
26
- end
27
-
28
- it 'should chain' do
29
- model.name(:joe).should == model
30
- end
31
-
32
- it 'should work with booleans' do
33
- model.name(false)
34
- model.name.should == false
35
- end
36
- end
37
-
38
-
39
- it 'should let you define more than one builder method at a time' do
40
- model_class = Class.new do
41
- extend Helpers::MethodBuilder
42
- builder_methods :foo, :bar
43
- end
44
- model = model_class.new
45
- model.respond_to?(:foo).should be_true
46
- model.respond_to?(:bar).should be_true
47
- end
48
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Request do
4
- let(:id) { "url_for_request_entity" }
5
- let(:request_url) { "requested_url" }
6
- let(:trigger_url) { "trigger url" }
7
-
8
- let(:body) { "body" }
9
- let(:parameters) { {"name" => "joe"} }
10
- let(:headers) { {"header" => "value"} }
11
-
12
- let(:request_json) do
13
- {body: body,
14
- headers: headers,
15
- parameters: parameters,
16
- request_url: trigger_url,
17
- id: id}
18
- end
19
-
20
- it 'delete a request' do
21
- id = "url"
22
- Request.should_receive(:delete).with(id)
23
- request = Request.new
24
- request.id = id
25
- request.delete
26
- end
27
-
28
- it 'should load request data' do
29
- Request.should_receive(:backedup_get).with(request_url, format: :json).and_return(request_json)
30
-
31
- request = Request.get(request_url)
32
- request.headers.should == headers
33
- request.body.should == body
34
- request.request_url.should == trigger_url
35
- request.parameters.should == parameters
36
- request.id.should == id
37
- end
38
-
39
- it 'raises error when request is not found' do
40
- Request.should_receive(:backedup_get).and_raise(StandardError)
41
-
42
- expect { Request.get(request_url) }.to raise_error(Request::NotReceivedException)
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Requests do
4
- it 'should delete all request data' do
5
- base_url = "base_url"
6
- Requests.should_receive(:delete).with("#{base_url}/requests")
7
- Requests.new(base_url).delete_all
8
- end
9
- end
@@ -1,138 +0,0 @@
1
- require 'spec_helper'
2
- require 'mirage/client'
3
-
4
-
5
- describe Mirage do
6
-
7
- describe 'starting' do
8
- before(:each) do
9
- @runner = double
10
- Runner.should_receive(:new).and_return(@runner)
11
- end
12
-
13
- it 'should start Mirage on port 7001 by default' do
14
- @runner.should_receive(:invoke).with(:start, [], {:port => 7001})
15
- client = Mirage.start
16
- client.should == Mirage::Client.new
17
- end
18
-
19
- it 'should start mirage on the given port' do
20
- options = {:port => 9001}
21
- @runner.should_receive(:invoke).with(:start, [], options)
22
- Mirage.start options
23
- end
24
- end
25
-
26
- describe 'stopping' do
27
- before(:each) do
28
- @runner = double
29
- Runner.stub(:new).and_return(@runner)
30
- end
31
-
32
- it 'should supply single port argument in an array to the runner' do
33
- port = 7001
34
- @runner.should_receive(:invoke).with(:stop, [], :port => [port])
35
- @runner.should_receive(:invoke).with(:stop, [], :port => [:all])
36
- Mirage.stop(:port => port)
37
- Mirage.stop(:all)
38
- end
39
-
40
- it 'should stop multiple instances of Mirage' do
41
- ports = 7001, 7002
42
- @runner.should_receive(:invoke).with(:stop, [], :port => ports)
43
- Mirage.stop(:port => ports)
44
- end
45
-
46
- end
47
-
48
- describe Mirage::Runner do
49
- it 'should stop the running instance of Mirage' do
50
- options = {:port => []}
51
- runner = Mirage::Runner.new
52
- runner.options = options
53
-
54
- runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901"})
55
-
56
-
57
- runner.should_receive(:kill).with("18901") do
58
- RSpec.reset
59
- runner.stub(:mirage_process_ids).with([]).and_return({})
60
- end
61
-
62
- Mirage::Runner.should_receive(:new).and_return(runner)
63
- runner.invoke(:stop, [], options)
64
- end
65
-
66
- it 'should not stop any instances when more than one is running' do
67
- options = {:port => []}
68
- runner = Mirage::Runner.new
69
- runner.options = options
70
-
71
- runner.stub(:mirage_process_ids).with([]).and_return({"7001" => "18901", "7002" => "18902", "7003" => "18903"})
72
- runner.should_not_receive(:kill)
73
- Mirage::Runner.should_receive(:new).and_return(runner)
74
-
75
- expect{ runner.invoke(:stop, [], options) }.to raise_error(Mirage::ClientError)
76
- end
77
-
78
-
79
- it 'should stop the instance running on the given port' do
80
- options = {:port => [7001]}
81
- runner = Mirage::Runner.new
82
- runner.options = options
83
-
84
- runner.should_receive(:mirage_process_ids).with([7001]).and_return({"7001" => "18901"})
85
- runner.should_receive(:kill).with("18901") do
86
- RSpec.reset
87
- runner.stub(:mirage_process_ids).with([7001]).and_return({})
88
- end
89
-
90
- Mirage::Runner.should_receive(:new).and_return(runner)
91
- runner.invoke(:stop, [], options)
92
- end
93
-
94
- it 'should stop the instance running on the given ports' do
95
- options = {:port => [7001, 7002]}
96
- runner = Mirage::Runner.new
97
- runner.options = options
98
-
99
- runner.should_receive(:mirage_process_ids).with([7001, 7002]).and_return({"7001" => "18901", "7002" => "18902"})
100
- runner.should_receive(:kill).with("18901")
101
- runner.should_receive(:kill).with("18902") do
102
- RSpec.reset
103
- runner.stub(:mirage_process_ids).with([7001, 7002]).and_return({})
104
- end
105
-
106
- Mirage::Runner.should_receive(:new).and_return(runner)
107
- runner.invoke(:stop, [], options)
108
- end
109
-
110
- it 'should stop all running instances' do
111
- options = {:port => [:all]}
112
- runner = Mirage::Runner.new
113
- runner.options = options
114
-
115
- runner.should_receive(:mirage_process_ids).with([:all]).and_return({"7001" => "18901", "7002" => "18902"})
116
- runner.should_receive(:kill).with("18901")
117
- runner.should_receive(:kill).with("18902") do
118
- RSpec.reset
119
- runner.stub(:mirage_process_ids).with([:all]).and_return({})
120
- end
121
-
122
- Mirage::Runner.should_receive(:new).and_return(runner)
123
- runner.invoke(:stop, [], options)
124
-
125
- end
126
-
127
- it 'should not error when asked to stop Mirage on a port that it is not running on' do
128
- options = {:port => [7001]}
129
- runner = Mirage::Runner.new
130
- runner.options = options
131
- runner.stub(:mirage_process_ids).with([7001]).and_return({})
132
-
133
- Mirage::Runner.should_receive(:new).and_return(runner)
134
- expect { runner.invoke(:stop, [], options) }.not_to raise_error
135
- end
136
-
137
- end
138
- end
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
- require 'mirage/client'
3
-
4
-
5
-
6
- describe Template::Configuration do
7
-
8
- it 'should have defaults' do
9
- configuration = Template::Configuration.new
10
- assert_defaults configuration
11
- end
12
-
13
- it 'should be reset' do
14
- configuration = Template::Configuration.new
15
- configuration.http_method :post
16
- configuration.status 202
17
- configuration.delay 3
18
- configuration.default true
19
- configuration.content_type "text/xml"
20
-
21
- configuration.reset
22
- assert_defaults configuration
23
- end
24
-
25
- def assert_defaults configuration
26
- configuration.http_method.should == :get
27
- configuration.status.should == 200
28
- configuration.delay.should == 0
29
- configuration.default.should == false
30
- configuration.content_type.should == "text/plain"
31
- end
32
- end