dry-web-roda 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/CONTRIBUTING.md +29 -0
  4. data/Gemfile +4 -3
  5. data/README.md +1 -1
  6. data/dry-web-roda.gemspec +0 -2
  7. data/lib/dry/web/roda/cli.rb +2 -2
  8. data/lib/dry/web/roda/cli/generate.rb +1 -1
  9. data/lib/dry/web/roda/generate.rb +32 -34
  10. data/lib/dry/web/roda/generators/abstract_generator.rb +54 -0
  11. data/lib/dry/web/roda/generators/abstract_project.rb +118 -0
  12. data/lib/dry/web/roda/generators/flat_project.rb +20 -14
  13. data/lib/dry/web/roda/generators/sub_app.rb +34 -13
  14. data/lib/dry/web/roda/generators/umbrella_project.rb +10 -19
  15. data/lib/dry/web/roda/templates/.env.test.tt +1 -0
  16. data/lib/dry/web/roda/templates/.env.tt +2 -0
  17. data/lib/dry/web/roda/templates/.gitignore +8 -0
  18. data/lib/dry/web/roda/{skeletons/flat_project/lib/__underscored_app_name__ → templates}/.keep +0 -0
  19. data/lib/dry/web/roda/templates/.rspec +2 -0
  20. data/lib/dry/web/roda/{skeletons/flat_project → templates}/Gemfile +4 -3
  21. data/lib/dry/web/roda/{skeletons/umbrella_project → templates}/README.md.tt +2 -2
  22. data/lib/dry/web/roda/templates/Rakefile.tt +66 -0
  23. data/lib/dry/web/roda/{skeletons/flat_project/web/templates/layouts → templates}/application.html.slim +0 -0
  24. data/lib/dry/web/roda/templates/boot__settings.rb.tt +10 -0
  25. data/lib/dry/web/roda/{skeletons/flat_project → templates}/config.ru.tt +0 -0
  26. data/lib/dry/web/roda/{skeletons/flat_project/bin → templates}/console.tt +0 -0
  27. data/lib/dry/web/roda/templates/container.rb.tt +14 -0
  28. data/lib/dry/web/roda/{skeletons/flat_project/web/routes/example.rb.tt → templates/example_routes.rb.tt} +0 -0
  29. data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates/flat_project}/application.rb.tt +6 -1
  30. data/lib/dry/web/roda/templates/flat_project/boot.rb.tt +10 -0
  31. data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates}/import.rb.tt +0 -0
  32. data/lib/dry/web/roda/{skeletons/flat_project/system/boot → templates}/monitor.rb.tt +0 -0
  33. data/lib/dry/web/roda/templates/operation.rb.tt +9 -0
  34. data/lib/dry/web/roda/{skeletons/flat_project/system/__underscored_app_name__ → templates}/repository.rb.tt +4 -2
  35. data/lib/dry/web/roda/templates/rom.rb.tt +39 -0
  36. data/lib/dry/web/roda/{skeletons/flat_project/db → templates}/sample_data.rb +0 -0
  37. data/lib/dry/web/roda/{skeletons/flat_project/db → templates}/seed.rb +0 -0
  38. data/lib/dry/web/roda/templates/settings.rb.tt +9 -0
  39. data/lib/dry/web/roda/{skeletons/flat_project/bin → templates}/setup +0 -0
  40. data/lib/dry/web/roda/{skeletons/umbrella_project/spec/db_helper.rb.tt → templates/spec/db_spec_helper.rb.tt} +2 -3
  41. data/lib/dry/web/roda/templates/spec/factories/example.rb +9 -0
  42. data/lib/dry/web/roda/{skeletons/flat_project → templates}/spec/spec_helper.rb.tt +1 -1
  43. data/lib/dry/web/roda/templates/spec/support/db/factory.rb +8 -0
  44. data/lib/dry/web/roda/templates/spec/support/db/helpers.rb.tt +13 -0
  45. data/lib/dry/web/roda/templates/spec/support/web/helpers.rb.tt +9 -0
  46. data/lib/dry/web/roda/{skeletons/umbrella_project/spec/app_helper.rb → templates/spec/web_spec_helper.rb} +8 -6
  47. data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/application.rb.tt +6 -1
  48. data/lib/dry/web/roda/templates/subapp/boot.rb.tt +5 -0
  49. data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/container.rb.tt +6 -9
  50. data/lib/dry/web/roda/{skeletons/sub_app/system/__underscored_app_name__ → templates/subapp}/transactions.rb.tt +2 -3
  51. data/lib/dry/web/roda/templates/subapp/view_context.rb.tt +8 -0
  52. data/lib/dry/web/roda/templates/subapp/view_controller.rb.tt +17 -0
  53. data/lib/dry/web/roda/{skeletons/flat_project/lib → templates}/types.rb +0 -0
  54. data/lib/dry/web/roda/{skeletons/umbrella_project/system/__underscored_app_name__ → templates/umbrella_project}/application.rb.tt +6 -1
  55. data/lib/dry/web/roda/templates/umbrella_project/boot.rb.tt +16 -0
  56. data/lib/dry/web/roda/templates/view_context.rb.tt +43 -0
  57. data/lib/dry/web/roda/templates/view_controller.rb.tt +17 -0
  58. data/lib/dry/web/roda/{skeletons/flat_project/web/templates → templates}/welcome.html.slim +0 -0
  59. data/lib/dry/web/roda/{skeletons/flat_project/lib/__underscored_app_name__/views → templates}/welcome.rb.tt +2 -2
  60. data/lib/dry/web/roda/version.rb +1 -1
  61. data/lib/roda/plugins/dry_view.rb +1 -1
  62. data/spec/support/project.rb +1 -1
  63. metadata +51 -116
  64. data/lib/dry/web/roda/skeletons/flat_project/README.md.tt +0 -12
  65. data/lib/dry/web/roda/skeletons/flat_project/Rakefile.tt +0 -81
  66. data/lib/dry/web/roda/skeletons/flat_project/config/settings.yml.tt +0 -8
  67. data/lib/dry/web/roda/skeletons/flat_project/lib/persistence/commands/.keep +0 -0
  68. data/lib/dry/web/roda/skeletons/flat_project/lib/persistence/relations/.keep +0 -0
  69. data/lib/dry/web/roda/skeletons/flat_project/log/.keep +0 -0
  70. data/lib/dry/web/roda/skeletons/flat_project/spec/app_helper.rb +0 -35
  71. data/lib/dry/web/roda/skeletons/flat_project/spec/db_helper.rb.tt +0 -24
  72. data/lib/dry/web/roda/skeletons/flat_project/spec/support/db/test_factories.rb +0 -3
  73. data/lib/dry/web/roda/skeletons/flat_project/spec/support/test_helpers.rb.tt +0 -15
  74. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/container.rb.tt +0 -23
  75. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/settings.rb.tt +0 -17
  76. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/transactions.rb.tt +0 -34
  77. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_context.rb.tt +0 -39
  78. data/lib/dry/web/roda/skeletons/flat_project/system/__underscored_app_name__/view_controller.rb.tt +0 -13
  79. data/lib/dry/web/roda/skeletons/flat_project/system/boot.rb.tt +0 -11
  80. data/lib/dry/web/roda/skeletons/flat_project/system/boot/rom.rb.tt +0 -32
  81. data/lib/dry/web/roda/skeletons/flat_project/system/boot/view.rb.tt +0 -3
  82. data/lib/dry/web/roda/skeletons/flat_project/transactions/example.rb.tt +0 -10
  83. data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/.keep +0 -0
  84. data/lib/dry/web/roda/skeletons/sub_app/lib/__underscored_app_name__/views/welcome.rb.tt +0 -11
  85. data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/import.rb.tt +0 -5
  86. data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_context.rb.tt +0 -6
  87. data/lib/dry/web/roda/skeletons/sub_app/system/__underscored_app_name__/view_controller.rb.tt +0 -13
  88. data/lib/dry/web/roda/skeletons/sub_app/system/boot.rb.tt +0 -8
  89. data/lib/dry/web/roda/skeletons/sub_app/system/boot/view.rb.tt +0 -3
  90. data/lib/dry/web/roda/skeletons/sub_app/transactions/example.rb.tt +0 -9
  91. data/lib/dry/web/roda/skeletons/sub_app/web/routes/example.rb.tt +0 -7
  92. data/lib/dry/web/roda/skeletons/sub_app/web/templates/layouts/application.html.slim +0 -3
  93. data/lib/dry/web/roda/skeletons/sub_app/web/templates/welcome.html.slim +0 -1
  94. data/lib/dry/web/roda/skeletons/umbrella_project/.gitignore +0 -8
  95. data/lib/dry/web/roda/skeletons/umbrella_project/Gemfile +0 -40
  96. data/lib/dry/web/roda/skeletons/umbrella_project/Rakefile.tt +0 -81
  97. data/lib/dry/web/roda/skeletons/umbrella_project/bin/console.tt +0 -7
  98. data/lib/dry/web/roda/skeletons/umbrella_project/bin/setup +0 -7
  99. data/lib/dry/web/roda/skeletons/umbrella_project/config.ru.tt +0 -2
  100. data/lib/dry/web/roda/skeletons/umbrella_project/config/settings.yml.tt +0 -8
  101. data/lib/dry/web/roda/skeletons/umbrella_project/db/sample_data.rb +0 -1
  102. data/lib/dry/web/roda/skeletons/umbrella_project/db/seed.rb +0 -1
  103. data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/repository.rb.tt +0 -11
  104. data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/transactions.rb.tt +0 -33
  105. data/lib/dry/web/roda/skeletons/umbrella_project/lib/__underscored_app_name__/view_context.rb.tt +0 -39
  106. data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/commands/.keep +0 -0
  107. data/lib/dry/web/roda/skeletons/umbrella_project/lib/persistence/relations/.keep +0 -0
  108. data/lib/dry/web/roda/skeletons/umbrella_project/lib/types.rb +0 -6
  109. data/lib/dry/web/roda/skeletons/umbrella_project/log/.keep +0 -0
  110. data/lib/dry/web/roda/skeletons/umbrella_project/spec/spec_helper.rb.tt +0 -61
  111. data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/db/test_factories.rb +0 -3
  112. data/lib/dry/web/roda/skeletons/umbrella_project/spec/support/test_helpers.rb.tt +0 -15
  113. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/container.rb.tt +0 -18
  114. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/import.rb.tt +0 -5
  115. data/lib/dry/web/roda/skeletons/umbrella_project/system/__underscored_app_name__/settings.rb.tt +0 -17
  116. data/lib/dry/web/roda/skeletons/umbrella_project/system/boot.rb.tt +0 -12
  117. data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/monitor.rb.tt +0 -9
  118. data/lib/dry/web/roda/skeletons/umbrella_project/system/boot/rom.rb.tt +0 -32
