diff --git a/.env.template b/.env.template index 2f9ad1e..064fbdd 100644 --- a/.env.template +++ b/.env.template @@ -1,4 +1,5 @@ # list environment variables in a .env file +# prefer rails credentials `rails credentials:edit` # required variables can be specified in `initializers/dotenv.rb` # generate a template file with `$ dotenv -t .env` -# SOMEVARIABLE=xxxxxsecretvariablexxxxx +# SOMEVARIABLE=xxxxxenvvariablexxxxx diff --git a/.ruby-version b/.ruby-version index ef538c2..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.2.2 diff --git a/README.md b/README.md index 6942047..9085cae 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,12 @@ A Rails Application Template for use at Ministry of Velocity Reference: [Rails Application Templates](https://guides.rubyonrails.org/rails_application_templates.html) - +### Locally ```bash rails new --skip-test --skip-jbuilder -d postgresql -c tailwind -m ./template.rb ``` +### Remotely ```bash rails new --skip-test --skip-jbuilder -d postgresql -c tailwind -m 'https://raw.githubusercontent.com/jparr/minifast-rails/main/template.rb' ``` \ No newline at end of file diff --git a/README_template.md b/README_template.md new file mode 100644 index 0000000..ac0f904 --- /dev/null +++ b/README_template.md @@ -0,0 +1,36 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +### Local dev +Start redis +```bash +brew services start redis +``` + +start dev server +```bash +dev +``` + + +* Deployment instructions + +* ... diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb new file mode 100644 index 0000000..af7d817 --- /dev/null +++ b/spec/support/capybara.rb @@ -0,0 +1,29 @@ +require 'capybara/cuprite' +require 'capybara/rspec' + +Capybara.default_driver = :rack_test +Capybara.javascript_driver = :cuprite +Capybara.server = :puma, {Silent: true} + +Capybara.register_driver(:cuprite) do |app| + Capybara::Cuprite::Driver.new( + app, + window_size: [1920, 1080], + headless: false + ) +end + +module FakeCapybaraPage + def page + Nokogiri::HTML::DocumentFragment.parse(response.body) + end +end + +RSpec.configure do |config| + config.include FakeCapybaraPage, type: :request + config.include Capybara::RSpecMatchers, type: :request + config.include ActionView::RecordIdentifier, type: :request + config.include Capybara::RSpecMatchers, type: :component + config.before(:each, type: :system) { driven_by(:rack_test) } + config.before(:each, js: true, type: :system) { driven_by(:cuprite) } +end diff --git a/spec/support/view_component.rb b/spec/support/view_component.rb new file mode 100644 index 0000000..ad3ad5c --- /dev/null +++ b/spec/support/view_component.rb @@ -0,0 +1,5 @@ +require 'view_component/test_helpers' + +RSpec.configure do |config| + config.include ViewComponent::TestHelpers, type: :component +end diff --git a/template.rb b/template.rb index b6f35fb..28ea494 100644 --- a/template.rb +++ b/template.rb @@ -59,7 +59,7 @@ def rails_7_or_newer? gem_group :test do gem 'capybara' - gem 'selenium-webdriver' + gem 'cuprite' gem 'shoulda-matchers', '~> 5.0' gem 'webdrivers' end @@ -70,8 +70,11 @@ def rails_7_or_newer? after_bundle do generate 'rspec:install' directory 'spec/support' + uncomment_lines 'spec/rails_helper.rb', /'spec', 'support', '\*\*', '\*.rb'/ + copy_file '.erb-lint.yml' copy_file '.rubocop.yml' + copy_file 'README_template.md', 'README.md' run 'bundle binstubs erb_lint' run 'bundle binstubs rubocop' @@ -81,6 +84,7 @@ def rails_7_or_newer? inject_into_file 'config/application.rb', after: 'config.load_defaults 7.0' do <<-RUBY + config.view_component.generate.sidecar = true config.generators do |generator| @@ -102,7 +106,7 @@ def rails_7_or_newer? # todo: better readme template - run 'bin/rubocop -A' + run 'bin/rubocop -a' say 'App successfully created!', :green end