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,156 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
- require 'base64'
4
-
5
- describe "Mirage Server" do
6
- include_context :rack_test, :disable_sinatra_error_handling => true
7
- before :each do
8
- Mirage::MockResponse.delete_all
9
- end
10
-
11
-
12
- describe "when adding responses" do
13
- before :each do
14
- @mock_response = Mirage::MockResponse.new('endpoint','value')
15
- end
16
-
17
- it 'should create a mock response with the supplied template spec' do
18
- endpoint = 'greeting'
19
- spec = {"somekeys" => 'some_values'}
20
-
21
- Mirage::MockResponse.should_receive(:new).with(endpoint, spec).and_return(@mock_response)
22
- put('/templates/greeting', spec.to_json)
23
- end
24
-
25
- it 'should set the requests url against the template that is created' do
26
- method = 'post'
27
- response_id = 1
28
- Mirage::MockResponse.should_receive(:new).and_return(@mock_response)
29
- put('/templates/greeting', {:request => {:http_method => method}}.to_json)
30
- @mock_response.requests_url.should == "http://example.org/requests/#{response_id}"
31
- end
32
-
33
- end
34
-
35
- context '/templates' do
36
- describe '/preview' 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}/preview")
42
- response.body.should == response_body
43
- response.content_type.should include(content_type)
44
- end
45
- end
46
- end
47
-
48
-
49
-
50
- describe 'matching templates' do
51
- before :each do
52
- @endpoint = "greeting"
53
- @options = {:body => anything, :params => anything, :endpoint => @endpoint, :headers => anything, :http_method => anything}
54
- end
55
-
56
- it 'should use request parameters' do
57
- parameters = {"key" => 'value'}
58
-
59
- Mirage::MockResponse.should_receive(:find).with(@options.merge(:params => parameters)).and_return(Mirage::MockResponse.new(@endpoint, {:response => {:body => "hello"}}))
60
- get("/responses/#{@endpoint}", parameters)
61
- end
62
-
63
- it 'should use the request body' do
64
- body = 'body'
65
-
66
- Mirage::MockResponse.should_receive(:find).with(@options.merge(:body => body)).and_return(Mirage::MockResponse.new(@endpoint, {:response => {:body => "hello"}}))
67
- post("/responses/#{@endpoint}", body)
68
- end
69
-
70
- it 'should use headers' do
71
- headers = {"HEADER" => 'VALUE'}
72
- application_expectations do |app|
73
- app.stub(:env).and_return(headers)
74
- app.should_receive(:extract_http_headers).with(headers).and_return(headers)
75
- end
76
-
77
- Mirage::MockResponse.should_receive(:find).with(@options.merge(:headers => headers)).and_return(Mirage::MockResponse.new(@endpoint, {:response => {:body => "hello"}}))
78
- get("/responses/#{@endpoint}")
79
- end
80
-
81
- it 'should return the default response if a specific match is not found' do
82
- Mirage::MockResponse.should_receive(:find_default).with(@options.merge(:http_method =>"post")).and_return(Mirage::MockResponse.new("greeting", {:response => {:body => "hello"}}))
83
-
84
- response_template = {
85
- :request => {
86
- :body_content => %w(leon),
87
- :content_type => "post"
88
- },
89
- :response => {
90
- :body => "hello leon"
91
- }
92
- }
93
- put("/templates/#{@endpoint}", response_template.to_json)
94
- post("/responses/#{@endpoint}")
95
- end
96
- end
97
-
98
-
99
-
100
- describe "operations" do
101
- describe 'resolving responses' do
102
- it 'should return the default response' do
103
- put('/templates/level1', {:response => {:body => Base64.encode64("level1")}}.to_json)
104
- put('/templates/level1/level2', {:response => {:body => Base64.encode64("level2"), :default => true}}.to_json)
105
- get('/responses/level1/level2/level3').body.should == "level2"
106
- end
107
-
108
- it 'should set any headers specified' do
109
- headers = {header: 'value'}
110
- put('/templates/greeting', {:response => {headers: headers, :body => ''}}.to_json)
111
- get('/responses/greeting').headers['header'].should == 'value'
112
- end
113
- end
114
-
115
- describe 'checking templates' do
116
- it 'should return the descriptor for a template' do
117
- response_body = "hello"
118
- response_id = JSON.parse(put('/templates/greeting', {:response => {:body => Base64.encode64(response_body)}}.to_json).body)['id']
119
- template = JSON.parse(get("/templates/#{response_id}").body)
120
- template.should == JSON.parse({:endpoint => "greeting",
121
- :id => response_id,
122
- :requests_url => "http://example.org/requests/#{response_id}",
123
- :request => {:parameters => {}, :http_method => "get", :body_content => [], :headers => {}},
124
- :response => {:default => false,
125
- :body => Base64.encode64(response_body),
126
- :delay => 0,
127
- :content_type => "text/plain",
128
- :status => 200}
129
- }.to_json)
130
- end
131
- end
132
-
133
- it 'should return tracked request data' do
134
- response_id = JSON.parse(put('/templates/greeting', {:request => {:http_method => :post}, :response => {:body => Base64.encode64("hello")}}.to_json).body)['id']
135
-
136
-
137
- header "MYHEADER", "my_header_value"
138
- post("/responses/greeting?param=value", 'body')
139
- request_data = JSON.parse(get("/requests/#{response_id}").body)
140
-
141
- request_data['parameters'].should == {'param' => 'value'}
142
- request_data['headers']["MYHEADER"].should == "my_header_value"
143
- request_data['body'].should == "body"
144
- request_data['request_url'].should == "http://example.org/responses/greeting?param=value"
145
- request_data['id'].should == "http://example.org/requests/#{response_id}"
146
-
147
- end
148
-
149
-
150
- it 'should delete a template' do
151
- response_id = JSON.parse(put('/templates/greeting', {:response => {:body => Base64.encode64("hello")}}.to_json).body)['id']
152
- delete("/templates/#{response_id}")
153
- expect { get("/templates/#{response_id}") }.to raise_error(Mirage::ServerResponseNotFound)
154
- end
155
- end
156
- end
@@ -1,85 +0,0 @@
1
- ROOT_DIR = "#{File.dirname(__FILE__)}/.."
2
- $LOAD_PATH.unshift "#{ROOT_DIR}/lib"
3
- $LOAD_PATH.unshift "#{ROOT_DIR}/server"
4
- require 'simplecov' if ENV['coverage'] && RUBY_PLATFORM != 'java'
5
- require 'mirage/client'
6
- require 'rspec'
7
- require 'json'
8
- require 'base64'
9
-
10
- module JsonHelpers
11
- def convert_keys_to_strings hash
12
- JSON.parse(hash.to_json)
13
- end
14
- end
15
-
16
- RSpec.configure do |config|
17
- include Mirage
18
- config.include JsonHelpers
19
-
20
- shared_context :windows do
21
- def process_string_for_mirage(mirage_port, pid)
22
- %Q{ruby.exe #{pid} Console 1 6,076 K Running WIN-ATPGMMC0218\\\\leon 0:01:58 mirage server port #{mirage_port}}
23
- end
24
-
25
- before :each do
26
- ChildProcess.stub(:windows?).and_return(true)
27
- end
28
- end
29
-
30
- shared_context :linux do
31
- def process_string_for_mirage(mirage_port, pid)
32
- "team #{pid} 6.2 0.4 84328 20760 pts/1 Sl 22:15 0:00 Mirage Server port #{mirage_port}"
33
- end
34
-
35
- before :each do
36
- ChildProcess.stub(:windows?).and_return(false)
37
- end
38
- end
39
- shared_context :resources do
40
- let(:resources_dir){"#{File.dirname(__FILE__)}/resources"}
41
- end
42
-
43
- shared_context :rack_test do |options|
44
- options = {:disable_sinatra_error_handling => false}.merge(options||{})
45
- require 'sinatra'
46
- require 'app'
47
- require 'rack/test'
48
- include Rack::Test::Methods
49
-
50
- def app
51
- @app_expectations ||= proc{}
52
- Mirage::Server.new do |app|
53
- @app_expectations.call app
54
- end
55
- end
56
-
57
- def application_expectations &block
58
- @app_expectations = proc do |app|
59
- app.stub(:dup).and_return(app)
60
- block.call app
61
- end
62
- end
63
-
64
- if options[:disable_sinatra_error_handling]
65
- module Mirage
66
- class Server < Sinatra::Base
67
- configure do
68
- set :show_exceptions, false
69
- end
70
- end
71
- end
72
-
73
- module Sinatra
74
- class Base
75
- def handle_exception! boom
76
- raise boom
77
- end
78
- end
79
- end
80
- end
81
- end
82
- end
83
-
84
-
85
-
@@ -1,7 +0,0 @@
1
- task :start do
2
- `RACK_ENV='development' && ruby ./bin/mirage start`
3
- end
4
-
5
- task :stop do
6
- `RACK_ENV='development' && ruby ./bin/mirage stop`
7
- end
@@ -1,28 +0,0 @@
1
- task :clean do |task|
2
- if system "gem list -i mirage"
3
- puts "cleaning"
4
- system "gem uninstall -x mirage"
5
- end
6
- Dir['*.gem'].each { |gem| FileUtils.rm_f(gem) }
7
- task.reenable
8
- end
9
-
10
- Jeweler::Tasks.new do |gem|
11
- gem.name = "mirage"
12
- gem.homepage = "https://github.com/lashd/mirage"
13
- gem.license = "MIT"
14
- gem.summary = "Mirage is a easy mock server for testing your applications"
15
- gem.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
- gem.authors = ["Leon Davis"]
17
- gem.executables = ['mirage']
18
- gem.post_install_message = %{
19
- ===============================================================================
20
- Mirage v3:
21
-
22
- Mirage has just gone up a major version from 2 to 3. If your project uses
23
- a previous version take a look at https://github.com/lashd/mirage to see
24
- what's changed
25
- ===============================================================================
26
- }
27
- end
28
- Jeweler::RubygemsDotOrgTasks.new
@@ -1,25 +0,0 @@
1
- task :specs
2
-
3
- %w(client server).each do |type|
4
- public_task_name = "#{type}_specs"
5
- private_task_name = "_#{public_task_name}"
6
-
7
- RSpec::Core::RakeTask.new(private_task_name) do |task|
8
- task.pattern = "spec/#{type}/**/*_spec.rb"
9
- end
10
-
11
- desc "specs for: #{type}"
12
- task public_task_name do
13
- ENV['coverage'] = type
14
- Rake::Task[private_task_name].invoke
15
- end
16
-
17
- Rake::Task["specs"].prerequisites << public_task_name
18
- end
19
-
20
-
21
- require 'cucumber'
22
- require 'cucumber/rake/task'
23
- Cucumber::Rake::Task.new(:features) do |t|
24
- t.cucumber_opts = "mode=regression features --format pretty"
25
- end