mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Run automatic cop fixes
This runs all of the automatic cops that came in since rubocop 0.68. None of these changes were manual.
This commit is contained in:
parent
41468b09f3
commit
0e7c6e60f1
11 changed files with 29 additions and 27 deletions
|
@ -16,6 +16,7 @@ module FactoryBot
|
|||
else instance_exec(&block)
|
||||
end
|
||||
raise SequenceAbuseError if FactoryBot::Sequence === value
|
||||
|
||||
value
|
||||
}
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ module FactoryBot
|
|||
end
|
||||
|
||||
delegate :to_create, :skip_create, :constructor, :before, :after,
|
||||
:callback, :callbacks, to: :@definition
|
||||
:callback, :callbacks, to: :@definition
|
||||
|
||||
def initialize_with(&block)
|
||||
@definition.define_constructor(&block)
|
||||
|
|
|
@ -72,8 +72,8 @@ module FactoryBot
|
|||
result = []
|
||||
begin
|
||||
FactoryBot.public_send(factory_strategy, factory.name)
|
||||
rescue StandardError => error
|
||||
result |= [FactoryError.new(error, factory)]
|
||||
rescue StandardError => e
|
||||
result |= [FactoryError.new(e, factory)]
|
||||
end
|
||||
result
|
||||
end
|
||||
|
@ -83,9 +83,9 @@ module FactoryBot
|
|||
factory.definition.defined_traits.map(&:name).each do |trait_name|
|
||||
begin
|
||||
FactoryBot.public_send(factory_strategy, factory.name, trait_name)
|
||||
rescue StandardError => error
|
||||
rescue StandardError => e
|
||||
result |=
|
||||
[FactoryTraitError.new(error, factory, trait_name)]
|
||||
[FactoryTraitError.new(e, factory, trait_name)]
|
||||
end
|
||||
end
|
||||
result
|
||||
|
|
|
@ -8,7 +8,7 @@ module FactoryBot
|
|||
end
|
||||
|
||||
delegate :defined_traits, :callbacks, :attributes, :constructor,
|
||||
:to_create, to: :definition
|
||||
:to_create, to: :definition
|
||||
|
||||
def compile; end
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ module FactoryBot
|
|||
|
||||
def find(name)
|
||||
@items.fetch(name)
|
||||
rescue KeyError => key_error
|
||||
raise key_error_with_custom_message(key_error)
|
||||
rescue KeyError => e
|
||||
raise key_error_with_custom_message(e)
|
||||
end
|
||||
|
||||
alias :[] :find
|
||||
|
|
|
@ -5,8 +5,8 @@ describe "a generated attributes hash" do
|
|||
define_model("User")
|
||||
define_model("Comment")
|
||||
|
||||
define_model("Post", title: :string,
|
||||
body: :string,
|
||||
define_model("Post", title: :string,
|
||||
body: :string,
|
||||
summary: :string,
|
||||
user_id: :integer) do
|
||||
belongs_to :user
|
||||
|
|
|
@ -2,10 +2,10 @@ describe "a generated attributes hash where order matters" do
|
|||
include FactoryBot::Syntax::Methods
|
||||
|
||||
before do
|
||||
define_model("ParentModel", static: :integer,
|
||||
evaluates_first: :integer,
|
||||
define_model("ParentModel", static: :integer,
|
||||
evaluates_first: :integer,
|
||||
evaluates_second: :integer,
|
||||
evaluates_third: :integer)
|
||||
evaluates_third: :integer)
|
||||
|
||||
FactoryBot.define do
|
||||
factory :parent_model do
|
||||
|
|
|
@ -4,9 +4,9 @@ describe "a generated stub instance" do
|
|||
before do
|
||||
define_model("User")
|
||||
|
||||
define_model("Post", title: :string,
|
||||
body: :string,
|
||||
age: :integer,
|
||||
define_model("Post", title: :string,
|
||||
body: :string,
|
||||
age: :integer,
|
||||
user_id: :integer,
|
||||
draft: :boolean) do
|
||||
belongs_to :user
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
describe "attribute overrides" do
|
||||
before do
|
||||
define_model("User", admin: :boolean)
|
||||
define_model("Post", title: :string,
|
||||
secure: :boolean,
|
||||
define_model("User", admin: :boolean)
|
||||
define_model("Post", title: :string,
|
||||
secure: :boolean,
|
||||
user_id: :integer) do
|
||||
belongs_to :user
|
||||
|
||||
def secure=(value)
|
||||
return unless user&.admin?
|
||||
|
||||
write_attribute(:secure, value)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
describe "an instance generated by a factory with multiple traits" do
|
||||
before do
|
||||
define_model("User",
|
||||
name: :string,
|
||||
admin: :boolean,
|
||||
gender: :string,
|
||||
email: :string,
|
||||
name: :string,
|
||||
admin: :boolean,
|
||||
gender: :string,
|
||||
email: :string,
|
||||
date_of_birth: :date,
|
||||
great: :string)
|
||||
great: :string)
|
||||
|
||||
FactoryBot.define do
|
||||
factory :user_without_admin_scoping, class: User do
|
||||
|
|
|
@ -25,9 +25,9 @@ module DefineConstantMacros
|
|||
connection.create_table(table_name, &block)
|
||||
created_tables << table_name
|
||||
connection
|
||||
rescue Exception => exception # rubocop:disable Lint/RescueException
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
connection.execute("DROP TABLE IF EXISTS #{table_name}")
|
||||
raise exception
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -56,7 +56,7 @@ RSpec.configure do |config|
|
|||
|
||||
config.before(:all) do
|
||||
ActiveRecord::Base.establish_connection(
|
||||
adapter: "sqlite3",
|
||||
adapter: "sqlite3",
|
||||
database: ":memory:",
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue