hanami 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -1
  3. data/lib/hanami/configuration/null_configuration.rb +2 -2
  4. data/lib/hanami/configuration.rb +17 -17
  5. data/lib/hanami/routes.rb +48 -21
  6. data/lib/hanami/version.rb +1 -1
  7. data/spec/{new_integration → integration}/action/cookies_spec.rb +0 -0
  8. data/spec/{new_integration → integration}/action/csrf_protection_spec.rb +0 -0
  9. data/spec/{new_integration → integration}/action/routes_spec.rb +3 -5
  10. data/spec/{new_integration → integration}/action/sessions_spec.rb +0 -0
  11. data/spec/{new_integration → integration}/action/slice_configuration_spec.rb +0 -0
  12. data/spec/{new_integration → integration}/action/view_integration_spec.rb +0 -0
  13. data/spec/{new_integration → integration}/action/view_rendering/automatic_rendering_spec.rb +0 -0
  14. data/spec/{new_integration → integration}/action/view_rendering/paired_view_inference_spec.rb +0 -0
  15. data/spec/{new_integration → integration}/action/view_rendering_spec.rb +0 -0
  16. data/spec/{new_integration → integration}/code_loading/loading_from_app_spec.rb +0 -0
  17. data/spec/{new_integration → integration}/code_loading/loading_from_lib_spec.rb +0 -0
  18. data/spec/{new_integration → integration}/code_loading/loading_from_slice_spec.rb +0 -0
  19. data/spec/{new_integration → integration}/container/application_routes_helper_spec.rb +1 -3
  20. data/spec/{new_integration → integration}/container/auto_injection_spec.rb +0 -0
  21. data/spec/{new_integration → integration}/container/auto_registration_spec.rb +0 -0
  22. data/spec/{new_integration → integration}/container/autoloader_spec.rb +0 -0
  23. data/spec/{new_integration → integration}/container/imports_spec.rb +0 -0
  24. data/spec/{new_integration → integration}/container/prepare_container_spec.rb +0 -0
  25. data/spec/{new_integration → integration}/container/shutdown_spec.rb +0 -0
  26. data/spec/{new_integration → integration}/container/standard_bootable_components_spec.rb +0 -0
  27. data/spec/{new_integration → integration}/dotenv_loading_spec.rb +0 -0
  28. data/spec/{new_integration → integration}/rack_app/middleware_spec.rb +9 -15
  29. data/spec/{new_integration → integration}/rack_app/non_booted_rack_app_spec.rb +3 -5
  30. data/spec/{new_integration → integration}/rack_app/rack_app_spec.rb +28 -48
  31. data/spec/{new_integration → integration}/settings/access_to_constants_spec.rb +0 -0
  32. data/spec/{new_integration → integration}/settings/loading_from_env_spec.rb +0 -0
  33. data/spec/{new_integration → integration}/settings/settings_component_loading_spec.rb +0 -0
  34. data/spec/{new_integration → integration}/settings/using_types_spec.rb +0 -0
  35. data/spec/{new_integration → integration}/setup_spec.rb +20 -0
  36. data/spec/{new_integration → integration}/slices/external_slice_spec.rb +2 -4
  37. data/spec/{new_integration → integration}/slices/slice_configuration_spec.rb +0 -0
  38. data/spec/{new_integration → integration}/slices/slice_loading_spec.rb +0 -0
  39. data/spec/{new_integration → integration}/slices/slice_routing_spec.rb +5 -13
  40. data/spec/{new_integration → integration}/slices/slice_settings_spec.rb +0 -0
  41. data/spec/{new_integration → integration}/slices_spec.rb +0 -0
  42. data/spec/{new_integration → integration}/view/context/assets_spec.rb +0 -0
  43. data/spec/{new_integration → integration}/view/context/inflector_spec.rb +0 -0
  44. data/spec/{new_integration → integration}/view/context/request_spec.rb +0 -0
  45. data/spec/{new_integration → integration}/view/context/routes_spec.rb +1 -3
  46. data/spec/{new_integration → integration}/view/context/settings_spec.rb +0 -0
  47. data/spec/{new_integration → integration}/view/inflector_spec.rb +0 -0
  48. data/spec/{new_integration → integration}/view/part_namespace_spec.rb +0 -0
  49. data/spec/{new_integration → integration}/view/path_spec.rb +0 -0
  50. data/spec/{new_integration → integration}/view/slice_configuration_spec.rb +0 -0
  51. data/spec/{new_integration → integration}/view/template_spec.rb +0 -0
  52. data/spec/{new_integration → integration}/view/views_spec.rb +0 -0
  53. data/spec/unit/hanami/configuration/actions_spec.rb +4 -15
  54. data/spec/unit/hanami/configuration/router_spec.rb +45 -0
  55. data/spec/unit/hanami/configuration/views_spec.rb +4 -15
  56. data/spec/unit/hanami/version_spec.rb +1 -1
  57. metadata +97 -244
  58. data/lib/hanami/server.rb +0 -29
  59. data/spec/integration/application_middleware_stack_spec.rb +0 -84
  60. data/spec/integration/assets/cdn_spec.rb +0 -48
  61. data/spec/integration/assets/fingerprint_spec.rb +0 -42
  62. data/spec/integration/assets/helpers_spec.rb +0 -50
  63. data/spec/integration/assets/serve_spec.rb +0 -70
  64. data/spec/integration/assets/subresource_integrity_spec.rb +0 -54
  65. data/spec/integration/body_parsers_spec.rb +0 -50
  66. data/spec/integration/cli/assets/precompile_spec.rb +0 -147
  67. data/spec/integration/cli/assets_spec.rb +0 -14
  68. data/spec/integration/cli/console_spec.rb +0 -105
  69. data/spec/integration/cli/db/apply_spec.rb +0 -74
  70. data/spec/integration/cli/db/console_spec.rb +0 -40
  71. data/spec/integration/cli/db/create_spec.rb +0 -50
  72. data/spec/integration/cli/db/drop_spec.rb +0 -54
  73. data/spec/integration/cli/db/migrate_spec.rb +0 -108
  74. data/spec/integration/cli/db/prepare_spec.rb +0 -36
  75. data/spec/integration/cli/db/rollback_spec.rb +0 -96
  76. data/spec/integration/cli/db/version_spec.rb +0 -38
  77. data/spec/integration/cli/db_spec.rb +0 -21
  78. data/spec/integration/cli/destroy/action_spec.rb +0 -143
  79. data/spec/integration/cli/destroy/app_spec.rb +0 -118
  80. data/spec/integration/cli/destroy/mailer_spec.rb +0 -74
  81. data/spec/integration/cli/destroy/migration_spec.rb +0 -70
  82. data/spec/integration/cli/destroy/model_spec.rb +0 -113
  83. data/spec/integration/cli/destroy_spec.rb +0 -18
  84. data/spec/integration/cli/generate/action_spec.rb +0 -469
  85. data/spec/integration/cli/generate/app_spec.rb +0 -215
  86. data/spec/integration/cli/generate/mailer_spec.rb +0 -189
  87. data/spec/integration/cli/generate/migration_spec.rb +0 -72
  88. data/spec/integration/cli/generate/model_spec.rb +0 -290
  89. data/spec/integration/cli/generate/secret_spec.rb +0 -56
  90. data/spec/integration/cli/generate_spec.rb +0 -19
  91. data/spec/integration/cli/new/database_spec.rb +0 -235
  92. data/spec/integration/cli/new/hanami_head_spec.rb +0 -27
  93. data/spec/integration/cli/new/template_spec.rb +0 -118
  94. data/spec/integration/cli/new/test_spec.rb +0 -274
  95. data/spec/integration/cli/new_spec.rb +0 -970
  96. data/spec/integration/cli/plugins_spec.rb +0 -39
  97. data/spec/integration/cli/routes_spec.rb +0 -49
  98. data/spec/integration/cli/server_spec.rb +0 -626
  99. data/spec/integration/cli/version_spec.rb +0 -85
  100. data/spec/integration/early_hints_spec.rb +0 -35
  101. data/spec/integration/handle_exceptions_spec.rb +0 -244
  102. data/spec/integration/head_spec.rb +0 -89
  103. data/spec/integration/http_headers_spec.rb +0 -29
  104. data/spec/integration/mailer_spec.rb +0 -32
  105. data/spec/integration/middleware_spec.rb +0 -81
  106. data/spec/integration/mount_applications_spec.rb +0 -88
  107. data/spec/integration/project_initializers_spec.rb +0 -40
  108. data/spec/integration/rackup_spec.rb +0 -35
  109. data/spec/integration/rake/with_minitest_spec.rb +0 -67
  110. data/spec/integration/rake/with_rspec_spec.rb +0 -69
  111. data/spec/integration/routing_helpers_spec.rb +0 -61
  112. data/spec/integration/security/content_security_policy_spec.rb +0 -46
  113. data/spec/integration/security/csrf_protection_spec.rb +0 -42
  114. data/spec/integration/security/force_ssl_spec.rb +0 -29
  115. data/spec/integration/security/x_content_type_options_spec.rb +0 -46
  116. data/spec/integration/security/x_frame_options_spec.rb +0 -46
  117. data/spec/integration/security/x_xss_protection_spec.rb +0 -46
  118. data/spec/integration/send_file_spec.rb +0 -51
  119. data/spec/integration/sessions_spec.rb +0 -247
  120. data/spec/integration/static_middleware_spec.rb +0 -21
  121. data/spec/integration/streaming_spec.rb +0 -41
  122. data/spec/integration/unsafe_send_file_spec.rb +0 -52
  123. data/spec/support/fixtures/hanami-plugin/Gemfile +0 -8
  124. data/spec/support/fixtures/hanami-plugin/README.md +0 -35
  125. data/spec/support/fixtures/hanami-plugin/Rakefile +0 -4
  126. data/spec/support/fixtures/hanami-plugin/bin/console +0 -15
  127. data/spec/support/fixtures/hanami-plugin/bin/setup +0 -8
  128. data/spec/support/fixtures/hanami-plugin/hanami-plugin.gemspec +0 -28
  129. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/cli.rb +0 -19
  130. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin/version.rb +0 -7
  131. data/spec/support/fixtures/hanami-plugin/lib/hanami/plugin.rb +0 -8
  132. data/spec/unit/hanami/routes_spec.rb +0 -25
