Last active
August 22, 2020 06:28
-
-
Save frullah/a279141d54f1227ff4edadb5d7a5c532 to your computer and use it in GitHub Desktop.
rails api additional setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # version 0.88.0 | |
| AllCops: | |
| Exclude: | |
| - 'node_modules/**/*' | |
| - 'vendor/**/*' | |
| - 'bin/*' | |
| - 'db/*_schema.rb' | |
| - 'db/schema.rb' | |
| - 'config/spring.rb' | |
| Metrics/AbcSize: | |
| Exclude: | |
| - db/migrate/**/* | |
| Style/Documentation: | |
| Exclude: | |
| - db/migrate/**/* | |
| Style/FrozenStringLiteralComment: | |
| Exclude: | |
| - db/migrate/**/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gem 'rswag-api' | |
| gem 'rswag-ui' | |
| group :development, :test do | |
| gem 'factory_bot_rails' | |
| gem 'guard-rspec', require: false | |
| gem 'rspec-rails', '~> 4.0.1' | |
| gem 'rswag-specs' | |
| end | |
| group :development do | |
| gem 'rubocop', '~> 0.88.0', require: false | |
| gem 'spring-commands-rspec', require: false | |
| gem 'spring-commands-rubocop', require: false | |
| end | |
| group :test do | |
| gem 'shoulda-matchers', '~> 4.0' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # RSpec files | |
| rspec = dsl.rspec | |
| watch(rspec.spec_helper) { rspec.spec_dir } | |
| watch(rspec.spec_support) { rspec.spec_dir } | |
| watch(rspec.spec_files) | |
| # Ruby files | |
| ruby = dsl.ruby | |
| dsl.watch_spec_files_for(ruby.lib_files) | |
| # Rails files | |
| rails = dsl.rails | |
| dsl.watch_spec_files_for(rails.app_files) | |
| watch(%r{app/controllers/(.+)_controller.rb}) do |match| | |
| "#{rspec.spec_dir}/requests/#{match[1]}_spec.rb" | |
| end | |
| # Rails config changes | |
| watch(rails.spec_helper) { rspec.spec_dir } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| bundle exec rails g rspec:install | |
| bundle exec guard init | |
| bundle binstub guard | |
| bundle exec spring binstub rubocop rspec | |
| # install rswag | |
| bundle exec rails g rswag:api:install | |
| bundle exec rails g rswag:ui:install | |
| RAILS_ENV=test bundle exec rails g rswag:specs:install | |
| # replace rpsec command | |
| sed -r '(?<=s/cmd: ")(.*)(?=")/bundle exec spring rspec -f doc/' Guardfile | |
| # insert shoulda-matchers config to spec/rails_helper.rb | |
| cat <<EOF >> spec/rails_helper.rb | |
| Shoulda::Matchers.configure do |config| | |
| config.integrate do |with| | |
| with.test_framework :rspec | |
| with.library :rails | |
| end | |
| end | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment