1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot_rails.git synced 2022-11-09 11:49:18 -05:00

Fix remaining RuboCop TODOs

This commit is contained in:
Daniel Colson 2018-09-28 22:34:23 -04:00
parent 7907b085fd
commit c84e6b2aa2
8 changed files with 56 additions and 54 deletions

View file

@ -2,33 +2,10 @@ inherit_from:
- https://raw.githubusercontent.com/thoughtbot/guides/master/style/ruby/.rubocop.yml
AllCops:
TargetRubyVersion: 2.3
Exclude:
- "tmp/**/*"
- "gemfiles/*"
Style/EmptyMethod:
EnforcedStyle: expanded
# TODO:
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-09-17 20:19:38 -0400 using RuboCop version 0.54.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Exclude:
- 'features/step_definitions/rails_steps.rb'
- 'lib/generators/factory_bot/model/model_generator.rb'
# Offense count: 11
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 133

View file

@ -1,5 +1,5 @@
When /^I run `([^"]+)` with a clean environment$/ do |command|
step %{I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`}
step <<~STEP
I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`
STEP
end
# system({'BUNDLE_GEMFILE' => nil}, "cd tmp/aruba/testapp && #{command} && cd -")

View file

@ -15,20 +15,20 @@ When /^I print out "([^"]*)"$/ do |path|
end
When /^I configure the factories as:$/ do |string|
append_to_file File.join("config", "application.rb"), <<-RUBY
class Testapp::Application
#{string}
end
append_to_file File.join("config", "application.rb"), <<~RUBY
class Testapp::Application
#{string}
end
RUBY
end
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|
g.fixture_replacement :factory_bot, :dir => "#{factory_dir}"
end
end
append_to_file File.join("config", "application.rb"), <<~RUBY
class Testapp::Application
config.generators do |g|
g.fixture_replacement :factory_bot, :dir => "#{factory_dir}"
end
end
RUBY
end

View file

@ -1,6 +1,7 @@
require "aruba/cucumber"
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", "..")).freeze
PROJECT_ROOT =
File.expand_path(File.join(File.dirname(__FILE__), "..", "..")).freeze
Aruba.configure do |config|
config.exit_timeout = Integer ENV.fetch("ARUBA_TIMEOUT") { 120 }
@ -8,15 +9,19 @@ end
if RUBY_PLATFORM == "java"
Aruba.configure do |config|
config.before_cmd do |_|
set_env("JRUBY_OPTS", "-X-C #{ENV['JRUBY_OPTS']}") # disable JIT since these processes are so short lived
config.before_cmd do
# disable JIT since these processes are so short lived
set_env("JRUBY_OPTS", "-X-C #{ENV['JRUBY_OPTS']}")
java_options = ENV["JAVA_OPTS"]
if 1.size == 4 # 4 for 32 bit java, 8 for 64 bit java.
set_env("JAVA_OPTS", "-d32 #{java_options}")
else
set_env("JAVA_OPTS", "-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}")
set_env(
"JAVA_OPTS",
"-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}",
)
end
end
end

View file

@ -6,7 +6,11 @@ module FactoryBotRails
end
def run
@generators.test_framework test_framework, fixture: false, fixture_replacement: :factory_bot
@generators.test_framework(
test_framework,
fixture: false,
fixture_replacement: :factory_bot,
)
end
private

View file

@ -6,7 +6,10 @@ module FactoryBotRails
end
def run
@generators.fixture_replacement fixture_replacement_setting, dir: factory_bot_directory
@generators.fixture_replacement(
fixture_replacement_setting,
dir: factory_bot_directory,
)
end
private
@ -16,7 +19,11 @@ module FactoryBotRails
end
def factory_bot_directory
@generators.options.fetch(:factory_bot, {}).fetch(:dir, "spec/factories")
factory_bot_options.fetch(:dir, "spec/factories")
end
def factory_bot_options
@generators.options.fetch(:factory_bot, {})
end
end
end

View file

@ -4,11 +4,20 @@ module FactoryBot
module Generators
class Base < Rails::Generators::NamedBase #:nodoc:
def self.source_root
File.expand_path(File.join(File.dirname(__FILE__), "factory_bot", generator_name, "templates"))
path = File.join(
File.dirname(__FILE__),
"factory_bot",
generator_name,
"templates",
)
File.expand_path(path)
end
def explicit_class_option
", class: '#{class_name}'" unless class_name == singular_table_name.camelize
return if class_name == singular_table_name.camelize
", class: '#{class_name}'"
end
end
end

View file

@ -53,18 +53,18 @@ module FactoryBot
end
def factory_definition
<<-RUBY
factory :#{singular_table_name}#{explicit_class_option} do
#{factory_attributes.gsub(/^/, ' ')}
end
<<~RUBY
factory :#{singular_table_name}#{explicit_class_option} do
#{factory_attributes.gsub(/^/, ' ')}
end
RUBY
end
def single_file_factory_definition
<<-RUBY
FactoryBot.define do
#{factory_definition.chomp}
end
<<~RUBY
FactoryBot.define do
#{factory_definition.chomp}
end
RUBY
end