dry-web-roda 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -1
- data/.rspec +1 -2
- data/.travis.yml +14 -8
- data/CHANGELOG.md +22 -0
- data/Gemfile +26 -15
- data/README.md +22 -4
- data/dry-web-roda.gemspec +3 -1
- data/lib/dry/web/roda/application.rb +3 -3
- data/lib/dry/web/roda/cli.rb +9 -2
- data/lib/dry/web/roda/cli/generate.rb +4 -4
- data/lib/dry/web/roda/generators/flat_project.rb +31 -0
- data/lib/dry/web/roda/generators/{app.rb → sub_app.rb} +2 -2
- data/lib/dry/web/roda/generators/{umbrella.rb → umbrella_project.rb} +6 -6
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/Gemfile +3 -3
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/README.md.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/Rakefile.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/bin/console.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/bin/setup +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/config.ru.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/config/settings.yml.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/db/sample_data.rb +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/db/seed.rb +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/lib/__underscored_app_name__/.keep +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/lib/__underscored_app_name__/views/welcome.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/persistence/commands/.keep +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/persistence/relations/.keep +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/lib/rom/instrumentation.rb.tt +22 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/lib/types.rb +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/log/.keep +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/app_helper.rb +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/db_helper.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/spec_helper.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/support/db/test_factories.rb +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/spec/support/test_helpers.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/application.rb.tt +29 -0
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/container.rb.tt +23 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/system/__underscored_app_name__/import.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella/lib → flat_project/system}/__underscored_app_name__/repository.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/system/__underscored_app_name__/settings.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/transactions.rb.tt +34 -0
- data/lib/dry/web/roda/skeletons/{umbrella/lib → flat_project/system}/__underscored_app_name__/view_context.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/system/__underscored_app_name__/view_controller.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/system/boot.rb.tt +11 -0
- data/lib/dry/web/roda/skeletons/flat_project/system/boot/monitor.rb.tt +10 -0
- data/lib/dry/web/roda/skeletons/{umbrella → flat_project}/system/boot/rom.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/system/boot/view.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/flat_project/transactions/example.rb.tt +10 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/web/routes/example.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/web/templates/layouts/application.html.slim +0 -0
- data/lib/dry/web/roda/skeletons/{app → flat_project}/web/templates/welcome.html.slim +0 -0
- data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/.keep +0 -0
- data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/views/welcome.rb.tt +11 -0
- data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/application.rb.tt +1 -1
- data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/container.rb.tt +2 -0
- data/lib/dry/web/roda/skeletons/{umbrella → sub_app}/system/__underscored_app_name__/import.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/transactions.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/{app → sub_app}/system/__underscored_app_name__/view_context.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_controller.rb.tt +13 -0
- data/lib/dry/web/roda/skeletons/{app → sub_app}/system/boot.rb.tt +1 -2
- data/lib/dry/web/roda/skeletons/sub_app/system/boot/view.rb.tt +3 -0
- data/lib/dry/web/roda/skeletons/{app → sub_app}/transactions/example.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/sub_app/web/routes/example.rb.tt +7 -0
- data/lib/dry/web/roda/skeletons/sub_app/web/templates/layouts/application.html.slim +3 -0
- data/lib/dry/web/roda/skeletons/sub_app/web/templates/welcome.html.slim +1 -0
- data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/.gitignore +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/Gemfile +39 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/README.md.tt +12 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/Rakefile.tt +81 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/bin/console.tt +7 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/bin/setup +7 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/config.ru.tt +2 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/config/settings.yml.tt +8 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/db/sample_data.rb +1 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/db/seed.rb +1 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/repository.rb.tt +11 -0
- data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/lib/__underscored_app_name__/transactions.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt +39 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/commands/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/relations/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/rom/instrumentation.rb.tt +22 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/lib/types.rb +6 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/log/.keep +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/app_helper.rb +35 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/db_helper.rb.tt +24 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/spec_helper.rb.tt +61 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/db/test_factories.rb +3 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/test_helpers.rb.tt +15 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/application.rb.tt +14 -0
- data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/system/__underscored_app_name__/container.rb.tt +1 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/import.rb.tt +5 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/settings.rb.tt +17 -0
- data/lib/dry/web/roda/skeletons/{umbrella → umbrella_project}/system/boot.rb.tt +0 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/monitor.rb.tt +10 -0
- data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/rom.rb.tt +26 -0
- data/lib/dry/web/roda/version.rb +1 -1
- data/script/ci +67 -0
- data/script/setup +47 -0
- data/script/teardown +42 -0
- data/spec/integration/new_app_spec.rb +21 -0
- data/spec/spec_helper.rb +14 -16
- data/spec/support/app.rb +64 -0
- data/spec/support/bundler.rb +113 -0
- data/spec/support/cli.rb +47 -0
- data/spec/support/directories.rb +37 -0
- data/spec/support/env.rb +84 -0
- data/spec/support/files.rb +59 -0
- data/spec/support/project.rb +60 -0
- data/spec/support/requests.rb +5 -0
- data/spec/support/silently.rb +28 -0
- metadata +139 -49
- data/lib/dry/web/roda/skeletons/umbrella/system/__underscored_app_name__/application.rb.tt +0 -7
- data/lib/dry/web/roda/skeletons/umbrella/system/boot/logger.rb.tt +0 -5
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "db_helper"
|
2
|
+
|
3
|
+
require "rack/test"
|
4
|
+
require "capybara/rspec"
|
5
|
+
require "capybara-screenshot/rspec"
|
6
|
+
require "capybara/poltergeist"
|
7
|
+
|
8
|
+
Dir[SPEC_ROOT.join("support/app/*.rb").to_s].each(&method(:require))
|
9
|
+
Dir[SPEC_ROOT.join("shared/app/*.rb").to_s].each(&method(:require))
|
10
|
+
|
11
|
+
require SPEC_ROOT.join("../system/boot").realpath
|
12
|
+
|
13
|
+
Capybara.app = TestHelpers.app
|
14
|
+
Capybara.server_port = 3001
|
15
|
+
Capybara.save_and_open_page_path = "#{File.dirname(__FILE__)}/../tmp/capybara-screenshot"
|
16
|
+
Capybara.javascript_driver = :poltergeist
|
17
|
+
Capybara::Screenshot.prune_strategy = {keep: 10}
|
18
|
+
|
19
|
+
Capybara.register_driver :poltergeist do |app|
|
20
|
+
Capybara::Poltergeist::Driver.new(
|
21
|
+
app,
|
22
|
+
js_errors: false,
|
23
|
+
phantomjs_logger: File.open(SPEC_ROOT.join("../log/phantomjs.log"), "w"),
|
24
|
+
phantomjs_options: %w(--load-images=no)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.include Rack::Test::Methods, type: :request
|
30
|
+
config.include Rack::Test::Methods, Capybara::DSL, type: :feature
|
31
|
+
|
32
|
+
config.before :suite do
|
33
|
+
TestHelpers.app.freeze
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "spec_helper"
|
2
|
+
|
3
|
+
<%= config[:camel_cased_app_name] %>::Container.boot! :rom
|
4
|
+
|
5
|
+
Dir[SPEC_ROOT.join("support/db/*.rb").to_s].each(&method(:require))
|
6
|
+
Dir[SPEC_ROOT.join("shared/db/*.rb").to_s].each(&method(:require))
|
7
|
+
|
8
|
+
require "database_cleaner"
|
9
|
+
DatabaseCleaner[:sequel, connection: TestHelpers.db_connection].strategy = :truncation
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include TestHelpers
|
13
|
+
config.include TestFactories
|
14
|
+
|
15
|
+
config.before :suite do
|
16
|
+
DatabaseCleaner.clean_with :truncation
|
17
|
+
end
|
18
|
+
|
19
|
+
config.around :each do |example|
|
20
|
+
DatabaseCleaner.cleaning do
|
21
|
+
example.run
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
ENV["RACK_ENV"] = "test"
|
2
|
+
|
3
|
+
require "byebug"
|
4
|
+
|
5
|
+
SPEC_ROOT = Pathname(__FILE__).dirname
|
6
|
+
|
7
|
+
Dir[SPEC_ROOT.join("support/*.rb").to_s].each(&method(:require))
|
8
|
+
Dir[SPEC_ROOT.join("shared/*.rb").to_s].each(&method(:require))
|
9
|
+
|
10
|
+
require SPEC_ROOT.join("../system/<%= config[:underscored_app_name] %>/container")
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.disable_monkey_patching!
|
14
|
+
|
15
|
+
config.expect_with :rspec do |expectations|
|
16
|
+
# This option will default to `true` in RSpec 4.
|
17
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
18
|
+
end
|
19
|
+
|
20
|
+
config.mock_with :rspec do |mocks|
|
21
|
+
# Prevents you from mocking or stubbing a method that does not exist on a
|
22
|
+
# real object. This is generally recommended, and will default to `true`
|
23
|
+
# in RSpec 4.
|
24
|
+
mocks.verify_partial_doubles = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# These two settings work together to allow you to limit a spec run to
|
28
|
+
# individual examples or groups you care about by tagging them with `:focus`
|
29
|
+
# metadata. When nothing is tagged with `:focus`, all examples get run.
|
30
|
+
config.filter_run :focus
|
31
|
+
config.run_all_when_everything_filtered = true
|
32
|
+
|
33
|
+
# Allows RSpec to persist some state between runs in order to support the
|
34
|
+
# `--only-failures` and `--next-failure` CLI options.
|
35
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
36
|
+
|
37
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
38
|
+
# file, and it's useful to allow more verbose output when running an
|
39
|
+
# individual spec file.
|
40
|
+
if config.files_to_run.one?
|
41
|
+
# Use the documentation formatter for detailed output, unless a formatter
|
42
|
+
# has already been configured (e.g. via a command-line flag).
|
43
|
+
config.default_formatter = "doc"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Print the 10 slowest examples and example groups at the end of the spec
|
47
|
+
# run, to help surface which specs are running particularly slow.
|
48
|
+
config.profile_examples = 10
|
49
|
+
|
50
|
+
# Run specs in random order to surface order dependencies. If you find an
|
51
|
+
# order dependency and want to debug it, you can fix the order by providing
|
52
|
+
# the seed, which is printed after each run.
|
53
|
+
# --seed 1234
|
54
|
+
config.order = :random
|
55
|
+
|
56
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
57
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
58
|
+
# test failures related to randomization by passing the same `--seed` value
|
59
|
+
# as the one that triggered the failure.
|
60
|
+
Kernel.srand config.seed
|
61
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TestHelpers
|
2
|
+
module_function
|
3
|
+
|
4
|
+
def app
|
5
|
+
<%= config[:camel_cased_app_name] %>::Application.app
|
6
|
+
end
|
7
|
+
|
8
|
+
def rom
|
9
|
+
<%= config[:camel_cased_app_name] %>::Container["persistence.rom"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def db_connection
|
13
|
+
rom.gateways[:default].connection
|
14
|
+
end
|
15
|
+
end
|
data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/application.rb.tt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "dry/web/roda/application"
|
2
|
+
require_relative "container"
|
3
|
+
|
4
|
+
module <%= config[:camel_cased_app_name] %>
|
5
|
+
class Application < Dry::Web::Roda::Application
|
6
|
+
configure do |config|
|
7
|
+
config.container = Container
|
8
|
+
end
|
9
|
+
|
10
|
+
route do |r|
|
11
|
+
r.run Main::Application.freeze.app
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/settings.rb.tt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "dry/web/settings"
|
2
|
+
require "dry-types"
|
3
|
+
|
4
|
+
module <%= config[:camel_cased_app_name] %>
|
5
|
+
class Settings < Dry::Web::Settings
|
6
|
+
module Types
|
7
|
+
include Dry::Types.module
|
8
|
+
|
9
|
+
module Required
|
10
|
+
String = Types::Strict::String.constrained(min_size: 1)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
setting :database_url, Types::Required::String
|
15
|
+
setting :session_secret, Types::Required::String
|
16
|
+
end
|
17
|
+
end
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= config[:camel_cased_app_name] %>::Container.namespace "persistence" do |persistence|
|
2
|
+
persistence.finalize(:rom) do
|
3
|
+
init do
|
4
|
+
require "sequel"
|
5
|
+
require "rom"
|
6
|
+
|
7
|
+
Sequel.database_timezone = :utc
|
8
|
+
Sequel.application_timezone = :local
|
9
|
+
|
10
|
+
rom_config = ROM::Configuration.new(
|
11
|
+
:sql,
|
12
|
+
persistence.settings.database_url,
|
13
|
+
extensions: [:error_sql]
|
14
|
+
)
|
15
|
+
|
16
|
+
persistence.register("config", rom_config)
|
17
|
+
end
|
18
|
+
|
19
|
+
start do
|
20
|
+
config = persistence["persistence.config"]
|
21
|
+
config.auto_registration(persistence.root.join("lib/persistence"))
|
22
|
+
|
23
|
+
persistence.register("rom", ROM.container(config))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/dry/web/roda/version.rb
CHANGED
data/script/ci
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
|
5
|
+
setup() {
|
6
|
+
./script/setup
|
7
|
+
}
|
8
|
+
|
9
|
+
teardown() {
|
10
|
+
./script/teardown
|
11
|
+
}
|
12
|
+
|
13
|
+
run_all() {
|
14
|
+
bundle exec rake
|
15
|
+
}
|
16
|
+
|
17
|
+
run_unit_tests() {
|
18
|
+
bundle exec rake spec:coverage
|
19
|
+
}
|
20
|
+
|
21
|
+
run_isolation_tests() {
|
22
|
+
local pwd=$PWD
|
23
|
+
local root="$pwd/spec/isolation"
|
24
|
+
|
25
|
+
run_tests $root
|
26
|
+
}
|
27
|
+
|
28
|
+
run_integration_tests() {
|
29
|
+
local pwd=$PWD
|
30
|
+
local root="$pwd/spec/integration"
|
31
|
+
|
32
|
+
run_tests $root
|
33
|
+
}
|
34
|
+
|
35
|
+
run_tests() {
|
36
|
+
local root=$1
|
37
|
+
|
38
|
+
for test in $(find $root -name '*_spec.rb')
|
39
|
+
do
|
40
|
+
run_test $test
|
41
|
+
|
42
|
+
if [ $? -ne 0 ]; then
|
43
|
+
local exit_code=$?
|
44
|
+
echo "Failing test: $test"
|
45
|
+
exit $exit_code
|
46
|
+
fi
|
47
|
+
done
|
48
|
+
}
|
49
|
+
|
50
|
+
run_test() {
|
51
|
+
local test=$1
|
52
|
+
|
53
|
+
printf "\n\n\nRunning: $test\n"
|
54
|
+
COVERAGE=true bundle exec rspec $test
|
55
|
+
}
|
56
|
+
|
57
|
+
main() {
|
58
|
+
setup &&
|
59
|
+
run_all
|
60
|
+
# run_unit_tests &&
|
61
|
+
# run_isolation_tests &&
|
62
|
+
# run_integration_tests
|
63
|
+
}
|
64
|
+
|
65
|
+
trap teardown EXIT
|
66
|
+
|
67
|
+
main
|
data/script/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
|
5
|
+
declare pwd=$PWD
|
6
|
+
declare cache="$pwd/vendor/cache"
|
7
|
+
|
8
|
+
cleanup() {
|
9
|
+
./script/teardown
|
10
|
+
}
|
11
|
+
|
12
|
+
bundle_package() {
|
13
|
+
bundle package --all
|
14
|
+
echo ""
|
15
|
+
}
|
16
|
+
|
17
|
+
# We may need something like this in future if we use github checkouts of gems
|
18
|
+
# (see `install_hanami_frameworks()` in hanami/hanami's setup script)
|
19
|
+
#
|
20
|
+
# install_from_git_checkouts() { }
|
21
|
+
|
22
|
+
install_base_gem() {
|
23
|
+
bundle exec rake build
|
24
|
+
local pkg=`ls $pwd/pkg/*.gem | sort -r | head -1`
|
25
|
+
|
26
|
+
gem install $pkg > /dev/null
|
27
|
+
mv $pkg $cache
|
28
|
+
|
29
|
+
echo "Installed $pkg (from $(git rev-parse HEAD))"
|
30
|
+
echo ""
|
31
|
+
}
|
32
|
+
|
33
|
+
generate_index() {
|
34
|
+
pushd $cache > /dev/null
|
35
|
+
gem generate_index
|
36
|
+
popd > /dev/null
|
37
|
+
echo ""
|
38
|
+
}
|
39
|
+
|
40
|
+
main() {
|
41
|
+
cleanup &&
|
42
|
+
bundle_package &&
|
43
|
+
install_base_gem &&
|
44
|
+
generate_index
|
45
|
+
}
|
46
|
+
|
47
|
+
main
|
data/script/teardown
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
|
5
|
+
remove_bundler_cache() {
|
6
|
+
local pwd=$PWD
|
7
|
+
local cache="$pwd/vendor/cache"
|
8
|
+
|
9
|
+
rm -rf $cache
|
10
|
+
}
|
11
|
+
|
12
|
+
# We may need something like this in future if we use github checkouts of gems
|
13
|
+
# (see `uninstall_hanami_gems()` in hanami/hanami's teardown script)
|
14
|
+
#
|
15
|
+
# uninstall_gems_from_checkouts() { }
|
16
|
+
|
17
|
+
bundle_install() {
|
18
|
+
bundle install > /dev/null
|
19
|
+
}
|
20
|
+
|
21
|
+
advertise_start() {
|
22
|
+
echo -en "Cleaning up.."
|
23
|
+
}
|
24
|
+
|
25
|
+
advertise_end() {
|
26
|
+
echo " done"
|
27
|
+
}
|
28
|
+
|
29
|
+
main() {
|
30
|
+
local ci=${CI:-false}
|
31
|
+
|
32
|
+
if [ "$ci" = true ] ; then
|
33
|
+
echo "Running on CI, skipping cleanup"
|
34
|
+
else
|
35
|
+
advertise_start &&
|
36
|
+
remove_bundler_cache &&
|
37
|
+
bundle_install &&
|
38
|
+
advertise_end
|
39
|
+
fi
|
40
|
+
}
|
41
|
+
|
42
|
+
main
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec.describe "new app", type: :cli do
|
2
|
+
describe "umbrella project" do
|
3
|
+
it "boots and displays a welcome page" do
|
4
|
+
with_project do
|
5
|
+
run_app do |app|
|
6
|
+
expect(app.get("/")).to eq "<html><body><h1>Welcome to dry-web-roda!</h1></body></html>"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "flat project" do
|
13
|
+
it "boots and displays a welcome page" do
|
14
|
+
with_project arch: "flat" do
|
15
|
+
run_app do |app|
|
16
|
+
expect(app.get("/")).to eq "<html><body><h1>Welcome to dry-web-roda!</h1></body></html>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
|
1
|
+
require "byebug"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
SPEC_ROOT = Pathname(__dir__)
|
4
|
+
TEST_APP_NAME = "test_app".freeze
|
5
|
+
|
6
|
+
Dir[SPEC_ROOT.join("support/*.rb").to_s].each { |f| require f }
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
rescue LoadError; end
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.disable_monkey_patching!
|
11
10
|
|
12
|
-
|
13
|
-
require 'rack/test'
|
14
|
-
require 'slim'
|
11
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
15
12
|
|
16
|
-
|
13
|
+
config.filter_run :focus
|
14
|
+
config.run_all_when_everything_filtered = true
|
17
15
|
|
18
|
-
|
16
|
+
config.default_formatter = "doc" if config.files_to_run.one?
|
19
17
|
|
20
|
-
|
21
|
-
config.disable_monkey_patching!
|
18
|
+
config.profile_examples = 10
|
22
19
|
|
23
|
-
config.
|
20
|
+
config.order = :random
|
21
|
+
Kernel.srand config.seed
|
24
22
|
end
|