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,46 +0,0 @@
1
- @command_line
2
- Feature: Starting Mirage
3
-
4
- The client can be used to start Mirage.
5
-
6
- Both the port and default templates directory can be specified
7
-
8
- On starting Mirage a client is returned.
9
-
10
-
11
- Background:
12
- Given the following require statements are needed:
13
- """
14
- require 'rubygems'
15
- require 'mirage/client'
16
- """
17
-
18
- Scenario: Starting Mirage on the default port
19
- When I run
20
- """
21
- Mirage.start
22
- """
23
- Then mirage should be running on 'http://localhost:7001'
24
-
25
-
26
- Scenario: Starting Mirage on a custom port
27
- When I run
28
- """
29
- Mirage.start :port => 9001
30
- """
31
- Then mirage should be running on 'http://localhost:9001'
32
-
33
-
34
- Scenario: Specifying a custom templates directory.
35
- And the file './custom_responses_location/default_greetings.rb' contains:
36
- """
37
- prime do |mirage|
38
- mirage.templates.put('greeting', 'hello')
39
- end
40
- """
41
- When I run
42
- """
43
- Mirage.start :defaults => './custom_responses_location'
44
- """
45
- And GET is sent to '/responses/greeting'
46
- Then 'hello' should be returned
@@ -1,53 +0,0 @@
1
- @command_line
2
- Feature: Stopping Mirage
3
-
4
- The client API can be used to stop instances of Mirage running on localhost.
5
-
6
- Background:
7
- Given the following require statements are needed:
8
- """
9
- require 'rubygems'
10
- require 'mirage/client'
11
- """
12
-
13
- Scenario: Stopping Mirage
14
- Given Mirage is running
15
- When I run
16
- """
17
- Mirage.stop
18
- """
19
- Then mirage should not be running on 'http://localhost:7001'
20
-
21
-
22
- Scenario: Stopping Mirage on custom port
23
- And I run 'mirage start -p 9001'
24
- When I run
25
- """
26
- Mirage.stop :port => 9001
27
- """
28
- Then mirage should not be running on 'http://localhost:9001'
29
-
30
- Scenario: Stopping multiple instances of Mirage
31
- Given I run 'mirage start -p 7001'
32
- And I run 'mirage start -p 9001'
33
- And I run 'mirage start -p 10001'
34
- When I run
35
- """
36
- Mirage.stop :port => [9001,10001]
37
- """
38
- Then mirage should be running on 'http://localhost:7001'
39
- Then mirage should not be running on 'http://localhost:9001'
40
- Then mirage should not be running on 'http://localhost:10001'
41
-
42
-
43
- Scenario: Stopping all instances of Mirage
44
- Given I run 'mirage start -p 7001'
45
- And I run 'mirage start -p 9001'
46
- And I run 'mirage start -p 10001'
47
- When I run
48
- """
49
- Mirage.stop :all
50
- """
51
- Then mirage should not be running on 'http://localhost:7001'
52
- Then mirage should not be running on 'http://localhost:9001'
53
- Then mirage should not be running on 'http://localhost:10001'
@@ -1,17 +0,0 @@
1
- @command_line
2
- Feature: Help
3
- Mirage is started from the command line. Mirage logs to mirage.log at the path where Mirage is started from.
4
-
5
-
6
- Background: Mirage usage
7
- Given usage information:
8
- """
9
- mirage help [COMMAND] # Describe available commands or one specific command
10
- mirage start # Starts mirage
11
- mirage stop # Stops mirage
12
- """
13
-
14
-
15
- Scenario: Starting with help option
16
- Given I run 'mirage help'
17
- Then the usage information should be displayed
@@ -1 +0,0 @@
1
- Mirage has a fully functional commandline interface check it out!
@@ -1,18 +0,0 @@
1
- @command_line
2
- Feature: Starting Mirage
3
- Mirage is started from the command line. more than instance of Mirage can be started on different ports at the same time.
4
-
5
- By default mirage runs on port 7001.
6
-
7
-
8
- Scenario: Starting mirage
9
- Given Mirage is not running
10
- When I run 'mirage start'
11
- Then mirage should be running on 'http://localhost:7001'
12
- And 'mirage.log' should exist
13
-
14
-
15
- Scenario: Starting Mirage on a custom port
16
- Given Mirage is not running
17
- When I run 'mirage start -p 9001'
18
- Then mirage should be running on 'http://localhost:9001'
@@ -1,42 +0,0 @@
1
- @command_line
2
- Feature: Stopping Mirage
3
- Mirage can be stopped from the commandline
4
- If more than one instance of Mirage is running, you will be asked to supply the ports which represent the running instances
5
- of mirage that you wish to stop.
6
-
7
- Scenario: Stopping a single instance of Mirage
8
- Given I run 'mirage start -p 7001'
9
- When I run 'mirage stop'
10
- Then mirage should not be running on 'http://localhost:7001'
11
-
12
- Scenario: Stopping an instance running on a given port
13
- Given I run 'mirage start -p 7001'
14
- And I run 'mirage start -p 9001'
15
- When I run 'mirage stop -p 7001'
16
- Then mirage should be running on 'http://localhost:9001'
17
- Then mirage should not be running on 'http://localhost:7001'
18
-
19
- Scenario: Stopping more than one instance
20
- Given I run 'mirage start -p 7001'
21
- And I run 'mirage start -p 9001'
22
- And I run 'mirage start -p 10001'
23
- When I run 'mirage stop -p 7001 9001'
24
- Then mirage should be running on 'http://localhost:10001'
25
- Then mirage should not be running on 'http://localhost:7001'
26
- Then mirage should not be running on 'http://localhost:9001'
27
-
28
- Scenario: Stopping all running instances
29
- Given I run 'mirage start -p 7001'
30
- And I run 'mirage start -p 9001'
31
- When I run 'mirage stop -p all'
32
- Then mirage should not be running on 'http://localhost:10001'
33
- Then mirage should not be running on 'http://localhost:7001'
34
- Then mirage should not be running on 'http://localhost:9001'
35
-
36
- Scenario: Calling stop when there is more than one instance running
37
- Given I run 'mirage start -p 7001'
38
- Given I run 'mirage start -p 9001'
39
- When I run 'mirage stop'
40
- Then I should see 'Mirage is running on ports 7001, 9001. Please run mirage stop -p [PORT(s)] instead' on the command line
41
- And mirage should be running on 'http://localhost:7001'
42
- And mirage should be running on 'http://localhost:9001'
@@ -1,6 +0,0 @@
1
- Feature: Output from Mirage is stored in mirage.log.
2
- This file is located at the root from which mirage is started.
3
-
4
- Scenario: Mirage logs request
5
- Given GET is sent to '/templates/greeting'
6
- Then mirage.log should contain '/templates/greeting'
@@ -1,35 +0,0 @@
1
- #TODO - rename responses directory to templates
2
- @command_line
3
- Feature: Preloading Templates
4
- Mirage can be primed with a set of templates.
5
- By default, Mirage loads any .rb files found in ./mirage on startup. Mirage can also be made to load responses from a directory
6
- of your choosing by using the -d/--defaults option
7
-
8
- Responses can be added to the responses directory and used to prime Mirage after Mirage has been started.
9
-
10
- Priming causes any modifications to Mirage's current state to be lost.
11
-
12
-
13
- Scenario: Using the default responses directory
14
- Given the file 'mirage/default_greetings.rb' contains:
15
- """
16
- prime do |mirage|
17
- mirage.templates.put('greeting', 'hello')
18
- end
19
- """
20
- And I run 'mirage start'
21
- When GET is sent to '/responses/greeting'
22
- Then 'hello' should be returned
23
-
24
-
25
- Scenario: Using a custom responses directory
26
- Given Mirage is not running
27
- And the file '/tmp/mirage/default_greetings.rb' contains:
28
- """
29
- prime do |mirage|
30
- mirage.templates.put('greeting', 'hello')
31
- end
32
- """
33
- And I run 'mirage start --defaults /tmp/mirage'
34
- And GET is sent to '/responses/greeting'
35
- Then 'hello' should be returned
@@ -1,7 +0,0 @@
1
- Mirage in an open source project that can be used to mock HTTP services. It facilitates application development in environments where external systems aren't easily accessed or can't be made to behave in a repeatable way.
2
-
3
- At its core, Mirage is a web application with a restful interface that can be configured with responses. The descriptors for these response are called [Templates](/lashd/mirage/docs/templates).
4
-
5
- If you're using Ruby then Mirage has a [client](/lashd/mirage/docs/client) to get you going straight away.
6
-
7
- If you're using another language, then the interface to Mirage is simple and it would be great to see clients emerging other languages too. If you need any help please ask! :)
@@ -1,48 +0,0 @@
1
- Feature: Deleting tracked requests
2
- Tracked request data can be deleted
3
-
4
- Background: The MockServer has already got a response for greeting and leaving on it.
5
- Given the following template template:
6
- """
7
- {
8
- "response":{
9
- "body":"Hello"
10
- }
11
- }
12
- """
13
- And 'response.body' is base64 encoded
14
- And the template is sent using PUT to '/templates/greeting'
15
-
16
- Given the following template template:
17
- """
18
- {
19
- "response":{
20
- "body":"Goodbye"
21
- }
22
- }
23
- """
24
- And 'response.body' is base64 encoded
25
- And the template is sent using PUT to '/templates/leaving'
26
-
27
-
28
- And GET is sent to '/responses/greeting'
29
- And GET is sent to '/responses/leaving'
30
-
31
-
32
- Scenario: Deleting all requests
33
- And DELETE is sent to '/requests'
34
-
35
- When GET is sent to '/requests/1'
36
- Then a 404 should be returned
37
- When GET is sent to '/requests/2'
38
- Then a 404 should be returned
39
-
40
-
41
-
42
- Scenario: Deleting a stored request for a particular response
43
- And DELETE is sent to '/requests/1'
44
-
45
- When GET is sent to '/requests/1'
46
- Then a 404 should be returned
47
- When GET is sent to '/requests/2'
48
- Then a 200 should be returned
@@ -1,36 +0,0 @@
1
- Feature: Checking tracked requests
2
- After a response has been served from Mirage, the request that triggered it can be retrieved. This is useful
3
- for testing that the correct information was sent by your application code.
4
-
5
- Use a template's ID to retrieve the last request that was last received.
6
-
7
-
8
- Background: A template has already be put on Mirage
9
- Given the following template template:
10
- """
11
- {
12
- "request" : {
13
- "http_method" : "post"
14
- },
15
- "response":{
16
- "body":"Hello"
17
- }
18
- }
19
- """
20
- And 'response.body' is base64 encoded
21
- And the template is sent using PUT to '/templates/greeting'
22
-
23
-
24
- Scenario: Getting request data when the data was in the body.
25
- Given I send POST to '/responses/greeting' with request entity
26
- """
27
- Hello Mirage
28
- """
29
- When GET is sent to '/requests/1'
30
- Then request data should have been retrieved
31
-
32
-
33
- Scenario: Getting request data for a template that has not yet served a response.
34
- Given GET is sent to '/requests/1'
35
- Then a 404 should be returned
36
-
@@ -1,35 +0,0 @@
1
- Feature: Having set up the Mirage with a number of defaults, your tests may continue to change its state.
2
- Clearing and resetting all of your responses, potentially hundreds of times, can be time expensive.
3
-
4
- Mirage provides the ability to save its current state and to revert back to that state.
5
-
6
- Background: The MockServer has been setup with some default responses
7
- Given the following template template:
8
- """
9
- {
10
- "response":{
11
- "body":"The default greeting"
12
- }
13
- }
14
- """
15
- And 'response.body' is base64 encoded
16
- And the template is sent using PUT to '/templates/greeting'
17
-
18
-
19
- Scenario: Saving Mirage and reverting it
20
- Given PUT is sent to '/backup'
21
- And the following template template:
22
- """
23
- {
24
- "response":{
25
- "body":"Changed"
26
- }
27
- }
28
- """
29
- And 'response.body' is base64 encoded
30
- And the template is sent using PUT to '/templates/greeting'
31
-
32
- When PUT is sent to '/'
33
- And GET is sent to '/responses/greeting'
34
-
35
- Then 'The default greeting' should be returned
@@ -1,97 +0,0 @@
1
- Given /^I run '(.*)'$/ do |command|
2
- if ENV['mode'] == 'regression' && ChildProcess.windows?
3
- command.gsub!(/^mirage/, MIRAGE_CMD)
4
- else
5
- path = "#{RUBY_CMD} ../bin/"
6
- end
7
-
8
- @commandline_output = normalise(run("#{path}#{command}"))
9
- end
10
-
11
- Given /^the file '(.*)' contains:$/ do |file_path, content|
12
- write_to_file file_path, content
13
- end
14
-
15
- Given /^usage information:$/ do |usage|
16
- @usage = normalise(usage.to_s)
17
- end
18
-
19
- Then /^I run$/ do |text|
20
- text.gsub!("\"", "\\\\\"")
21
- Dir.chdir SCRATCH do
22
- raise "run failed" unless system "#{RUBY_CMD} -I #{SOURCE_PATH} -e \"#{@code_snippet}\n#{text}\""
23
- end
24
- end
25
-
26
- Given /^the following require statements are needed:$/ do |text|
27
- @code_snippet = text.gsub("\"", "\\\\\"")
28
- end
29
-
30
- When /^I send (POST|PUT) to '(.*)' with request entity$/ do |method, endpoint, entity|
31
- url = "http://localhost:7001#{endpoint}"
32
- @response = case method
33
- when 'POST'
34
- post(url, body: entity)
35
- when 'PUT'
36
- put(url, body: entity)
37
- end
38
- end
39
-
40
- When /^(GET|PUT|POST|DELETE) is sent to '([^']*)'$/ do |method, endpoint|
41
- start_time = Time.now
42
- url = "http://localhost:7001#{endpoint}"
43
- @response = case method
44
- when 'GET' then
45
- get(url)
46
- when 'PUT' then
47
- put(url, body: '')
48
- when 'POST' then
49
- post(url, body: '')
50
- when 'DELETE' then
51
- delete(url)
52
- end
53
- @response_time = Time.now - start_time
54
- end
55
-
56
- When /^I click '(.*)'$/ do |thing|
57
- @page = @page.links.find { |link| link.attributes['id'] == thing }.click
58
- end
59
-
60
- When /^I send (GET|POST) to '(.*)' with parameters:$/ do |http_method, endpoint, table|
61
-
62
-
63
- url = "http://localhost:7001#{endpoint}"
64
- parameters = {}
65
- table.raw.each do |row|
66
- parameter, value = row[0].to_sym, row[1]
67
- value = File.exists?(value) ? File.open(value, 'rb') : value
68
- parameters[parameter]=value
69
- end
70
-
71
- @response = case http_method
72
- when 'POST' then
73
- post(url, query: parameters, headers: {'Content-length' => '0'})
74
- when 'GET' then
75
- get(url, query: parameters)
76
- end
77
- end
78
-
79
- Given /^the following template template:$/ do |text|
80
- @response_template = Hashie::Mash.new(JSON.parse(text))
81
- end
82
-
83
- When /^'(.*)' is base64 encoded$/ do |template_component|
84
- @response_template.send(:eval, "#{template_component}=Base64.encode64(#{template_component})")
85
- end
86
-
87
- When /^the template is sent using PUT to '(.*?)'$/ do |endpoint|
88
- @response = put("http://localhost:7001#{endpoint}", body: @response_template.to_hash.to_json, :headers => {"Content-Type" => "application/json"})
89
- end
90
-
91
- Given /^a template for '(.*)' has been set with a value of '(.*)'$/ do |endpoint, value|
92
- mirage.templates.put(endpoint, value)
93
- end
94
-
95
- Given(/^the following Template JSON:$/) do |text|
96
- @response_template = Hashie::Mash.new(JSON.parse(text))
97
- end