@@ -1,235 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe "hanami new", type: :integration do
4
- describe "--database" do
5
- context "postgres" do
6
- it "generates project" do
7
- project = "bookshelf_postgresql"
8
- output = [
9
- "create db/migrations/.gitkeep",
10
- "create db/schema.sql"
11
- ]
12
-
13
- run_cmd "hanami new #{project} --database=postgres", output
14
-
15
- within_project_directory(project) do
16
- #
17
- # .env.development
18
- #
19
- development_url = Platform.match do
20
- engine(:ruby) { "postgresql://localhost/#{project}_development" }
21
- engine(:jruby) { "jdbc:postgresql://localhost/#{project}_development" }
22
- end
23
-
24
- expect(".env.development").to have_file_content(%r{DATABASE_URL="#{development_url}"})
25
-
26
- #
27
- # .env.test
28
- #
29
- test_url = Platform.match do
30
- engine(:ruby) { "postgresql://localhost/#{project}_test" }
31
- engine(:jruby) { "jdbc:postgresql://localhost/#{project}_test" }
32
- end
33
-
34
- expect(".env.test").to have_file_content(%r{DATABASE_URL="#{test_url}"})
35
-
36
- #
37
- # Gemfile
38
- #
39
- gem_name = Platform.match do
40
- engine(:ruby) { "pg" }
41
- engine(:jruby) { "jdbc-postgres" }
42
- end
43
-
44
- expect("Gemfile").to have_file_content(%r{gem '#{gem_name}'})
45
-
46
- #
47
- # config/environment.rb
48
- #
49
- expect("config/environment.rb").to have_file_content(%r{ adapter :sql, ENV.fetch\('DATABASE_URL'\)})
50
- expect("config/environment.rb").to have_file_content(%r{ migrations 'db/migrations'})
51
- expect("config/environment.rb").to have_file_content(%r{ schema 'db/schema.sql'})
52
-
53
- #
54
- # db/migrations/.gitkeep
55
- #
56
- expect("db/migrations/.gitkeep").to be_an_existing_file
57
-
58
- #
59
- # db/schema.sql
60
- #
61
- expect("db/schema.sql").to be_an_existing_file
62
-
63
- #
64
- # .gitignore
65
- #
66
- expect(".gitignore").to have_file_content <<-END
67
- /public/assets*
68
- /tmp
69
- .env.local
70
- .env.*.local
71
- END
72
- end
73
- end
74
- end # postgres
75
-
76
- describe "sqlite" do
77
- it "generates project" do
78
- project = "bookshelf_sqlite"
79
- output = [
80
- "create db/migrations/.gitkeep",
81
- "create db/schema.sql"
82
- ]
83
-
84
- run_cmd "hanami new #{project} --database=sqlite", output
85
-
86
- within_project_directory(project) do
87
- #
88
- # .env.development
89
- #
90
- development_url = Platform.match do
91
- engine(:ruby) { "sqlite://db/#{project}_development.sqlite" }
92
- engine(:jruby) { "jdbc:sqlite://db/#{project}_development.sqlite" }
93
- end
94
-
95
- expect(".env.development").to have_file_content(%r{DATABASE_URL="#{development_url}"})
96
-
97
- #
98
- # .env.test
99
- #
100
- test_url = Platform.match do
101
- engine(:ruby) { "sqlite://db/#{project}_test.sqlite" }
102
- engine(:jruby) { "jdbc:sqlite://db/#{project}_test.sqlite" }
103
- end
104
-
105
- expect(".env.test").to have_file_content(%r{DATABASE_URL="#{test_url}"})
106
-
107
- #
108
- # Gemfile
109
- #
110
- gem_name = Platform.match do
111
- engine(:ruby) { "sqlite3" }
112
- engine(:jruby) { "jdbc-sqlite3" }
113
- end
114
-
115
- expect("Gemfile").to have_file_content(%r{gem '#{gem_name}'})
116
-
117
- #
118
- # config/environment.rb
119
- #
120
- expect("config/environment.rb").to have_file_content(%r{ adapter :sql, ENV.fetch\('DATABASE_URL'\)})
121
- expect("config/environment.rb").to have_file_content(%r{ migrations 'db/migrations'})
122
- expect("config/environment.rb").to have_file_content(%r{ schema 'db/schema.sql'})
123
-
124
- #
125
- # db/migrations/.gitkeep
126
- #
127
- expect("db/migrations/.gitkeep").to be_an_existing_file
128
-
129
- #
130
- # db/schema.sql
131
- #
132
- expect("db/schema.sql").to be_an_existing_file
133
-
134
- #
135
- # .gitignore
136
- #
137
- expect(".gitignore").to have_file_content <<-END
138
- /db/*.sqlite
139
- /public/assets*
140
- /tmp
141
- .env.local
142
- .env.*.local
143
- END
144
- end
145
- end
146
- end # sqlite
147
-
148
- context "mysql" do
149
- it "generates project" do
150
- project = "bookshelf_mysql"
151
- output = [
152
- "create db/migrations/.gitkeep",
153
- "create db/schema.sql"
154
- ]
155
-
156
- run_cmd "hanami new #{project} --database=mysql", output
157
-
158
- within_project_directory(project) do
159
- #
160
- # .env.development
161
- #
162
- development_url = Platform.match do
163
- engine(:ruby) { "mysql2://localhost/#{project}_development" }
164
- engine(:jruby) { "jdbc:mysql://localhost/#{project}_development" }
165
- end
166
-
167
- expect(".env.development").to have_file_content(%r{DATABASE_URL="#{development_url}"})
168
-
169
- #
170
- # .env.test
171
- #
172
- test_url = Platform.match do
173
- engine(:ruby) { "mysql2://localhost/#{project}_test" }
174
- engine(:jruby) { "jdbc:mysql://localhost/#{project}_test" }
175
- end
176
-
177
- expect(".env.test").to have_file_content(%r{DATABASE_URL="#{test_url}"})
178
-
179
- #
180
- # Gemfile
181
- #
182
- gem_name = Platform.match do
183
- engine(:ruby) { "mysql2" }
184
- engine(:jruby) { "jdbc-mysql" }
185
- end
186
-
187
- expect("Gemfile").to have_file_content(%r{gem '#{gem_name}'})
188
-
189
- #
190
- # config/environment.rb
191
- #
192
- expect("config/environment.rb").to have_file_content(%r{ adapter :sql, ENV.fetch\('DATABASE_URL'\)})
193
- expect("config/environment.rb").to have_file_content(%r{ migrations 'db/migrations'})
194
- expect("config/environment.rb").to have_file_content(%r{ schema 'db/schema.sql'})
195
-
196
- #
197
- # db/migrations/.gitkeep
198
- #
199
- expect("db/migrations/.gitkeep").to be_an_existing_file
200
-
201
- #
202
- # db/schema.sql
203
- #
204
- expect("db/schema.sql").to be_an_existing_file
205
-
206
- #
207
- # .gitignore
208
- #
209
- expect(".gitignore").to have_file_content <<-END
210
- /public/assets*
211
- /tmp
212
- .env.local
213
- .env.*.local
214
- END
215
- end
216
- end
217
- end # mysql
218
-
219
- context "missing" do
220
- it "returns error" do
221
- output = "`' is not a valid database engine"
222
-
223
- run_cmd "hanami new bookshelf --database=", output, exit_status: 1
224
- end
225
- end # missing
226
-
227
- context "unknown" do
228
- it "returns error" do
229
- output = "`foo' is not a valid database engine"
230
-
231
- run_cmd "hanami new bookshelf --database=foo", output, exit_status: 1
232
- end
233
- end # unknown
234
- end # database
235
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe "hanami new", type: :integration do
4
- describe "--hanami-head" do
5
- it "generates project" do
6
- project = "bookshelf_hanami_head"
7
-
8
- run_cmd "hanami new #{project} --hanami-head"
9
-
10
- within_project_directory(project) do
11
- #
12
- # Gemfile
13
- #
14
- expect('Gemfile').to have_file_content(%r{gem 'hanami-utils', require: false, git: 'https://github.com/hanami/utils.git', branch: 'develop'})
15
- expect('Gemfile').to have_file_content(%r{gem 'hanami-validations', require: false, git: 'https://github.com/hanami/validations.git', branch: 'develop'})
16
- expect('Gemfile').to have_file_content(%r{gem 'hanami-router', require: false, git: 'https://github.com/hanami/router.git', branch: 'develop'})
17
- expect('Gemfile').to have_file_content(%r{gem 'hanami-controller', require: false, git: 'https://github.com/hanami/controller.git', branch: 'develop'})
18
- expect('Gemfile').to have_file_content(%r{gem 'hanami-view', require: false, git: 'https://github.com/hanami/view.git', branch: 'develop'})
19
- expect('Gemfile').to have_file_content(%r{gem 'hanami-helpers', require: false, git: 'https://github.com/hanami/helpers.git', branch: 'develop'})
20
- expect('Gemfile').to have_file_content(%r{gem 'hanami-mailer', require: false, git: 'https://github.com/hanami/mailer.git', branch: 'develop'})
21
- expect('Gemfile').to have_file_content(%r{gem 'hanami-assets', require: false, git: 'https://github.com/hanami/assets.git', branch: 'develop'})
22
- expect('Gemfile').to have_file_content(%r{gem 'hanami-model', require: false, git: 'https://github.com/hanami/model.git', branch: 'develop'})
23
- expect('Gemfile').to have_file_content(%r{gem 'hanami', git: 'https://github.com/hanami/hanami.git', branch: 'develop'})
24
- end
25
- end
26
- end # hanami-head
27
- end
@@ -1,118 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe "hanami new", type: :integration do
4
- describe "--template" do
5
- context "erb" do
6
- it "generates project" do
7
- project = "bookshelf_erb"
8
- output = [
9
- "create apps/web/templates/app.html.erb"
10
- ]
11
-
12
- run_cmd "hanami new #{project} --template=erb", output
13
-
14
- within_project_directory(project) do
15
- #
16
- # .hanamirc
17
- #
18
- expect(".hanamirc").to have_file_content(%r{template=erb})
19
-
20
- #
21
- # apps/web/templates/app.html.erb
22
- #
23
- expect("apps/web/templates/app.html.erb").to have_file_content <<~END
24
- <!DOCTYPE html>
25
- <html>
26
- <head>
27
- <title>Web</title>
28
- <%= favicon %>
29
- </head>
30
- <body>
31
- <%= yield %>
32
- </body>
33
- </html>
34
- END
35
- end
36
- end
37
- end # erb
38
-
39
- context "haml" do
40
- it "generates project" do
41
- project = "bookshelf_erb"
42
- output = [
43
- "create apps/web/templates/app.html.haml"
44
- ]
45
-
46
- run_cmd "hanami new #{project} --template=haml", output
47
-
48
- within_project_directory(project) do
49
- #
50
- # .hanamirc
51
- #
52
- expect(".hanamirc").to have_file_content(%r{template=haml})
53
-
54
- #
55
- # apps/web/templates/app.html.haml
56
- #
57
- expect("apps/web/templates/app.html.haml").to have_file_content <<~END
58
- !!!
59
- %html
60
- %head
61
- %title Web
62
- = favicon
63
- %body
64
- = yield
65
- END
66
- end
67
- end
68
- end # haml
69
-
70
- context "slim" do
71
- it "generates project" do
72
- project = "bookshelf_erb"
73
- output = [
74
- "create apps/web/templates/app.html.slim"
75
- ]
76
-
77
- run_cmd "hanami new #{project} --template=slim", output
78
-
79
- within_project_directory(project) do
80
- #
81
- # .hanamirc
82
- #
83
- expect(".hanamirc").to have_file_content(%r{template=slim})
84
-
85
- #
86
- # apps/web/templates/app.html.slim
87
- #
88
- expect("apps/web/templates/app.html.slim").to have_file_content <<~END
89
- doctype html
90
- html
91
- head
92
- title
93
- | Web
94
- = favicon
95
- body
96
- = yield
97
- END
98
- end
99
- end
100
- end # slim
101
-
102
- context "missing" do
103
- it "returns error" do
104
- output = "`' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
105
-
106
- run_cmd "hanami new bookshelf --template=", output, exit_status: 1
107
- end
108
- end # missing
109
-
110
- context "unknown" do
111
- it "returns error" do
112
- output = "`foo' is not a valid template engine. Please use one of: `erb', `haml', `slim'"
113
-
114
- run_cmd "hanami new bookshelf --template=foo", output, exit_status: 1
115
- end
116
- end # unknown
117
- end # template
118
- end
@@ -1,274 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe "hanami new", type: :integration do
4
- describe "--test" do
5
- context "minitest" do
6
- it "generates project" do
7
- project = "bookshelf_minitest"
8
- output = [
9
- "create spec/spec_helper.rb",
10
- "create spec/features_helper.rb",
11
- "create spec/web/views/app_layout_spec.rb"
12
- ]
13
-
14
- run_cmd "hanami new #{project} --test=minitest", output
15
-
16
- within_project_directory(project) do
17
- #
18
- # .hanamirc
19
- #
20
- expect(".hanamirc").to have_file_content(%r{test=minitest})
21
-
22
- #
23
- # spec/spec_helper.rb
24
- #
25
- expect("spec/spec_helper.rb").to have_file_content <<~END
26
- # Require this file for unit tests
27
- ENV['HANAMI_ENV'] ||= 'test'
28
-
29
- require_relative '../config/environment'
30
- require 'minitest/autorun'
31
-
32
- Hanami.boot
33
- END
34
-
35
- #
36
- # spec/features_helper.rb
37
- #
38
- expect("spec/features_helper.rb").to have_file_content <<~END
39
- # Require this file for feature tests
40
- require_relative './spec_helper'
41
-
42
- require 'capybara'
43
- require 'capybara/dsl'
44
-
45
- Capybara.app = Hanami.app
46
-
47
- class MiniTest::Spec
48
- include Capybara::DSL
49
- end
50
- END
51
-
52
- #
53
- # spec/<app>/views/app_layout_spec.rb
54
- #
55
- expect("spec/web/views/app_layout_spec.rb").to have_file_content <<-END
56
- require "spec_helper"
57
-
58
- describe Web::Views::AppLayout do
59
- let(:layout) { Web::Views::AppLayout.new({ format: :html }, "contents") }
60
- let(:rendered) { layout.render }
61
-
62
- it 'contains app name' do
63
- _(rendered).must_include('Web')
64
- end
65
- end
66
- END
67
- end
68
- end
69
- end # minitest
70
-
71
- describe "rspec" do
72
- it "generates project" do
73
- project = "bookshelf_rspec"
74
- output = [
75
- "create .rspec",
76
- "create spec/spec_helper.rb",
77
- "create spec/features_helper.rb",
78
- "create spec/support/capybara.rb",
79
- "create spec/web/views/app_layout_spec.rb"
80
- ]
81
-
82
- run_cmd "hanami new #{project} --test=rspec", output
83
-
84
- within_project_directory(project) do
85
- #
86
- # .hanamirc
87
- #
88
- expect(".hanamirc").to have_file_content(%r{test=rspec})
89
-
90
- #
91
- # .rspec
92
- #
93
- expect(".rspec").to have_file_content <<~END
94
- --color
95
- --require spec_helper
96
- END
97
-
98
- #
99
- # spec/spec_helper.rb
100
- #
101
- expect("spec/spec_helper.rb").to have_file_content <<~END
102
- # Require this file for unit tests
103
- ENV['HANAMI_ENV'] ||= 'test'
104
-
105
- require_relative '../config/environment'
106
- Hanami.boot
107
- Hanami::Utils.require!("\#{__dir__}/support")
108
-
109
- # This file was generated by the `rspec --init` command. Conventionally, all
110
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
111
- # The generated `.rspec` file contains `--require spec_helper` which will cause
112
- # this file to always be loaded, without a need to explicitly require it in any
113
- # files.
114
- #
115
- # Given that it is always loaded, you are encouraged to keep this file as
116
- # light-weight as possible. Requiring heavyweight dependencies from this file
117
- # will add to the boot time of your test suite on EVERY test run, even for an
118
- # individual file that may not need all of that loaded. Instead, consider making
119
- # a separate helper file that requires the additional dependencies and performs
120
- # the additional setup, and require it from the spec files that actually need
121
- # it.
122
- #
123
- # The `.rspec` file also contains a few flags that are not defaults but that
124
- # users commonly want.
125
- #
126
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
127
- RSpec.configure do |config|
128
- # rspec-expectations config goes here. You can use an alternate
129
- # assertion/expectation library such as wrong or the stdlib/minitest
130
- # assertions if you prefer.
131
- config.expect_with :rspec do |expectations|
132
- # This option will default to `true` in RSpec 4. It makes the `description`
133
- # and `failure_message` of custom matchers include text for helper methods
134
- # defined using `chain`, e.g.:
135
- # be_bigger_than(2).and_smaller_than(4).description
136
- # # => "be bigger than 2 and smaller than 4"
137
- # ...rather than:
138
- # # => "be bigger than 2"
139
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
140
- end
141
-
142
- # rspec-mocks config goes here. You can use an alternate test double
143
- # library (such as bogus or mocha) by changing the `mock_with` option here.
144
- config.mock_with :rspec do |mocks|
145
- # Prevents you from mocking or stubbing a method that does not exist on
146
- # a real object. This is generally recommended, and will default to
147
- # `true` in RSpec 4.
148
- mocks.verify_partial_doubles = true
149
- end
150
-
151
- # The settings below are suggested to provide a good initial experience
152
- # with RSpec, but feel free to customize to your heart's content.
153
- =begin
154
- # These two settings work together to allow you to limit a spec run
155
- # to individual examples or groups you care about by tagging them with
156
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
157
- # get run.
158
- config.filter_run :focus
159
- config.run_all_when_everything_filtered = true
160
-
161
- # Allows RSpec to persist some state between runs in order to support
162
- # the `--only-failures` and `--next-failure` CLI options. We recommend
163
- # you configure your source control system to ignore this file.
164
- config.example_status_persistence_file_path = "spec/examples.txt"
165
-
166
- # Limits the available syntax to the non-monkey patched syntax that is
167
- # recommended. For more details, see:
168
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
169
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
170
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
171
- config.disable_monkey_patching!
172
-
173
- # This setting enables warnings. It's recommended, but in many cases may
174
- # be too noisy due to issues in dependencies.
175
- config.warnings = false
176
-
177
- # Many RSpec users commonly either run the entire suite or an individual
178
- # file, and it's useful to allow more verbose output when running an
179
- # individual spec file.
180
- if config.files_to_run.one?
181
- # Use the documentation formatter for detailed output,
182
- # unless a formatter has already been configured
183
- # (e.g. via a command-line flag).
184
- config.default_formatter = 'doc'
185
- end
186
-
187
- # Print the 10 slowest examples and example groups at the
188
- # end of the spec run, to help surface which specs are running
189
- # particularly slow.
190
- config.profile_examples = 10
191
-
192
- # Run specs in random order to surface order dependencies. If you find an
193
- # order dependency and want to debug it, you can fix the order by providing
194
- # the seed, which is printed after each run.
195
- # --seed 1234
196
- config.order = :random
197
-
198
- # Seed global randomization in this process using the `--seed` CLI option.
199
- # Setting this allows you to use `--seed` to deterministically reproduce
200
- # test failures related to randomization by passing the same `--seed` value
201
- # as the one that triggered the failure.
202
- Kernel.srand config.seed
203
- =end
204
- end
205
- END
206
-
207
- #
208
- # spec/features_helper.rb
209
- #
210
- expect("spec/features_helper.rb").to have_file_content <<~END
211
- # Require this file for feature tests
212
- require_relative './spec_helper'
213
-
214
- require 'capybara'
215
- require 'capybara/rspec'
216
-
217
- RSpec.configure do |config|
218
- config.include RSpec::FeatureExampleGroup
219
-
220
- config.include Capybara::DSL, feature: true
221
- config.include Capybara::RSpecMatchers, feature: true
222
- end
223
- END
224
-
225
- #
226
- # spec/support/capybara.rb
227
- #
228
- expect("spec/support/capybara.rb").to have_file_content <<~END
229
- module RSpec
230
- module FeatureExampleGroup
231
- def self.included(group)
232
- group.metadata[:type] = :feature
233
- Capybara.app = Hanami.app
234
- end
235
- end
236
- end
237
- END
238
-
239
- #
240
- # spec/<app>/views/app_layout_spec.rb
241
- #
242
- expect("spec/web/views/app_layout_spec.rb").to have_file_content <<~END
243
- require "spec_helper"
244
-
245
- RSpec.describe Web::Views::AppLayout, type: :view do
246
- let(:layout) { Web::Views::AppLayout.new({ format: :html }, "contents") }
247
- let(:rendered) { layout.render }
248
-
249
- it 'contains app name' do
250
- expect(rendered).to include('Web')
251
- end
252
- end
253
- END
254
- end
255
- end
256
- end # rspec
257
-
258
- context "missing" do
259
- it "returns error" do
260
- output = "`' is not a valid test framework. Please use one of: `rspec', `minitest'"
261
-
262
- run_cmd "hanami new bookshelf --test=", output, exit_status: 1
263
- end
264
- end # missing
265
-
266
- context "unknown" do
267
- it "returns error" do
268
- output = "`foo' is not a valid test framework. Please use one of: `rspec', `minitest'"
269
-
270
- run_cmd "hanami new bookshelf --test=foo", output, exit_status: 1
271
- end
272
- end # unknown
273
- end # test
274
- end