eac_rails_gem_support 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3eceb1c1e7a910b9301a3fc7adcd793db7f75b705655f6faae463ee13440162
4
- data.tar.gz: e344a0569f787ea7a1e6fda11c78e827b1bd14eaf9319a9fa9cbf80a2a21d520
3
+ metadata.gz: 55d3693bb6833b88d52d73720341788e32bf2b706749f25f2d40ac45e03f16a2
4
+ data.tar.gz: 178f20bc771e1be0656247018697760c630feb80eda8d87247da6cfdbafa8184
5
5
  SHA512:
6
- metadata.gz: 37d2da075e11632aa9433f91ed0da8d48fc58773c8335b4f89c37839d9410e726c50a62d88ac22ffe4287505962c35dcb08b383d0d6fe30ef437f58a8bc41356
7
- data.tar.gz: 3695b465581a8edee371b6bb5747e8533dcb0bb52097c55450c1c3f3b9ac391bc92631f9a388f3b956e5a36d34c2b8e32a7c3bfcff2fa6b5fa93f3ec55d75d7e
6
+ metadata.gz: d60e41b95e70795601c1da806af14e29eeb81242448365a5bdca7041d343dc3b726d922c6543abbcc49b0d546057bae00cb6d8494ff6b375be6f44708af4f043
7
+ data.tar.gz: 8799c5121fb460c72c2ea1427aa768a1693ff2ac8e194df0231120a16a5bb2d78df72c7b3f4359ab7cbd91fb23cd0215a05c4cd48c7c10ef114eb8f7b82b7beb
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ require_sub __FILE__
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_templates/patches/object/template'
4
+
5
+ ::EacTemplates::Searcher.default.included_paths <<
6
+ ::File.expand_path('../../../../template', __dir__)
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_rails_gem_support/patches/object/template'
4
+ require 'eac_ruby_gems_utils/gem'
5
+ require 'eac_ruby_utils/core_ext'
6
+ require 'fileutils'
7
+
8
+ module EacRailsGemSupport
9
+ module Rspec
10
+ class AppendableRailsApp
11
+ enable_simple_cache
12
+ common_constructor :gem_dir, :append_dir, :target_dir, default: [nil] do
13
+ self.target_dir = (target_dir || ::Dir.mktmpdir).to_pathname
14
+ build
15
+ end
16
+
17
+ protected
18
+
19
+ def build
20
+ copy_app_base
21
+ copy_append_directory
22
+ database_migrate
23
+ end
24
+
25
+ def database_migrate
26
+ the_gem.bundle('exec', 'rake', 'db:migrate').chdir(target_dir).execute!
27
+ end
28
+
29
+ def copy_app_base
30
+ template.apply(self, target_dir)
31
+ end
32
+
33
+ def copy_append_directory
34
+ ::FileUtils.cp_r("#{append_dir}/.", target_dir)
35
+ end
36
+
37
+ def the_gem_uncached
38
+ ::EacRubyGemsUtils::Gem.new(gem_dir)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -9,6 +9,7 @@ module EacRailsGemSupport
9
9
  require_sub __FILE__, include_modules: true
10
10
 
11
11
  def self.extended(obj)
12
+ obj.singleton_class.include(::EacRubyUtils::SimpleCache)
12
13
  obj.setup_rails_env
13
14
  return unless obj.setup_rails_app
14
15
 
@@ -16,44 +17,6 @@ module EacRailsGemSupport
16
17
  obj.setup_capybara
17
18
  obj.setup_factory_bot
18
19
  end
19
-
20
- # @return [Pathname]
21
- def rails_app_path
22
- [
23
- app_root_path,
24
- app_root_path.join('spec', 'support', 'rails_app')
25
- ].find { |app_path| app_path.join('config', 'environment.rb').file? }
26
- end
27
-
28
- def fixtures_path
29
- [
30
- app_root_path.join('spec', 'fixtures'),
31
- app_root_path.join('test', 'fixtures')
32
- ].find(&:directory?)
33
- end
34
-
35
- def setup_rails_app
36
- return false unless rails_app_path
37
-
38
- require rails_app_path.join('config', 'environment').to_path
39
- ::ActiveRecord::Migrator.migrations_paths = [rails_app_path.join('db', 'migrate')]
40
- raise('The Rails environment is running in production mode!') if Rails.env.production?
41
-
42
- require 'rspec/rails'
43
- ::ActiveRecord::Migration.maintain_test_schema!
44
- true
45
- end
46
-
47
- def setup_fixtures
48
- rspec_config.use_transactional_fixtures = true
49
- fixtures_path.if_present do |v|
50
- rspec_config.fixture_path = v
51
- end
52
- end
53
-
54
- def setup_rails_env
55
- ENV['RAILS_ENV'] ||= 'test'
56
- end
57
20
  end
58
21
  end
59
22
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRailsGemSupport
6
+ module Rspec
7
+ module Setup
8
+ module Fixtures
9
+ def fixtures_path
10
+ [
11
+ app_root_path.join('spec', 'fixtures'),
12
+ app_root_path.join('test', 'fixtures')
13
+ ].find(&:directory?)
14
+ end
15
+
16
+ def setup_fixtures
17
+ rspec_config.use_transactional_fixtures = true
18
+ fixtures_path.if_present do |v|
19
+ rspec_config.fixture_path = v
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_rails_gem_support/rspec/appendable_rails_app'
4
+ require 'eac_ruby_utils'
5
+
6
+ module EacRailsGemSupport
7
+ module Rspec
8
+ module Setup
9
+ module RailsApp
10
+ def builded_rails_app_path
11
+ dir = app_root_path.join('spec', 'support', 'rails_app_append')
12
+ return nil unless dir.directory?
13
+
14
+ ::EacRailsGemSupport::Rspec::AppendableRailsApp.new(app_root_path, dir).target_dir
15
+ end
16
+
17
+ def existing_rails_app_path
18
+ [
19
+ app_root_path,
20
+ app_root_path.join('spec', 'support', 'rails_app')
21
+ ].find { |app_path| app_path.join('config', 'environment.rb').file? }
22
+ end
23
+
24
+ # @return [Pathname]
25
+ def rails_app_path_uncached
26
+ existing_rails_app_path || builded_rails_app_path
27
+ end
28
+
29
+ def setup_rails_app
30
+ return false unless rails_app_path
31
+
32
+ require rails_app_path.join('config', 'environment').to_path
33
+ ::ActiveRecord::Migrator.migrations_paths = [rails_app_path.join('db', 'migrate')]
34
+ raise('The Rails environment is running in production mode!') if Rails.env.production?
35
+
36
+ require 'rspec/rails'
37
+ ::ActiveRecord::Migration.maintain_test_schema!
38
+ true
39
+ end
40
+
41
+ def setup_rails_env
42
+ ENV['RAILS_ENV'] ||= 'test'
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsGemSupport
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require File.expand_path('config/application', __dir__)
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path('../config/application', __dir__)
5
+ require_relative '../config/boot'
6
+ require 'rails/commands'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is used by Rack-based servers to start the application.
4
+
5
+ require ::File.expand_path('../config/environment', __FILE__)
6
+ run Rails.application
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('boot', __dir__)
4
+
5
+ require 'rails/all'
6
+
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ config.active_record.raise_in_transactional_callbacks = true if ::Rails.version < '5'
12
+
13
+ config.action_mailer.default_url_options = { host: 'dummyhost' }
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
+
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ test:
2
+ adapter: sqlite3
3
+ pool: 5
4
+ timeout: 5000
5
+ database: db/test.sqlite3
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require File.expand_path('application', __dir__)
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ # Settings specified here will take precedence over those in config/application.rb.
5
+
6
+ # The test environment is used exclusively to run your application's
7
+ # test suite. You never need to work with it otherwise. Remember that
8
+ # your test database is "scratch space" for the test suite and is wiped
9
+ # and recreated between test runs. Don't rely on the data there!
10
+ config.cache_classes = true
11
+
12
+ # Do not eager load code on boot. This avoids loading your whole application
13
+ # just for the purpose of running a single test. If you are using a tool that
14
+ # preloads Rails for running tests, you may have to set it to true.
15
+ config.eager_load = false
16
+
17
+ # Configure static file server for tests with Cache-Control for performance.
18
+ config.serve_static_files = true
19
+ config.static_cache_control = 'public, max-age=3600'
20
+
21
+ # Show full error reports and disable caching.
22
+ config.consider_all_requests_local = true
23
+ config.action_controller.perform_caching = false
24
+
25
+ # Raise exceptions instead of rendering exception templates.
26
+ config.action_dispatch.show_exceptions = false
27
+
28
+ # Disable request forgery protection in test environment.
29
+ config.action_controller.allow_forgery_protection = false
30
+
31
+ # Tell Action Mailer not to deliver emails to the real world.
32
+ # The :test delivery method accumulates sent emails in the
33
+ # ActionMailer::Base.deliveries array.
34
+ config.action_mailer.delivery_method = :test
35
+
36
+ # Randomize the order test cases are executed.
37
+ config.active_support.test_order = :random
38
+
39
+ # Print deprecation notices to the stderr.
40
+ config.active_support.deprecation = :stderr
41
+
42
+ # Raises error for missing translations
43
+ # config.action_view.raise_on_missing_translations = true
44
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ resources :jobs do
5
+ collection do
6
+ get 'search'
7
+ end
8
+ end
9
+ resources :users
10
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 50d3bce23e309d961dafde3edfa89be2713718a5e2fb75b6c3e1f61826230921535243d2f221b8cecebeaceccb574a1e74fbbf3b89a9d53758ac988950f1753c
15
+
16
+ test:
17
+ secret_key_base: 75f37392ef7726b50b4ce117bd6a7eca7cdc299608e256f7ca163b14032559217364d41b7c091483ce02179a18c956f6e076331a611c0500f2862f83979a6c16
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_gem_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
@@ -44,6 +44,26 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 0.3.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: eac_ruby_gems_utils
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.9'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.9.5
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.9'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.9.5
47
67
  - !ruby/object:Gem::Dependency
