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,4 +0,0 @@
1
- Templates are the descriptors pushed to Mirage to tell it what to return to a client.
2
-
3
- They can be configured to place restrictions on the requests that should be met before they are allowed to be used to generate a response.
4
-
@@ -1,113 +0,0 @@
1
- Feature: Placing requirements on requests
2
- If you want Mirage to be choosy when using a Template to generate a response the following can have requirements placed on them when looking for a suitable to Template to generate responses:
3
-
4
- * request parameters
5
- * body content
6
- * HTTP Headers
7
- * HTTP Method
8
-
9
- When specifying requirements on Headers, request parameters or the body of a request either a litteral string
10
- or a regular expression can be used for matching.
11
-
12
- Background: There is already a default response for 'greeting'
13
- Given the following template template:
14
- """
15
- {
16
- "request":{
17
- "parameters":{},
18
- "http_method":"get",
19
- "body_content":[]
20
- },
21
- "response":{
22
- "default":false,
23
- "body":"Hello Stranger",
24
- "delay":0,
25
- "content_type":"text/plain",
26
- "status":200
27
- }
28
- }
29
- """
30
- And 'response.body' is base64 encoded
31
- And the template is sent using PUT to '/templates/greeting'
32
-
33
- Scenario: Configuring a template with requirements on HTTP headers
34
- Given the following template template:
35
- """
36
- {
37
- "request":{
38
- "parameters":{},
39
- "http_method":"get",
40
- "body_content":[]
41
- },
42
- "response":{
43
- "default":false,
44
- "body":"Hello Stranger",
45
- "delay":0,
46
- "content_type":"text/plain",
47
- "status":200
48
- }
49
- }
50
- """
51
- And 'response.body' is base64 encoded
52
- And the template is sent using PUT to '/templates/greeting'
53
-
54
-
55
- Scenario: Configuring a template with requirements on request parameters
56
- Given the following template template:
57
- """
58
- {
59
- "request":{
60
- "parameters":{
61
- "firstname" : "%r\{.*e}",
62
- "surname" : "Blogs"
63
- },
64
- "http_method":"get",
65
- "body_content":[]
66
- },
67
- "response":{
68
- "default":false,
69
- "body":"Hello Joe",
70
- "delay":0,
71
- "content_type":"text/plain",
72
- "status":200
73
- }
74
- }
75
- """
76
- And 'response.body' is base64 encoded
77
- And the template is sent using PUT to '/templates/greeting'
78
-
79
- When I send GET to '/responses/greeting' with parameters:
80
- |firstname|Joe |
81
- |surname |Blogs|
82
- Then 'Hello Joe' should be returned
83
-
84
- Scenario: Configuring a template with requirements on the body
85
- Given the following template template:
86
- """
87
- {
88
- "request":{
89
- "parameters":{},
90
- "http_method":"POST",
91
- "body_content":["Joe", "%r{B..gs}"]
92
- },
93
- "response":{
94
- "default":false,
95
- "body":"Hello Joe",
96
- "delay":0,
97
- "content_type":"text/plain",
98
- "status":200
99
- }
100
- }
101
- """
102
- And 'response.body' is base64 encoded
103
- And the template is sent using PUT to '/templates/greeting'
104
-
105
- When I send POST to '/responses/greeting' with request entity
106
- """
107
- {"username":"Joe Blogs"}
108
- """
109
- Then 'Hello Joe' should be returned
110
-
111
-
112
-
113
-
@@ -1,44 +0,0 @@
1
- Feature: Web interface
2
- Note: This feature is being rewritten but the screens pretty basic so take a look:
3
-
4
- The home page is served from '/' so by default is found at http://localhost:7001/
5
-
6
- Mirage's home page allows you to see what response are currently being hosted.
7
- From this page you can:
8
- - See all currently hosted templates
9
- - Preview at a Templates content
10
- - View the last request to trigger a particular Template
11
-
12
-
13
- # Background: There are already a couple of responses hosted on he Mirage server
14
- # Given the following template template:
15
- # """
16
- # {
17
- # "response":{
18
- # "body":"SGVsbG8="
19
- # },
20
- # "request":{
21
- # }
22
- # }
23
- # """
24
- # And the template is sent using PUT to '/templates/greeting'
25
- #
26
- #
27
- # Scenario: Using the home page to see what response are being hosted
28
- # Given I goto to the Mirage home page
29
- # Then I should see 'greeting/*'
30
- # Then I should see 'leaving'
31
- #
32
- # Scenario: Using the home page to peek at a response
33
- # Given I goto ''
34
- # When I click 'peek_response_1'
35
- # Then I should see 'hello'
36
- #
37
- # Scenario: Using the home page to track if a request has been made
38
- # Given I send POST to '/responses/greeting' with request entity
39
- # """
40
- # Yo!
41
- # """
42
- # Given I goto ''
43
- # When I click 'track_response_1'
44
- # Then I should see 'Yo!'
@@ -1,100 +0,0 @@
1
- #!/bin/bash
2
- blue='\033[34m'
3
- red='\033[31m'
4
- green='\033[32m'
5
- yellow='\033[33m'
6
- white='\033[37m'
7
- bold='\033[1m'
8
- reset='\033[0m'
9
-
10
- println(){
11
- echo -e "$1${reset}"
12
- }
13
-
14
- print(){
15
- echo -ne "$1${reset}"
16
- }
17
-
18
-
19
-
20
- usage(){
21
- println "${bold}Usage:\n"
22
- println "./full_build.sh [ruby_version]\n"
23
- println "When running with out a ruby version, the full build is run for ruby versions:"
24
- println "1.8.6\n1.8.7\n1.9.1\n1.9.2\njruby\n"
25
- println "Else specify a particular ruby version to run the build against\n"
26
- }
27
-
28
-
29
- if [ -f "$HOME/.rvm/scripts/rvm" ]
30
- then
31
- source "$HOME/.rvm/scripts/rvm"
32
- elif [ -f "/usr/local/rvm/scripts/rvm" ]
33
- then
34
- source "/usr/local/rvm/scripts/rvm"
35
- else
36
- println "${bold}RVM Not found"
37
- println "I looked in $HOME/.rvm/scripts/rvm and /usr/local/rvm/scripts/rvm"
38
- println "RVM must be installed to run this script. It's great! find out more: here ${bold}http://rvm.beginrescueend.com/"
39
- println "Until it is installed simply run the default rake target to test Mirage against your active version of Ruby and installed gems"
40
- exit 1
41
- fi
42
-
43
- while getopts ":h" opt; do
44
- case $opt in
45
- h)
46
- usage
47
- exit 0
48
- ;;
49
- \?)
50
- println "Invalid option: -$OPTARG"
51
- usage
52
- exit 1
53
- ;;
54
- esac
55
- done
56
-
57
- message=""
58
- result=true
59
-
60
- run_build_for_ruby( ){
61
- println "${green}Running build for: $1"
62
-
63
- ruby_list=`rvm list`
64
- if [[ ${ruby_list} == *$1* ]]
65
- then
66
- rvm --create $1@mirage
67
- rvm --force gemset empty
68
- [ -f Gemfile.lock ] && rm Gemfile.lock
69
- gem install bundler
70
- bundle install
71
- rake
72
-
73
- if [ $? == 0 ]
74
- then
75
- message="${message}${blue}$1: ${green}pass\n"
76
- else
77
- message="${message}${blue}$1: ${red}fail\n"
78
- result=false
79
- fi
80
- else
81
- message="${message}${blue}$1: ${yellow}Not installed\n"
82
- result=false
83
- fi
84
- }
85
-
86
- if [ $1 ]
87
- then
88
- run_build_for_ruby $1
89
- else
90
- run_build_for_ruby 'ruby-1.8.6'
91
- run_build_for_ruby 'ruby-1.8.7'
92
- run_build_for_ruby 'ruby-1.9.1-p378'
93
- run_build_for_ruby 'ruby-1.9.2'
94
- run_build_for_ruby 'jruby'
95
- fi
96
-
97
- println "\n\n${message}"
98
- print "${white}Result: "
99
- [ ${result} == true ] && println "${green}Pass\n" || println "${red}Fail\n"
100
-
@@ -1,174 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: mirage 3.0.13 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "mirage"
9
- s.version = "3.0.13"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Leon Davis"]
14
- s.date = "2017-10-11"
15
- 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
- s.executables = ["mirage"]
17
- s.extra_rdoc_files = [
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".ruby-gemset",
22
- ".ruby-version",
23
- ".simplecov",
24
- ".travis.yml",
25
- "Gemfile",
26
- "Gemfile.lock",
27
- "HISTORY",
28
- "README.md",
29
- "Rakefile",
30
- "VERSION",
31
- "bin/mirage",
32
- "features/.nav",
33
- "features/client/clear.feature",
34
- "features/client/configure.feature",
35
- "features/client/model.feature",
36
- "features/client/preview_responses.feature",
37
- "features/client/prime.feature",
38
- "features/client/put.feature",
39
- "features/client/readme.md",
40
- "features/client/requests.feature",
41
- "features/client/running.feature",
42
- "features/client/save_and_revert.feature",
43
- "features/client/start.feature",
44
- "features/client/stop.feature",
45
- "features/commandline_interface/help.feature",
46
- "features/commandline_interface/readme.md",
47
- "features/commandline_interface/start.feature",
48
- "features/commandline_interface/stop.feature",
49
- "features/logging.feature",
50
- "features/prime.feature",
51
- "features/readme.md",
52
- "features/requests/delete.feature",
53
- "features/requests/get.feature",
54
- "features/save_and_revert.feature",
55
- "features/step_definitions/my_steps.rb",
56
- "features/step_definitions/observation_steps.rb",
57
- "features/support/command_line.rb",
58
- "features/support/env.rb",
59
- "features/support/hooks.rb",
60
- "features/support/mirage.rb",
61
- "features/support/web.rb",
62
- "features/templates/delete.feature",
63
- "features/templates/get.feature",
64
- "features/templates/path_wildcards.feature",
65
- "features/templates/preview.feature",
66
- "features/templates/put.feature",
67
- "features/templates/put_with_substitutions.feature",
68
- "features/templates/readme.md",
69
- "features/templates/required_content.feature",
70
- "features/web_user_interface.feature",
71
- "full_build.sh",
72
- "lib/mirage/client.rb",
73
- "lib/mirage/client/cli_bridge.rb",
74
- "lib/mirage/client/client.rb",
75
- "lib/mirage/client/error.rb",
76
- "lib/mirage/client/helpers/method_builder.rb",
77
- "lib/mirage/client/request.rb",
78
- "lib/mirage/client/requests.rb",
79
- "lib/mirage/client/runner.rb",
80
- "lib/mirage/client/template.rb",
81
- "lib/mirage/client/template/configuration.rb",
82
- "lib/mirage/client/template/model.rb",
83
- "lib/mirage/client/template/model/common_methods.rb",
84
- "lib/mirage/client/template/model/instance_methods.rb",
85
- "lib/mirage/client/templates.rb",
86
- "lib/mirage/wait_methods.rb",
87
- "mirage.gemspec",
88
- "mirage_server.rb",
89
- "server/app.rb",
90
- "server/binary_data_checker.rb",
91
- "server/extensions/hash.rb",
92
- "server/extensions/object.rb",
93
- "server/helpers.rb",
94
- "server/helpers/http_headers.rb",
95
- "server/helpers/template_requirements.rb",
96
- "server/mock_response.rb",
97
- "server/mock_response_set.rb",
98
- "server/server.rb",
99
- "spec/mirage/client/cli_bridge_spec.rb",
100
- "spec/mirage/client/client_spec.rb",
101
- "spec/mirage/client/helpers/method_builder_spec.rb",
102
- "spec/mirage/client/request_spec.rb",
103
- "spec/mirage/client/requests_spec.rb",
104
- "spec/mirage/client/runner_spec.rb",
105
- "spec/mirage/client/template/configuration_spec.rb",
106
- "spec/mirage/client/template/model/common_methods_spec.rb",
107
- "spec/mirage/client/template/model/instance_methods_spec.rb",
108
- "spec/mirage/client/template/model_spec.rb",
109
- "spec/mirage/client/template_spec.rb",
110
- "spec/mirage/client/templates_spec.rb",
111
- "spec/mirage/wait_methods_spec.rb",
112
- "spec/resources/binary.file",
113
- "spec/server/binary_data_checker_spec.rb",
114
- "spec/server/helpers/http_headers_spec.rb",
115
- "spec/server/helpers/template_requirements_spec.rb",
116
- "spec/server/mock_response_set_spec.rb",
117
- "spec/server/mock_response_spec.rb",
118
- "spec/server/server_spec.rb",
119
- "spec/spec_helper.rb",
120
- "tasks/application.rake",
121
- "tasks/packaging.rake",
122
- "tasks/tests.rake",
123
- "views/index.haml",
124
- "views/response.haml"
125
- ]
126
- s.homepage = "https://github.com/lashd/mirage"
127
- s.licenses = ["MIT"]
128
- 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"
129
- s.rubygems_version = "2.4.8"
130
- s.summary = "Mirage is a easy mock server for testing your applications"
131
-
132
- if s.respond_to? :specification_version then
133
- s.specification_version = 4
134
-
135
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
136
- s.add_runtime_dependency(%q<sinatra>, [">= 0"])
137
- s.add_runtime_dependency(%q<childprocess>, [">= 0"])
138
- s.add_runtime_dependency(%q<thor>, [">= 0"])
139
- s.add_runtime_dependency(%q<ptools>, [">= 0"])
140
- s.add_runtime_dependency(%q<httparty>, [">= 0"])
141
- s.add_runtime_dependency(%q<haml>, [">= 0"])
142
- s.add_runtime_dependency(%q<hashie>, [">= 0"])
143
- s.add_development_dependency(%q<rake>, [">= 0"])
144
- s.add_development_dependency(%q<jeweler>, [">= 0"])
145
- s.add_development_dependency(%q<sinatra-contrib>, [">= 0"])
146
- s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
147
- else
148
- s.add_dependency(%q<sinatra>, [">= 0"])
149
- s.add_dependency(%q<childprocess>, [">= 0"])
150
- s.add_dependency(%q<thor>, [">= 0"])
151
- s.add_dependency(%q<ptools>, [">= 0"])
152
- s.add_dependency(%q<httparty>, [">= 0"])
153
- s.add_dependency(%q<haml>, [">= 0"])
154
- s.add_dependency(%q<hashie>, [">= 0"])
155
- s.add_dependency(%q<rake>, [">= 0"])
156
- s.add_dependency(%q<jeweler>, [">= 0"])
157
- s.add_dependency(%q<sinatra-contrib>, [">= 0"])
158
- s.add_dependency(%q<jruby-openssl>, [">= 0"])
159
- end
160
- else
161
- s.add_dependency(%q<sinatra>, [">= 0"])
162
- s.add_dependency(%q<childprocess>, [">= 0"])
163
- s.add_dependency(%q<thor>, [">= 0"])
164
- s.add_dependency(%q<ptools>, [">= 0"])
165
- s.add_dependency(%q<httparty>, [">= 0"])
166
- s.add_dependency(%q<haml>, [">= 0"])
167
- s.add_dependency(%q<hashie>, [">= 0"])
168
- s.add_dependency(%q<rake>, [">= 0"])
169
- s.add_dependency(%q<jeweler>, [">= 0"])
170
- s.add_dependency(%q<sinatra-contrib>, [">= 0"])
171
- s.add_dependency(%q<jruby-openssl>, [">= 0"])
172
- end
173
- end
174
-
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
- require 'mirage/client'
3
-
4
- describe CLIBridge do
5
- def mapping port
6
- {port.to_s => port_pid_mappings[port.to_s]}
7
- end
8
-
9
- let(:port_pid_mappings) do
10
- {"7001" => "18903", "7002" => "18904", "7003" => "18905"}
11
- end
12
-
13
- let(:operating_system) do
14
- Hashie::Mash.new({
15
- :windows => {
16
- :kill_string => "taskkill /F /T /PID %d",
17
- :set_ps_cmd_expectation => proc{bridge.stub(:`).with(/tasklist.*/).and_return(tasklist_output)}
18
- },
19
- :linux => {
20
- :kill_string => "kill -9 %d",
21
- :set_ps_cmd_expectation => proc{IO.stub(:popen).with(/ps aux.*/).and_return(tasklist_output)}
22
- }
23
- })
24
- end
25
-
26
- [:linux,:windows].each do |os_name|
27
-
28
- describe os_name do
29
- let(:os){operating_system[os_name]}
30
- let!(:bridge) do
31
- bridge = Object.new
32
- bridge.extend(CLIBridge)
33
- end
34
-
35
- include_context os_name do
36
-
37
- let(:tasklist_output) do
38
- output = []
39
- port_pid_mappings.each do |port, pid|
40
- output << process_string_for_mirage(port, pid)
41
- end
42
- output.join("\n")
43
- end
44
-
45
- it 'should find the pids of mirage instances for given ports' do
46
- os.set_ps_cmd_expectation.call
47
- bridge.mirage_process_ids([7001, 7002]).should == mapping(7001).merge(mapping(7002))
48
- end
49
-
50
- it 'should find the pids of mirage instances for all ports' do
51
- os.set_ps_cmd_expectation.call
52
- bridge.mirage_process_ids([:all]).should == port_pid_mappings
53
- end
54
-
55
- it 'should kill the given process id' do
56
- bridge.should_receive(:`).with(os.kill_string % 18903)
57
- bridge.kill(18903)
58
- end
59
- end
60
- end
61
- end
62
-
63
- end