mini-quick-sys 0.0.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.
- checksums.yaml +7 -0
- data/mini-quick-sys.gemspec +12 -0
- data/rspec-rails-8.0.4/Capybara.md +28 -0
- data/rspec-rails-8.0.4/Changelog.md +1408 -0
- data/rspec-rails-8.0.4/LICENSE.md +25 -0
- data/rspec-rails-8.0.4/README.md +386 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/authentication_generator.rb +25 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/templates/user_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/templates/users.yml +11 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/channel/channel_generator.rb +12 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/channel/templates/channel_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/controller_generator.rb +51 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/controller_spec.rb +16 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/request_spec.rb +19 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/routing_spec.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/view_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/feature_generator.rb +29 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/templates/feature_singular_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/templates/feature_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/generator/generator_generator.rb +24 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/generator/templates/generator_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/helper/helper_generator.rb +16 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/helper/templates/helper_spec.rb +17 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/install/install_generator.rb +80 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/install/templates/spec/rails_helper.rb +91 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/job/job_generator.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/job/templates/job_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailbox/mailbox_generator.rb +14 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailbox/templates/mailbox_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/mailer_generator.rb +30 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/fixture +3 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/mailer_spec.rb +25 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/preview.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/model_generator.rb +37 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/templates/fixtures.yml +19 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/templates/model_spec.rb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/request/request_generator.rb +17 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/request/templates/request_spec.rb +10 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/scaffold_generator.rb +136 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +129 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/controller_spec.rb +145 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/edit_spec.rb +27 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/index_spec.rb +26 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/new_spec.rb +22 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/request_spec.rb +138 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/routing_spec.rb +46 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/show_spec.rb +21 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/system/system_generator.rb +24 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/system/templates/system_spec.rb +9 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/view/templates/view_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/view/view_generator.rb +22 -0
- data/rspec-rails-8.0.4/lib/generators/rspec.rb +56 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/active_record.rb +25 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/adapters.rb +196 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/configuration.rb +158 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/channel_example_group.rb +93 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/controller_example_group.rb +217 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/feature_example_group.rb +53 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/helper_example_group.rb +42 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/job_example_group.rb +23 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/mailbox_example_group.rb +80 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/mailer_example_group.rb +38 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/model_example_group.rb +11 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/rails_example_group.rb +23 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/request_example_group.rb +27 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/routing_example_group.rb +61 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/system_example_group.rb +177 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/view_example_group.rb +214 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example.rb +13 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/extensions/active_record/proxy.rb +11 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/extensions.rb +1 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/feature_check.rb +51 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/file_fixture_support.rb +18 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/fixture_file_upload_support.rb +39 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/fixture_support.rb +58 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +180 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable/have_streams.rb +58 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable.rb +70 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_mailbox.rb +73 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/active_job.rb +534 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/base_matcher.rb +179 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_a_new.rb +83 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_new_record.rb +30 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_valid.rb +49 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_enqueued_mail.rb +259 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_http_status.rb +381 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_rendered.rb +64 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/redirect_to.rb +38 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/relation_match_array.rb +3 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/routing_matchers.rb +125 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/send_email.rb +122 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers.rb +36 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/tasks/rspec.rake +49 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/vendor/capybara.rb +32 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/version.rb +9 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_assigns.rb +27 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_path_builder.rb +29 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_rendering.rb +166 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_spec_methods.rb +56 -0
- data/rspec-rails-8.0.4/lib/rspec/rails.rb +18 -0
- data/rspec-rails-8.0.4/lib/rspec-rails.rb +91 -0
- metadata +142 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class HelperGenerator < Base
|
|
7
|
+
class_option :helper_specs, type: :boolean, default: true
|
|
8
|
+
|
|
9
|
+
def generate_helper_spec
|
|
10
|
+
return unless options[:helper_specs]
|
|
11
|
+
|
|
12
|
+
template 'helper_spec.rb', target_path('helpers', class_path, "#{file_name}_helper_spec.rb")
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# Specs in this file have access to a helper object that includes
|
|
4
|
+
# the <%= class_name %>Helper. For example:
|
|
5
|
+
#
|
|
6
|
+
# describe <%= class_name %>Helper do
|
|
7
|
+
# describe "string concat" do
|
|
8
|
+
# it "concats two strings with spaces" do
|
|
9
|
+
# expect(helper.concat_strings("this","that")).to eq("this that")
|
|
10
|
+
# end
|
|
11
|
+
# end
|
|
12
|
+
# end
|
|
13
|
+
<% module_namespacing do -%>
|
|
14
|
+
RSpec.describe <%= class_name %>Helper, <%= type_metatag(:helper) %> do
|
|
15
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
|
16
|
+
end
|
|
17
|
+
<% end -%>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require "rspec/support"
|
|
2
|
+
require "rspec/core"
|
|
3
|
+
RSpec::Support.require_rspec_core "project_initializer"
|
|
4
|
+
require "rspec/rails/feature_check"
|
|
5
|
+
|
|
6
|
+
module Rspec
|
|
7
|
+
module Generators
|
|
8
|
+
# @private
|
|
9
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
10
|
+
desc <<DESC
|
|
11
|
+
Description:
|
|
12
|
+
Copy rspec files to your application.
|
|
13
|
+
DESC
|
|
14
|
+
|
|
15
|
+
class_option :default_path, type: :string, default: 'spec'
|
|
16
|
+
|
|
17
|
+
def self.source_root
|
|
18
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def copy_spec_files
|
|
22
|
+
Dir.mktmpdir do |dir|
|
|
23
|
+
generate_rspec_init dir
|
|
24
|
+
template File.join(dir, '.rspec'), '.rspec'
|
|
25
|
+
directory File.join(dir, 'spec'), default_path
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def copy_rails_files
|
|
30
|
+
template 'spec/rails_helper.rb', "#{default_path}/rails_helper.rb"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def generate_rspec_init(tmpdir)
|
|
36
|
+
initializer = ::RSpec::Core::ProjectInitializer.new(
|
|
37
|
+
destination: tmpdir,
|
|
38
|
+
report_stream: StringIO.new
|
|
39
|
+
)
|
|
40
|
+
initializer.run
|
|
41
|
+
|
|
42
|
+
spec_helper_path = File.join(tmpdir, 'spec', 'spec_helper.rb')
|
|
43
|
+
|
|
44
|
+
replace_generator_command(spec_helper_path)
|
|
45
|
+
remove_warnings_configuration(spec_helper_path)
|
|
46
|
+
|
|
47
|
+
unless default_path == "spec"
|
|
48
|
+
dot_rspec_path = File.join(tmpdir, '.rspec')
|
|
49
|
+
|
|
50
|
+
append_default_path(dot_rspec_path)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def replace_generator_command(spec_helper_path)
|
|
55
|
+
gsub_file spec_helper_path,
|
|
56
|
+
'rspec --init',
|
|
57
|
+
'rails generate rspec:install',
|
|
58
|
+
verbose: false
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def remove_warnings_configuration(spec_helper_path)
|
|
62
|
+
empty_line = '^\n'
|
|
63
|
+
comment_line = '^\s*#.+\n'
|
|
64
|
+
gsub_file spec_helper_path,
|
|
65
|
+
/#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/,
|
|
66
|
+
'',
|
|
67
|
+
verbose: false
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def append_default_path(dot_rspec_path)
|
|
71
|
+
append_to_file dot_rspec_path,
|
|
72
|
+
"--default-path #{default_path}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def default_path
|
|
76
|
+
options[:default_path]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
4
|
+
require_relative '../config/environment'
|
|
5
|
+
# Prevent database truncation if the environment is production
|
|
6
|
+
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
|
7
|
+
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
|
8
|
+
# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file
|
|
9
|
+
# that will avoid rails generators crashing because migrations haven't been run yet
|
|
10
|
+
# return unless Rails.env.test?
|
|
11
|
+
<% end -%>
|
|
12
|
+
require 'rspec/rails'
|
|
13
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
|
14
|
+
|
|
15
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
|
16
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
|
17
|
+
# run as spec files by default. This means that files in spec/support that end
|
|
18
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
|
19
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
|
20
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
|
21
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
|
22
|
+
#
|
|
23
|
+
# The following line is provided for convenience purposes. It has the downside
|
|
24
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
|
25
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
26
|
+
# require only the support files necessary.
|
|
27
|
+
#
|
|
28
|
+
# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f }
|
|
29
|
+
|
|
30
|
+
<% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
|
|
31
|
+
# Ensures that the test database schema matches the current schema file.
|
|
32
|
+
# If there are pending migrations it will invoke `db:test:prepare` to
|
|
33
|
+
# recreate the test database by loading the schema.
|
|
34
|
+
# If you are not using ActiveRecord, you can remove these lines.
|
|
35
|
+
begin
|
|
36
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
37
|
+
rescue ActiveRecord::PendingMigrationError => e
|
|
38
|
+
abort e.to_s.strip
|
|
39
|
+
end
|
|
40
|
+
<% end -%>
|
|
41
|
+
RSpec.configure do |config|
|
|
42
|
+
<% if RSpec::Rails::FeatureCheck.has_active_record? -%>
|
|
43
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
44
|
+
config.fixture_paths = [
|
|
45
|
+
Rails.root.join('spec/fixtures')
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
49
|
+
# examples within a transaction, remove the following line or assign false
|
|
50
|
+
# instead of true.
|
|
51
|
+
config.use_transactional_fixtures = true
|
|
52
|
+
|
|
53
|
+
# You can uncomment this line to turn off ActiveRecord support entirely.
|
|
54
|
+
# config.use_active_record = false
|
|
55
|
+
|
|
56
|
+
<% else -%>
|
|
57
|
+
# Remove this line to enable support for ActiveRecord
|
|
58
|
+
config.use_active_record = false
|
|
59
|
+
|
|
60
|
+
# If you enable ActiveRecord support you should uncomment these lines,
|
|
61
|
+
# note if you'd prefer not to run each example within a transaction, you
|
|
62
|
+
# should set use_transactional_fixtures to false.
|
|
63
|
+
#
|
|
64
|
+
# config.fixture_paths = [
|
|
65
|
+
# Rails.root.join('spec/fixtures')
|
|
66
|
+
# ]
|
|
67
|
+
# config.use_transactional_fixtures = true
|
|
68
|
+
|
|
69
|
+
<% end -%>
|
|
70
|
+
# RSpec Rails uses metadata to mix in different behaviours to your tests,
|
|
71
|
+
# for example enabling you to call `get` and `post` in request specs. e.g.:
|
|
72
|
+
#
|
|
73
|
+
# RSpec.describe UsersController, type: :request do
|
|
74
|
+
# # ...
|
|
75
|
+
# end
|
|
76
|
+
#
|
|
77
|
+
# The different available types are documented in the features, such as in
|
|
78
|
+
# https://rspec.info/features/8-0/rspec-rails
|
|
79
|
+
#
|
|
80
|
+
# You can also infer these behaviours automatically by location, e.g.
|
|
81
|
+
# /spec/models would pull in the same behaviour as `type: :model` but this
|
|
82
|
+
# behaviour is considered legacy and will be removed in a future version.
|
|
83
|
+
#
|
|
84
|
+
# To enable this behaviour uncomment the line below.
|
|
85
|
+
# config.infer_spec_type_from_file_location!
|
|
86
|
+
|
|
87
|
+
# Filter lines from Rails gems in backtraces.
|
|
88
|
+
config.filter_rails_from_backtrace!
|
|
89
|
+
# arbitrary gems may also be filtered via:
|
|
90
|
+
# config.filter_gems_from_backtrace("gem name")
|
|
91
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class JobGenerator < Base
|
|
7
|
+
def create_job_spec
|
|
8
|
+
file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
|
|
9
|
+
template 'job_spec.rb.erb', target_path('jobs', class_path, [file_name, file_suffix].join('_'))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class MailboxGenerator < Base
|
|
7
|
+
def create_mailbox_spec
|
|
8
|
+
template('mailbox_spec.rb.erb',
|
|
9
|
+
target_path('mailboxes', class_path, "#{file_name}_mailbox_spec.rb")
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
require "rspec/rails/feature_check"
|
|
3
|
+
|
|
4
|
+
module Rspec
|
|
5
|
+
module Generators
|
|
6
|
+
# @private
|
|
7
|
+
class MailerGenerator < Base
|
|
8
|
+
argument :actions, type: :array, default: [], banner: "method method"
|
|
9
|
+
|
|
10
|
+
def generate_mailer_spec
|
|
11
|
+
file_suffix = file_name.end_with?('mailer') ? 'spec.rb' : 'mailer_spec.rb'
|
|
12
|
+
template "mailer_spec.rb", target_path('mailers', class_path, [file_name, file_suffix].join('_'))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def generate_fixtures_files
|
|
16
|
+
actions.each do |action|
|
|
17
|
+
@action, @path = action, File.join(file_path, action)
|
|
18
|
+
template "fixture", target_path("fixtures", @path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def generate_preview_files
|
|
23
|
+
return unless RSpec::Rails::FeatureCheck.has_action_mailer_preview?
|
|
24
|
+
|
|
25
|
+
file_suffix = file_name.end_with?('mailer') ? 'preview.rb' : 'mailer_preview.rb'
|
|
26
|
+
template "preview.rb", target_path("mailers/previews", class_path, [file_name, file_suffix].join('_'))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
<% module_namespacing do -%>
|
|
4
|
+
RSpec.describe <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>, <%= type_metatag(:mailer) %> do
|
|
5
|
+
<% for action in actions -%>
|
|
6
|
+
describe "<%= action %>" do
|
|
7
|
+
let(:mail) { <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %> }
|
|
8
|
+
|
|
9
|
+
it "renders the headers" do
|
|
10
|
+
expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
|
|
11
|
+
expect(mail.to).to eq(["to@example.org"])
|
|
12
|
+
expect(mail.from).to eq(["from@example.com"])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "renders the body" do
|
|
16
|
+
expect(mail.body.encoded).to match("Hi")
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
<% end -%>
|
|
21
|
+
<% if actions.blank? -%>
|
|
22
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
|
23
|
+
<% end -%>
|
|
24
|
+
end
|
|
25
|
+
<% end -%>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% module_namespacing do -%>
|
|
2
|
+
# Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %>_mailer
|
|
3
|
+
class <%= class_name %><%= 'Mailer' unless class_name.end_with?('Mailer') %>Preview < ActionMailer::Preview
|
|
4
|
+
<% actions.each do |action| -%>
|
|
5
|
+
|
|
6
|
+
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>_mailer/<%= action %>
|
|
7
|
+
def <%= action %>
|
|
8
|
+
<%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %>
|
|
9
|
+
end
|
|
10
|
+
<% end -%>
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
<% end -%>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class ModelGenerator < Base
|
|
7
|
+
argument :attributes,
|
|
8
|
+
type: :array,
|
|
9
|
+
default: [],
|
|
10
|
+
banner: "field:type field:type"
|
|
11
|
+
class_option :fixture, type: :boolean
|
|
12
|
+
|
|
13
|
+
def create_model_spec
|
|
14
|
+
template_file = target_path(
|
|
15
|
+
'models',
|
|
16
|
+
class_path,
|
|
17
|
+
"#{file_name}_spec.rb"
|
|
18
|
+
)
|
|
19
|
+
template 'model_spec.rb', template_file
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
hook_for :fixture_replacement
|
|
23
|
+
|
|
24
|
+
def create_fixture_file
|
|
25
|
+
return unless missing_fixture_replacement?
|
|
26
|
+
|
|
27
|
+
template 'fixtures.yml', target_path('fixtures', class_path, "#{(pluralize_table_names? ? plural_file_name : file_name)}.yml")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def missing_fixture_replacement?
|
|
33
|
+
options[:fixture] && options[:fixture_replacement].nil?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
|
2
|
+
|
|
3
|
+
<% unless attributes.empty? -%>
|
|
4
|
+
one:
|
|
5
|
+
<% for attribute in attributes -%>
|
|
6
|
+
<%= attribute.name %>: <%= attribute.default %>
|
|
7
|
+
<% end -%>
|
|
8
|
+
|
|
9
|
+
two:
|
|
10
|
+
<% for attribute in attributes -%>
|
|
11
|
+
<%= attribute.name %>: <%= attribute.default %>
|
|
12
|
+
<% end -%>
|
|
13
|
+
<% else -%>
|
|
14
|
+
# one:
|
|
15
|
+
# column: value
|
|
16
|
+
#
|
|
17
|
+
# two:
|
|
18
|
+
# column: value
|
|
19
|
+
<% end -%>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
|
|
3
|
+
module Rspec
|
|
4
|
+
module Generators
|
|
5
|
+
# @private
|
|
6
|
+
class RequestGenerator < Base
|
|
7
|
+
class_option :request_specs, type: :boolean, default: true, desc: 'Generate request specs'
|
|
8
|
+
|
|
9
|
+
def generate_request_spec
|
|
10
|
+
return unless options[:request_specs]
|
|
11
|
+
|
|
12
|
+
template 'request_spec.rb',
|
|
13
|
+
target_path('requests', "#{name.underscore.pluralize}_spec.rb")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
|
|
4
|
+
describe "GET /<%= name.underscore.pluralize %>" do
|
|
5
|
+
it "works! (now write some real specs)" do
|
|
6
|
+
get <%= index_helper %>_path
|
|
7
|
+
expect(response).to have_http_status(200)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
require 'generators/rspec'
|
|
2
|
+
require 'rails/generators/resource_helpers'
|
|
3
|
+
|
|
4
|
+
module Rspec
|
|
5
|
+
module Generators
|
|
6
|
+
# @private
|
|
7
|
+
class ScaffoldGenerator < Base
|
|
8
|
+
include ::Rails::Generators::ResourceHelpers
|
|
9
|
+
source_paths << File.expand_path('../helper/templates', __dir__)
|
|
10
|
+
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
11
|
+
|
|
12
|
+
class_option :orm, desc: "ORM used to generate the controller"
|
|
13
|
+
class_option :template_engine, desc: "Template engine to generate view files"
|
|
14
|
+
class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
|
|
15
|
+
class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"
|
|
16
|
+
|
|
17
|
+
class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
|
|
18
|
+
class_option :request_specs, type: :boolean, default: true, desc: "Generate request specs"
|
|
19
|
+
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
|
|
20
|
+
class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
|
|
21
|
+
class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"
|
|
22
|
+
|
|
23
|
+
def initialize(*args, &blk)
|
|
24
|
+
@generator_args = args.first
|
|
25
|
+
super(*args, &blk)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def generate_controller_spec
|
|
29
|
+
return unless options[:controller_specs]
|
|
30
|
+
|
|
31
|
+
if options[:api]
|
|
32
|
+
template 'api_controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
|
|
33
|
+
else
|
|
34
|
+
template 'controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def generate_request_spec
|
|
39
|
+
return unless options[:request_specs]
|
|
40
|
+
|
|
41
|
+
if options[:api]
|
|
42
|
+
template 'api_request_spec.rb', template_file(folder: 'requests')
|
|
43
|
+
else
|
|
44
|
+
template 'request_spec.rb', template_file(folder: 'requests')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def generate_view_specs
|
|
49
|
+
return if options[:api]
|
|
50
|
+
return unless options[:view_specs] && options[:template_engine]
|
|
51
|
+
|
|
52
|
+
copy_view :edit
|
|
53
|
+
copy_view :index unless options[:singleton]
|
|
54
|
+
copy_view :new
|
|
55
|
+
copy_view :show
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def generate_routing_spec
|
|
59
|
+
return unless options[:routing_specs]
|
|
60
|
+
|
|
61
|
+
template_file = target_path(
|
|
62
|
+
'routing',
|
|
63
|
+
controller_class_path,
|
|
64
|
+
"#{controller_file_name}_routing_spec.rb"
|
|
65
|
+
)
|
|
66
|
+
template 'routing_spec.rb', template_file
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
protected
|
|
70
|
+
|
|
71
|
+
attr_reader :generator_args
|
|
72
|
+
|
|
73
|
+
def copy_view(view)
|
|
74
|
+
template "#{view}_spec.rb",
|
|
75
|
+
target_path("views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# support for namespaced-resources
|
|
79
|
+
def ns_file_name
|
|
80
|
+
return file_name if ns_parts.empty?
|
|
81
|
+
|
|
82
|
+
"#{ns_prefix.map(&:underscore).join('/')}_#{ns_suffix.singularize.underscore}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# support for namespaced-resources
|
|
86
|
+
def ns_table_name
|
|
87
|
+
return table_name if ns_parts.empty?
|
|
88
|
+
|
|
89
|
+
"#{ns_prefix.map(&:underscore).join('/')}/#{ns_suffix.tableize}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def ns_parts
|
|
93
|
+
@ns_parts ||= begin
|
|
94
|
+
parts = generator_args[0].split(/\/|::/)
|
|
95
|
+
parts.size > 1 ? parts : []
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def ns_prefix
|
|
100
|
+
@ns_prefix ||= ns_parts[0..-2]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def ns_suffix
|
|
104
|
+
@ns_suffix ||= ns_parts[-1]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def value_for(attribute)
|
|
108
|
+
raw_value_for(attribute).inspect
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def raw_value_for(attribute)
|
|
112
|
+
case attribute.type
|
|
113
|
+
when :string
|
|
114
|
+
attribute.name.titleize
|
|
115
|
+
when :integer, :float
|
|
116
|
+
@attribute_id_map ||= {}
|
|
117
|
+
@attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next + attribute.default
|
|
118
|
+
else
|
|
119
|
+
attribute.default
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def template_file(folder:, suffix: '')
|
|
124
|
+
target_path(folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb")
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def banner
|
|
128
|
+
self.class.banner
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def show_helper(resource_name = file_name)
|
|
132
|
+
"#{singular_route_name}_url(#{resource_name})"
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|