48
68
  name: eac_ruby_utils
49
69
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +78,26 @@ dependencies:
58
78
  - - "~>"
59
79
  - !ruby/object:Gem::Version
60
80
  version: '0.74'
81
+ - !ruby/object:Gem::Dependency
82
+ name: eac_templates
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '0.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 0.1.1
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 0.1.1
61
101
  - !ruby/object:Gem::Dependency
62
102
  name: factory_bot_rails
63
103
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +112,20 @@ dependencies:
72
112
  - - ">="
73
113
  - !ruby/object:Gem::Version
74
114
  version: '0'
115
+ - !ruby/object:Gem::Dependency
116
+ name: rails
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 5.1.7
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: 5.1.7
75
129
  - !ruby/object:Gem::Dependency
76
130
  name: rspec-rails
77
131
  requirement: !ruby/object:Gem::Requirement
@@ -107,11 +161,27 @@ extensions: []
107
161
  extra_rdoc_files: []
108
162
  files:
109
163
  - lib/eac_rails_gem_support.rb
164
+ - lib/eac_rails_gem_support/patches/object.rb
165
+ - lib/eac_rails_gem_support/patches/object/template.rb
110
166
  - lib/eac_rails_gem_support/rspec.rb
167
+ - lib/eac_rails_gem_support/rspec/appendable_rails_app.rb
111
168
  - lib/eac_rails_gem_support/rspec/setup.rb
112
169
  - lib/eac_rails_gem_support/rspec/setup/capybara.rb
113
170
  - lib/eac_rails_gem_support/rspec/setup/factory_bot.rb
171
+ - lib/eac_rails_gem_support/rspec/setup/fixtures.rb
172
+ - lib/eac_rails_gem_support/rspec/setup/rails_app.rb
114
173
  - lib/eac_rails_gem_support/version.rb
174
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/Rakefile
175
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/app/assets/config/manifest.js
176
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/bin/rails
177
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config.ru
178
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/application.rb
179
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/boot.rb
180
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/database.yml
181
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/environment.rb
182
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/environments/test.rb
183
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/routes.rb
184
+ - template/eac_rails_gem_support/rspec/appendable_rails_app/config/secrets.yml
115
185
  homepage:
116
186
  licenses: []
117
187
  metadata: {}