diff --git a/Rakefile b/Rakefile index b7f8bb4..6623284 100644 --- a/Rakefile +++ b/Rakefile @@ -12,4 +12,4 @@ end RSpec::Core::RakeTask.new(:spec) desc "Run the test suite" -task default: %w(spec cucumber) +task default: %w[spec cucumber] diff --git a/factory_bot_rails.gemspec b/factory_bot_rails.gemspec index ca0e7fc..53e8e17 100644 --- a/factory_bot_rails.gemspec +++ b/factory_bot_rails.gemspec @@ -1,18 +1,18 @@ Gem::Specification.new do |s| - s.name = "factory_bot_rails" - s.version = "5.1.1" - s.authors = ["Joe Ferris"] - s.email = "jferris@thoughtbot.com" - s.homepage = "https://github.com/thoughtbot/factory_bot_rails" - s.summary = "factory_bot_rails provides integration between "\ + s.name = "factory_bot_rails" + s.version = "5.1.1" + s.authors = ["Joe Ferris"] + s.email = "jferris@thoughtbot.com" + s.homepage = "https://github.com/thoughtbot/factory_bot_rails" + s.summary = "factory_bot_rails provides integration between "\ "factory_bot and rails 5.0 or newer" s.description = "factory_bot_rails provides integration between "\ "factory_bot and rails 5.0 or newer" s.files = Dir["lib/**/*"] + %w[CONTRIBUTING.md LICENSE NEWS.md README.md] s.require_paths = ["lib"] - s.executables = [] - s.license = "MIT" + s.executables = [] + s.license = "MIT" s.add_runtime_dependency("factory_bot", "~> 5.1.0") s.add_runtime_dependency("railties", ">= 5.0.0") diff --git a/features/step_definitions/appraisal.rb b/features/step_definitions/appraisal.rb index 433129f..76fe529 100644 --- a/features/step_definitions/appraisal.rb +++ b/features/step_definitions/appraisal.rb @@ -1,10 +1,10 @@ -When /^I run `([^"]+)` with a clean environment$/ do |command| +When(/^I run `([^"]+)` with a clean environment$/) do |command| step <<~STEP I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'` STEP end -When /^I run `([^"]+)` with Spring enabled$/ do |command| +When(/^I run `([^"]+)` with Spring enabled$/) do |command| step <<~STEP I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'` STEP diff --git a/features/step_definitions/rails_steps.rb b/features/step_definitions/rails_steps.rb index 2556791..ba493fb 100644 --- a/features/step_definitions/rails_steps.rb +++ b/features/step_definitions/rails_steps.rb @@ -1,4 +1,4 @@ -When /^I create a new rails application$/ do +When(/^I create a new rails application$/) do options = %w[ --api @@ -20,15 +20,15 @@ When /^I create a new rails application$/ do cd("test_app") end -When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name| - append_to_file("Gemfile", %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n}) +When(/^I add "([^"]+)" from this project as a dependency$/) do |gem_name| + append_to_file("Gemfile", %(gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n)) end -When /^I add "([^"]+)" as a dependency$/ do |gem_name| - append_to_file("Gemfile", %{gem "#{gem_name}"\n}) +When(/^I add "([^"]+)" as a dependency$/) do |gem_name| + append_to_file("Gemfile", %(gem "#{gem_name}"\n)) end -When /^I print out "([^"]*)"$/ do |path| +When(/^I print out "([^"]*)"$/) do |path| in_current_dir do File.open(path, "r") do |f| puts f.inspect @@ -36,7 +36,7 @@ When /^I print out "([^"]*)"$/ do |path| end end -When /^I configure the factories as:$/ do |string| +When(/^I configure the factories as:$/) do |string| append_to_file File.join("config", "application.rb"), <<~RUBY class TestApp::Application #{string} @@ -44,7 +44,7 @@ When /^I configure the factories as:$/ do |string| RUBY end -When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir| +When(/^I configure the factories directory as "([^"]+)"$/) do |factory_dir| append_to_file File.join("config", "application.rb"), <<~RUBY class TestApp::Application config.generators do |g| @@ -54,7 +54,7 @@ When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir| RUBY end -When /^I comment out gem "([^"]*)" from my Gemfile$/ do |gem_name| +When(/^I comment out gem "([^"]*)" from my Gemfile$/) do |gem_name| in_current_dir do content = File.read("Gemfile") File.open("Gemfile", "w") do |f| diff --git a/features/support/env.rb b/features/support/env.rb index d234143..07116c6 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -11,7 +11,7 @@ if RUBY_PLATFORM == "java" Aruba.configure do |config| config.before_cmd do # disable JIT since these processes are so short lived - set_env("JRUBY_OPTS", "-X-C #{ENV['JRUBY_OPTS']}") + set_env("JRUBY_OPTS", "-X-C #{ENV["JRUBY_OPTS"]}") java_options = ENV["JAVA_OPTS"] @@ -20,7 +20,7 @@ if RUBY_PLATFORM == "java" else set_env( "JAVA_OPTS", - "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}", + "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}" ) end end diff --git a/lib/factory_bot_rails/generators/non_rspec_generator.rb b/lib/factory_bot_rails/generators/non_rspec_generator.rb index 7d2d770..df794f3 100644 --- a/lib/factory_bot_rails/generators/non_rspec_generator.rb +++ b/lib/factory_bot_rails/generators/non_rspec_generator.rb @@ -9,7 +9,7 @@ module FactoryBotRails @generators.test_framework( test_framework, fixture: false, - fixture_replacement: :factory_bot, + fixture_replacement: :factory_bot ) end diff --git a/lib/factory_bot_rails/generators/rspec_generator.rb b/lib/factory_bot_rails/generators/rspec_generator.rb index 96dde63..4781733 100644 --- a/lib/factory_bot_rails/generators/rspec_generator.rb +++ b/lib/factory_bot_rails/generators/rspec_generator.rb @@ -8,7 +8,7 @@ module FactoryBotRails def run @generators.fixture_replacement( fixture_replacement_setting, - dir: factory_bot_directory, + dir: factory_bot_directory ) end diff --git a/lib/generators/factory_bot.rb b/lib/generators/factory_bot.rb index ef7551e..e5ff76b 100644 --- a/lib/generators/factory_bot.rb +++ b/lib/generators/factory_bot.rb @@ -8,7 +8,7 @@ module FactoryBot File.dirname(__FILE__), "factory_bot", generator_name, - "templates", + "templates" ) File.expand_path(path) diff --git a/lib/generators/factory_bot/model/model_generator.rb b/lib/generators/factory_bot/model/model_generator.rb index 4d28fb6..e99c594 100644 --- a/lib/generators/factory_bot/model/model_generator.rb +++ b/lib/generators/factory_bot/model/model_generator.rb @@ -8,21 +8,21 @@ module FactoryBot :attributes, type: :array, default: [], - banner: "field:type field:type", + banner: "field:type field:type" ) class_option( :dir, type: :string, default: "test/factories", - desc: "The directory or file root where factories belong", + desc: "The directory or file root where factories belong" ) class_option( :suffix, type: :string, default: nil, - desc: "Suffix to add factory file", + desc: "Suffix to add factory file" ) def create_fixture_file @@ -43,7 +43,7 @@ module FactoryBot insert_into_file( factories_file, factory_definition, - after: "FactoryBot.define do\n", + after: "FactoryBot.define do\n" ) end @@ -55,16 +55,16 @@ module FactoryBot def factory_definition <<~RUBY factory :#{factory_name}#{explicit_class_option} do - #{factory_attributes.gsub(/^/, ' ')} + #{factory_attributes.gsub(/^/, " ")} end RUBY end def factory_attributes - attributes.map do |attribute| + attributes.map { |attribute| "#{attribute.name} { #{attribute.default.inspect} }" - end.join("\n") + }.join("\n") end def filename diff --git a/spec/factory_bot_rails/definition_file_paths_spec.rb b/spec/factory_bot_rails/definition_file_paths_spec.rb index 006ed18..5004110 100644 --- a/spec/factory_bot_rails/definition_file_paths_spec.rb +++ b/spec/factory_bot_rails/definition_file_paths_spec.rb @@ -18,7 +18,7 @@ describe FactoryBotRails::DefinitionFilePaths do directories = described_class.new(definition_file_paths).directories expect(directories).to eq( - "spec/fixtures/factories" => [:rb], + "spec/fixtures/factories" => [:rb] ) end diff --git a/spec/factory_bot_rails/reloader_spec.rb b/spec/factory_bot_rails/reloader_spec.rb index 188e791..70010d1 100644 --- a/spec/factory_bot_rails/reloader_spec.rb +++ b/spec/factory_bot_rails/reloader_spec.rb @@ -42,8 +42,8 @@ describe FactoryBotRails::Reloader do def run_reloader(definition_file_paths) FactoryBot.definition_file_paths = definition_file_paths - FactoryBotRails::Reloader. - new(Rails.application, Rails.application.config).run + FactoryBotRails::Reloader + .new(Rails.application, Rails.application.config).run end def reloader_class