test_server 0.2.4 → 0.3.1

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 (106) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +54 -29
  4. data/README.rdoc +28 -0
  5. data/Rakefile +3 -3
  6. data/app/assets/images/.keep +0 -0
  7. data/app/assets/javascripts/application.js +14 -0
  8. data/app/assets/javascripts/errors.js +2 -0
  9. data/app/assets/stylesheets/application.scss +83 -0
  10. data/app/assets/stylesheets/errors.css +4 -0
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/controllers/test_server/application_controller.rb +34 -0
  13. data/app/controllers/test_server/dashboard_controller.rb +9 -0
  14. data/app/controllers/test_server/errors_controller.rb +22 -0
  15. data/app/controllers/test_server/generator_controller.rb +40 -0
  16. data/app/controllers/test_server/static_controller.rb +16 -0
  17. data/app/controllers/test_server/streaming_controller.rb +56 -0
  18. data/app/controllers/test_server/string_controller.rb +39 -0
  19. data/app/helpers/application_helper.rb +2 -0
  20. data/app/helpers/errors_helper.rb +2 -0
  21. data/app/mailers/.keep +0 -0
  22. data/app/models/.keep +0 -0
  23. data/app/models/concerns/.keep +0 -0
  24. data/app/views/layouts/application.html.haml +59 -0
  25. data/app/views/shared/_overview.html.haml +16 -0
  26. data/app/views/test_server/dashboard/show.html.haml +7 -0
  27. data/app/views/test_server/errors/not_found.html.haml +2 -0
  28. data/app/views/test_server/errors/show.html.haml +6 -0
  29. data/app/views/test_server/generator/_overview.html.haml +1 -0
  30. data/app/views/test_server/generator/index.html.haml +1 -0
  31. data/app/views/{xhr/show.haml → test_server/generator/xhr.html.haml} +15 -12
  32. data/app/views/test_server/static/_overview.html.haml +1 -0
  33. data/app/views/test_server/static/index.html.haml +1 -0
  34. data/app/views/test_server/streaming/_overview.html.haml +1 -0
  35. data/app/views/test_server/streaming/index.html.haml +1 -0
  36. data/app/views/test_server/string/_overview.html.haml +1 -0
  37. data/app/views/test_server/string/index.html.haml +1 -0
  38. data/config.ru +3 -50
  39. data/config/application.rb +44 -0
  40. data/config/boot.rb +4 -0
  41. data/config/database.yml +25 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +37 -0
  44. data/config/environments/production.rb +87 -0
  45. data/config/environments/profile.rb +85 -0
  46. data/config/environments/test.rb +39 -0
  47. data/config/initializers/backtrace_silencers.rb +7 -0
  48. data/config/initializers/breadbrumb_builder.rb +24 -0
  49. data/config/initializers/change_values.rb +5 -0
  50. data/config/initializers/cookies_serializer.rb +3 -0
  51. data/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/config/initializers/inflections.rb +16 -0
  53. data/config/initializers/mime_types.rb +4 -0
  54. data/config/initializers/session_store.rb +3 -0
  55. data/config/initializers/to_bool.rb +23 -0
  56. data/config/initializers/wrap_parameters.rb +14 -0
  57. data/config/locales/en.yml +23 -0
  58. data/config/routes.rb +78 -0
  59. data/config/secrets.yml +22 -0
  60. data/lib/assets/.keep +0 -0
  61. data/lib/tasks/.keep +0 -0
  62. data/lib/test_server.rb +13 -15
  63. data/lib/test_server/error_handler.rb +15 -11
  64. data/lib/test_server/error_messages.rb +16 -6
  65. data/lib/test_server/exceptions.rb +6 -0
  66. data/lib/test_server/locales/en.yml +55 -2
  67. data/lib/test_server/permitted_params.rb +107 -0
  68. data/lib/test_server/version.rb +1 -1
  69. data/lib/test_server/web_helper.rb +7 -31
  70. data/log/.keep +0 -0
  71. data/log/development.log +0 -0
  72. data/log/test.log +1 -0
  73. data/public/404.html +67 -0
  74. data/public/422.html +67 -0
  75. data/public/500.html +66 -0
  76. data/public/favicon.ico +0 -0
  77. data/public/robots.txt +5 -0
  78. data/public/static/plain.html +11 -0
  79. data/script/bundle +3 -0
  80. data/script/rails +8 -0
  81. data/script/rake +8 -0
  82. data/script/spring +18 -0
  83. data/spec/controllers/errors_controller_spec.rb +12 -0
  84. data/spec/error_handler_spec.rb +42 -9
  85. data/spec/features/dashboard_spec.rb +35 -0
  86. data/spec/features/fetch_data_via_javascript_spec.rb +14 -14
  87. data/spec/features/fetch_test_data_plain_spec.rb +11 -29
  88. data/spec/features/fetch_test_data_via_streaming_spec.rb +6 -6
  89. data/spec/features/helper_spec.rb +23 -31
  90. data/spec/helpers/errors_helper_spec.rb +15 -0
  91. data/spec/permitted_params_spec.rb +64 -0
  92. data/spec/spec_helper.rb +44 -3
  93. data/spec/support/capybara.rb +4 -0
  94. data/spec/support/rails.rb +33 -0
  95. data/spec/views/errors/not_found.html.haml_spec.rb +5 -0
  96. data/test_server.gemspec +18 -17
  97. data/vendor/assets/components/open-sans/scss/_base.scss +5 -5
  98. data/vendor/assets/javascripts/.keep +0 -0
  99. data/vendor/assets/stylesheets/.keep +0 -0
  100. metadata +133 -116
  101. data/app/controllers/application_controller.rb +0 -76
  102. data/app/controllers/assets_controller.rb +0 -73
  103. data/app/controllers/javascript_controller.rb +0 -36
  104. data/app/controllers/streaming_controller.rb +0 -52
  105. data/app/controllers/string_controller.rb +0 -51
  106. data/app/views/layouts/application.haml +0 -19
data/log/.keep ADDED
File without changes
File without changes
data/log/test.log ADDED
@@ -0,0 +1 @@
1
+  (0.1ms) begin transaction
data/public/404.html ADDED
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
data/public/422.html ADDED
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
data/public/500.html ADDED
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
data/public/robots.txt ADDED
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,11 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ Static site for testing
5
+ </title>
6
+ </head>
7
+ <body>
8
+ <h1>Static site</h1>
9
+ Static site
10
+ </body>
11
+ </html>
data/script/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
7
+ require_relative '../config/boot'
8
+ require 'rails/commands'
data/script/rake ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ require_relative '../config/boot'
7
+ require 'rake'
8
+ Rake.application.run
data/script/spring ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast
4
+ # It gets overwritten when you run the `spring binstub` command
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m)
11
+ ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
12
+ ENV["GEM_HOME"] = ""
13
+ Gem.paths = ENV
14
+
15
+ gem "spring", match[1]
16
+ require "spring/binstub"
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe TestServer::ErrorsController do
4
+
5
+ describe "GET 'not_found'" do
6
+ it "returns http success" do
7
+ get 'not_found'
8
+ response.should be_success
9
+ end
10
+ end
11
+
12
+ end
@@ -5,16 +5,56 @@ describe ErrorHandler do
5
5
  let(:exception) { StandardError.new }
6
6
 
7
7
  context '.create' do
8
+ end
9
+
10
+ context '#new' do
8
11
  it 'requires an exception class, a message and a exit code' do
9
12
  expect {
10
- ErrorHandler.create(
13
+ ErrorHandler.new(
11
14
  exception: StandardError,
12
15
  details: 'errors.default.details',
13
16
  summary: 'errors.default.summary',
14
- exit_code: 1,
15
17
  )
16
18
  }.not_to raise_error
17
19
  end
20
+
21
+ it 'defaults to 500 for status code' do
22
+ handler = ErrorHandler.new(
23
+ exception: StandardError,
24
+ details: 'errors.default.details',
25
+ summary: 'errors.default.summary',
26
+ )
27
+ expect(handler.status_code).to eq :internal_server_error
28
+ end
29
+
30
+ it 'sets status code' do
31
+ handler = ErrorHandler.new(
32
+ exception: StandardError,
33
+ details: 'errors.default.details',
34
+ summary: 'errors.default.summary',
35
+ status_code: :my_status_code
36
+ )
37
+ expect(handler.status_code).to eq :my_status_code
38
+ end
39
+
40
+ it 'defaults to 1 for exit code' do
41
+ handler = ErrorHandler.new(
42
+ exception: StandardError,
43
+ details: 'errors.default.details',
44
+ summary: 'errors.default.summary',
45
+ )
46
+ expect(handler.exit_code).to eq 1
47
+ end
48
+
49
+ it 'sets exit code' do
50
+ handler = ErrorHandler.new(
51
+ exception: StandardError,
52
+ details: 'errors.default.details',
53
+ summary: 'errors.default.summary',
54
+ exit_code: 5,
55
+ )
56
+ expect(handler.exit_code).to eq 5
57
+ end
18
58
  end
19
59
 
20
60
  context '.find' do
@@ -23,7 +63,6 @@ describe ErrorHandler do
23
63
  exception: StandardError,
24
64
  details: 'errors.default.details',
25
65
  summary: 'errors.default.summary',
26
- exit_code: 1,
27
66
  )
28
67
 
29
68
  expect(ErrorHandler.find(exception)).not_to be_nil
@@ -40,7 +79,6 @@ describe ErrorHandler do
40
79
  exception: StandardError,
41
80
  details: 'errors.default.details',
42
81
  summary: 'errors.default.summary',
43
- exit_code: 1,
44
82
  )
45
83
 
46
84
  expect(handler.exception).to eq(StandardError)
@@ -53,7 +91,6 @@ describe ErrorHandler do
53
91
  exception: StandardError,
54
92
  details: 'errors.default.details',
55
93
  summary: 'errors.default.summary',
56
- exit_code: 1,
57
94
  )
58
95
  handler.original_message = 'blub'
59
96
 
@@ -76,7 +113,6 @@ describe ErrorHandler do
76
113
  exception: StandardError,
77
114
  details: 'errors.internal_error.details',
78
115
  summary: 'errors.internal_error.summary',
79
- exit_code: 1,
80
116
  )
81
117
 
82
118
  TestServer.ui_logger.level = :debug
@@ -98,7 +134,6 @@ describe ErrorHandler do
98
134
  exception: StandardError,
99
135
  details: 'errors.default.details',
100
136
  summary: 'errors.default.summary',
101
- exit_code: 1,
102
137
  )
103
138
  handler.original_message = 'blub'
104
139
 
@@ -124,7 +159,6 @@ describe ErrorHandler do
124
159
  exception: StandardError,
125
160
  details: 'errors.internal_error.details',
126
161
  summary: 'errors.internal_error.summary',
127
- exit_code: 1,
128
162
  )
129
163
 
130
164
  handler.use(message: 'help')
@@ -138,7 +172,6 @@ describe ErrorHandler do
138
172
  exception: StandardError,
139
173
  details: 'errors.internal_error.details',
140
174
  summary: 'errors.internal_error.summary',
141
- exit_code: 1,
142
175
  )
143
176
 
144
177
  handler.use(message: 'help')
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe 'Dashboard', :js do
5
+ before :each do
6
+ config = Class.new do
7
+ include FeduxOrg::Stdlib::Filesystem
8
+
9
+ def root_directory
10
+ ::File.expand_path('../../../', __FILE__)
11
+ end
12
+
13
+ def log_level
14
+ :unknown
15
+ end
16
+
17
+ def access_log
18
+ File.join(working_directory, 'access.log')
19
+ end
20
+
21
+ def reload_config_signal
22
+ 'USR1'
23
+ end
24
+ end.new
25
+
26
+ TestServer.config = config
27
+ end
28
+
29
+ context 'Overview test functions' do
30
+ it 'lists links to all other test functions' do
31
+ visit '/'
32
+ expect(page).to have_selector 'div.ts-dashboard-section-body li a'
33
+ end
34
+ end
35
+ end
@@ -25,21 +25,21 @@ describe 'Fetch data via javascript', :js do
25
25
 
26
26
  TestServer.config = config
27
27
 
28
- Capybara.app = Rack::Builder.new do
29
- map '/' do
30
- run TestServer::App::JavascriptController
31
- end
32
-
33
- map '/assets' do
34
- run TestServer::App::AssetsController.assets
35
- end
36
- end
28
+ #Capybara.app = Rack::Builder.new do
29
+ # map '/' do
30
+ # run TestServer::App::JavascriptController
31
+ # end
32
+
33
+ # map '/assets' do
34
+ # run TestServer::App::AssetsController.assets
35
+ # end
36
+ #end
37
37
  end
38
38
 
39
- context '/xhr/url/' do
39
+ context '/generator/xhr' do
40
40
  it 'submits requests to url' do
41
- url = '/v1/test/javascript/xhr/url'
42
- visit '/xhr/url/'
41
+ url = '/generator/xhr'
42
+ visit url
43
43
 
44
44
  within '#form' do
45
45
  fill_in 'url', :with => url
@@ -55,8 +55,8 @@ describe 'Fetch data via javascript', :js do
55
55
  end
56
56
 
57
57
  it 'supports opening a new page based on given values' do
58
- url = '/v1/test/javascript/xhr/url'
59
- visit '/xhr/url/'
58
+ url = '/generator/xhr'
59
+ visit '/generator/xhr'
60
60
 
61
61
  within '#form' do
62
62
  fill_in 'url', :with => url