@@ -1,36 +1,27 @@
1
1
  require "securerandom"
2
- require "dry/web/roda/generate"
3
- require "dry/web/roda/generators/inflections"
2
+ require "dry/web/roda/generators/abstract_project"
4
3
  require "dry/web/roda/generators/sub_app"
5
4
 
6
5
  module Dry
7
6
  module Web
8
7
  module Roda
9
8
  module Generators
10
- class UmbrellaProject
11
- attr_reader :generate, :sub_app_generator
9
+ class UmbrellaProject < AbstractProject
10
+ private
12
11
 
13
- def initialize
14
- @generate = Generate.new("umbrella_project")
15
- @sub_app_generator = Generators::SubApp.new
12
+ def add_boot
13
+ add_template("umbrella_project/boot.rb.tt", "system/boot.rb")
16
14
  end
17
15
 
18
- def call(target_dir)
19
- generate.(target_dir, prepare_scope(target_dir))
16
+ def add_application
17
+ add_template("umbrella_project/application.rb.tt", "system/#{underscored_project_name}/application.rb")
18
+ end
20
19
 
20
+ def post_process_callback
21
21
  Dir.chdir(target_dir) do
22
- sub_app_generator.("main", umbrella: target_dir)
22
+ Generators::SubApp.new("main", umbrella: target_dir).call
23
23
  end
24
24
  end
25
-
26
- private
27
-
28
- def prepare_scope(target_dir)
29
- {
30
- underscored_app_name: Inflections.underscored_name(target_dir),
31
- camel_cased_app_name: Inflections.camel_cased_name(target_dir)
32
- }
33
- end
34
25
  end
35
26
  end
36
27
  end
@@ -0,0 +1 @@
1
+ DATABASE_URL='postgres://localhost/<%= config[:underscored_project_name] %>_test'
@@ -0,0 +1,2 @@
1
+ DATABASE_URL='postgres://localhost/<%= config[:underscored_project_name] %>_development'
2
+ SESSION_SECRET='<%= SecureRandom.hex %>'
@@ -0,0 +1,8 @@
1
+ # Ignore app settings (copy to .example.env.* to check in example files)
2
+ /.env*
3
+
4
+ # RSpec
5
+ /spec/examples.txt
6
+
7
+ # Logs
8
+ /log/*.log
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -3,7 +3,8 @@ source "https://rubygems.org"
3
3
  gem "rake"
4
4
 
5
5
  # Web framework
6
- gem "dry-web", ">= 0.6.0"
6
+ gem "dry-system", ">= 0.7.1"
7
+ gem "dry-web", ">= 0.7.0"
7
8
  gem "dry-web-roda", ">= 0.6.0"
8
9
  gem "puma"
9
10
  gem "rack_csrf"
@@ -21,10 +22,10 @@ gem "rom-sql", ">= 1.1.0"
21
22
  gem "dry-matcher"
22
23
  gem "dry-monads"
23
24
  gem "dry-struct"
24
- gem "dry-transaction"
25
+ gem "dry-transaction", ">= 0.10.0"
25
26
  gem "dry-types"
26
27
  gem "dry-validation"
27
- gem "dry-view", ">= 0.2.2"
28
+ gem "dry-view", ">= 0.3.0"
28
29
  gem "slim"
29
30
 
30
31
  group :development, :test do
@@ -5,8 +5,8 @@ Welcome! You’ve generated an app using dry-web-roda.
5
5
  ## First steps
6
6
 
7
7
  1. Run `bundle`
8
- 1. Review `config/settings.yml` (and make a copy at `config/settings.example.yml` if you want to keep example settings checked in)
9
- 1. Create a `<%= config[:underscored_app_name] %>_development` database
8
+ 1. Review `.env` & `.env.test` (and make a copy to e.g. `.example.env` if you want example settings checked in)
9
+ 1. Create a `blog_development` database
10
10
  1. Add your own steps to `bin/setup`
11
11
  1. Run the app with `bundle exec shotgun -p 3000 -o 0.0.0.0 config.ru`
12
12
  1. Initialize git with `git init` and make your initial commit
@@ -0,0 +1,66 @@
1
+ require "bundler/setup"
2
+ require "byebug" unless ENV["RACK_ENV"] == "production"
3
+ require "rom/sql/rake_task"
4
+ require "shellwords"
5
+ require_relative "system/<%= config[:underscored_project_name] %>/container"
6
+
7
+ begin
8
+ require "rspec/core/rake_task"
9
+ RSpec::Core::RakeTask.new :spec
10
+ task default: [:spec]
11
+ rescue LoadError
12
+ end
13
+
14
+ def db
15
+ <%= config[:camel_cased_app_name] %>::Container["persistence.db"]
16
+ end
17
+
18
+ namespace :db do
19
+ task :setup do
20
+ <%= config[:camel_cased_app_name] %>::Container.boot :rom
21
+ end
22
+
23
+ desc "Prints current schema version"
24
+ task version: :setup do
25
+ version =
26
+ if db.tables.include?(:schema_migrations)
27
+ db[:schema_migrations].order(:filename).last[:filename]
28
+ else
29
+ "not available"
30
+ end
31
+
32
+ puts "Current schema version: #{version}"
33
+ end
34
+
35
+ desc "Perform migration up to latest migration available"
36
+ task :migrate do
37
+ # Enhance the migration task provided by ROM
38
+
39
+ # Once it finishes, dump the db structure
40
+ Rake::Task["db:structure:dump"].execute
41
+
42
+ # And print the current migration version
43
+ Rake::Task["db:version"].execute
44
+ end
45
+
46
+ namespace :structure do
47
+ desc "Dump database structure to db/structure.sql"
48
+ task :dump do
49
+ if system("which pg_dump", out: File::NULL)
50
+ system(%(pg_dump -s -x -O #{Shellwords.escape(db.url)} > db/structure.sql))
51
+ end
52
+ end
53
+ end
54
+
55
+ desc "Load seed data into the database"
56
+ task :seed do
57
+ seed_data = File.join("db", "seed.rb")
58
+ load(seed_data) if File.exist?(seed_data)
59
+ end
60
+
61
+ desc "Load a small, representative set of data so that the application can start in a useful state (for development)."
62
+ task :sample_data do
63
+ sample_data = File.join("db", "sample_data.rb")
64
+ load(sample_data) if File.exist?(sample_data)
65
+ end
66
+ end
@@ -0,0 +1,10 @@
1
+ <%= config[:camel_cased_app_name] %>::Container.finalize :settings do |container|
2
+ init do
3
+ require "<%= config[:underscored_project_name] %>/settings"
4
+ end
5
+
6
+ start do
7
+ settings = <%= config[:camel_cased_app_name] %>::Settings.load(container.config.root, container.config.env)
8
+ container.register "settings", settings
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ require "dry/web/container"
2
+
3
+ module <%= config[:camel_cased_app_name] %>
4
+ class Container < Dry::Web::Container
5
+ configure do
6
+ config.name = :<%= config[:underscored_project_name] %>
7
+ config.listeners = true
8
+ config.default_namespace = "<%= config[:underscored_project_name] %>"
9
+ config.auto_register = %w[lib/<%= config[:underscored_project_name] %>]
10
+ end
11
+
12
+ load_paths! "lib"
13
+ end
14
+ end
@@ -10,7 +10,7 @@ module <%= config[:camel_cased_app_name] %>
10
10
 
11
11
  opts[:root] = Pathname(__FILE__).join("../..").realpath.dirname
12
12
 
13
- use Rack::Session::Cookie, key: "<%= config[:underscored_app_name] %>.session", secret: <%= config[:camel_cased_app_name] %>::Container.settings.session_secret
13
+ use Rack::Session::Cookie, key: "<%= config[:underscored_project_name] %>.session", secret: self["settings"].session_secret
14
14
 
15
15
  plugin :csrf, raise: true
16
16
  plugin :flash
@@ -24,6 +24,11 @@ module <%= config[:camel_cased_app_name] %>
24
24
  end
25
25
  end
26
26
 
27
+ error do |e|
28
+ self.class[:rack_monitor].instrument(:error, exception: e)
29
+ raise e
30
+ end
31
+
27
32
  load_routes!
28
33
  end
29
34
  end
@@ -0,0 +1,10 @@
1
+ begin
2
+ require "pry-byebug"
3
+ rescue LoadError
4
+ end
5
+
6
+ require_relative "<%= config[:underscored_project_name] %>/container"
7
+
8
+ <%= config[:camel_cased_app_name] %>::Container.finalize!
9
+
10
+ require "<%= config[:underscored_project_name] %>/application"
@@ -0,0 +1,9 @@
1
+ # auto_register: false
2
+
3
+ require "dry/transaction/operation"
4
+
5
+ module <%= config[:camel_cased_app_name] %>
6
+ class Operation
7
+ include Dry::Transaction::Operation
8
+ end
9
+ end
@@ -1,6 +1,8 @@
1
+ # auto_register: false
2
+
1
3
  require "rom-repository"
2
- require "<%= config[:underscored_app_name] %>/container"
3
- require "<%= config[:underscored_app_name] %>/import"
4
+ require "<%= config[:underscored_project_name] %>/container"
5
+ require "<%= config[:underscored_project_name] %>/import"
4
6
 
5
7
  <%= config[:camel_cased_app_name] %>::Container.boot! :rom
6
8
 
@@ -0,0 +1,39 @@
1
+ <%= config[:camel_cased_app_name] %>::Container.namespace "persistence" do |container|
2
+ container.finalize :rom do
3
+ init do
4
+ require "sequel"
5
+ require "rom"
6
+ require "rom/sql"
7
+
8
+ use :settings
9
+ use :monitor
10
+
11
+ ROM::SQL.load_extensions :postgres
12
+
13
+ Sequel.database_timezone = :utc
14
+ Sequel.application_timezone = :local
15
+
16
+ rom_config = ROM::Configuration.new(
17
+ :sql,
18
+ container["settings"].database_url,
19
+ extensions: %i[error_sql pg_array pg_json],
20
+ )
21
+
22
+ rom_config.plugin :sql, relations: :instrumentation do |plugin_config|
23
+ plugin_config.notifications = notifications
24
+ end
25
+
26
+ rom_config.plugin :sql, relations: :auto_restrictions
27
+
28
+ container.register "config", rom_config
29
+ container.register "db", rom_config.gateways[:default].connection
30
+ end
31
+
32
+ start do
33
+ config = container["persistence.config"]
34
+ config.auto_registration container.root.join("lib/persistence")
35
+
36
+ container.register "rom", ROM.container(config)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ require "dry/web/settings"
2
+ require "types"
3
+
4
+ module <%= config[:camel_cased_app_name] %>
5
+ class Settings < Dry::Web::Settings
6
+ setting :database_url, Types::Strict::String.constrained(filled: true)
7
+ setting :session_secret, Types::Strict::String.constrained(filled: true)
8
+ end
9
+ end
@@ -6,11 +6,10 @@ Dir[SPEC_ROOT.join("support/db/*.rb").to_s].each(&method(:require))
6
6
  Dir[SPEC_ROOT.join("shared/db/*.rb").to_s].each(&method(:require))
7
7
 
8
8
  require "database_cleaner"
9
- DatabaseCleaner[:sequel, connection: TestHelpers.db_connection].strategy = :truncation
9
+ DatabaseCleaner[:sequel, connection: Test::DatabaseHelpers.db].strategy = :truncation
10
10
 
11
11
  RSpec.configure do |config|
12
- config.include TestHelpers
13
- config.include TestFactories
12
+ config.include Test::DatabaseHelpers
14
13
 
15
14
  config.before :suite do
16
15
  DatabaseCleaner.clean_with :truncation
@@ -0,0 +1,9 @@
1
+ # Define your factories here, e.g.
2
+ #
3
+ # Factory.define :article do |f|
4
+ # f.sequence(:slug) { |i| "article-#{i}" }
5
+ # f.title { fake(:lorem, :words, 5) }
6
+ # f.body { fake(:lorem, :paragraphs, 1) }
7
+ # end
8
+ #
9
+ # See https://github.com/rom-rb/rom-factory for more.
@@ -7,7 +7,7 @@ SPEC_ROOT = Pathname(__FILE__).dirname
7
7
  Dir[SPEC_ROOT.join("support/*.rb").to_s].each(&method(:require))
8
8
  Dir[SPEC_ROOT.join("shared/*.rb").to_s].each(&method(:require))
9
9
 
10
- require SPEC_ROOT.join("../system/<%= config[:underscored_app_name] %>/container")
10
+ require SPEC_ROOT.join("../system/<%= config[:underscored_project_name] %>/container")
11
11
 
12
12
  RSpec.configure do |config|
13
13
  config.disable_monkey_patching!
@@ -0,0 +1,8 @@
1
+ require "rom-factory"
2
+ require_relative "helpers"
3
+
4
+ Factory = ROM::Factory.configure do |config|
5
+ config.rom = Test::DatabaseHelpers.rom
6
+ end
7
+
8
+ Dir[Pathname(__FILE__).dirname.join("../../factories/**/*.rb")].each(&method(:require))
@@ -0,0 +1,13 @@
1
+ module Test
2
+ module DatabaseHelpers
3
+ module_function
4
+
5
+ def rom
6
+ <%= config[:camel_cased_app_name] %>::Container["persistence.rom"]
7
+ end
8
+
9
+ def db
10
+ <%= config[:camel_cased_app_name] %>::Container["persistence.db"]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Test
2
+ module WebHelpers
3
+ module_function
4
+
5
+ def app
6
+ <%= config[:camel_cased_app_name] %>::Container::Application.app
7
+ end
8
+ end
9
+ end
@@ -1,16 +1,16 @@
1
- require_relative "db_helper"
1
+ require_relative "db_spec_helper"
2
2
 
3
3
  require "rack/test"
4
4
  require "capybara/rspec"
5
5
  require "capybara-screenshot/rspec"
6
6
  require "capybara/poltergeist"
7
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))
8
+ Dir[SPEC_ROOT.join("support/web/*.rb").to_s].each(&method(:require))
9
+ Dir[SPEC_ROOT.join("shared/web/*.rb").to_s].each(&method(:require))
10
10
 
11
11
  require SPEC_ROOT.join("../system/boot").realpath
12
12
 
13
- Capybara.app = TestHelpers.app
13
+ Capybara.app = Test::WebHelpers.app
14
14
  Capybara.server_port = 3001
15
15
  Capybara.save_and_open_page_path = "#{File.dirname(__FILE__)}/../tmp/capybara-screenshot"
16
16
  Capybara.javascript_driver = :poltergeist
@@ -21,15 +21,17 @@ Capybara.register_driver :poltergeist do |app|
21
21
  app,
22
22
  js_errors: false,
23
23
  phantomjs_logger: File.open(SPEC_ROOT.join("../log/phantomjs.log"), "w"),
24
- phantomjs_options: %w(--load-images=no)
24
+ phantomjs_options: %w(--load-images=no),
25
+ window_size: [1600, 768],
25
26
  )
26
27
  end
27
28
 
28
29
  RSpec.configure do |config|
29
30
  config.include Rack::Test::Methods, type: :request
30
31
  config.include Rack::Test::Methods, Capybara::DSL, type: :feature
32
+ config.include Test::WebHelpers
31
33
 
32
34
  config.before :suite do
33
- TestHelpers.app.freeze
35
+ Test::WebHelpers.app.freeze
34
36
  end
35
37
  end