mirror of
https://github.com/thoughtbot/factory_bot_rails.git
synced 2022-11-09 11:49:18 -05:00
Run standardrb
This commit applies the changes from running `standardrb --fix`
This commit is contained in:
parent
aad77ceeb6
commit
ce8bfb409b
11 changed files with 35 additions and 35 deletions
2
Rakefile
2
Rakefile
|
@ -12,4 +12,4 @@ end
|
||||||
RSpec::Core::RakeTask.new(:spec)
|
RSpec::Core::RakeTask.new(:spec)
|
||||||
|
|
||||||
desc "Run the test suite"
|
desc "Run the test suite"
|
||||||
task default: %w(spec cucumber)
|
task default: %w[spec cucumber]
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "factory_bot_rails"
|
s.name = "factory_bot_rails"
|
||||||
s.version = "5.1.1"
|
s.version = "5.1.1"
|
||||||
s.authors = ["Joe Ferris"]
|
s.authors = ["Joe Ferris"]
|
||||||
s.email = "jferris@thoughtbot.com"
|
s.email = "jferris@thoughtbot.com"
|
||||||
s.homepage = "https://github.com/thoughtbot/factory_bot_rails"
|
s.homepage = "https://github.com/thoughtbot/factory_bot_rails"
|
||||||
s.summary = "factory_bot_rails provides integration between "\
|
s.summary = "factory_bot_rails provides integration between "\
|
||||||
"factory_bot and rails 5.0 or newer"
|
"factory_bot and rails 5.0 or newer"
|
||||||
s.description = "factory_bot_rails provides integration between "\
|
s.description = "factory_bot_rails provides integration between "\
|
||||||
"factory_bot and rails 5.0 or newer"
|
"factory_bot and rails 5.0 or newer"
|
||||||
|
|
||||||
s.files = Dir["lib/**/*"] + %w[CONTRIBUTING.md LICENSE NEWS.md README.md]
|
s.files = Dir["lib/**/*"] + %w[CONTRIBUTING.md LICENSE NEWS.md README.md]
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
s.executables = []
|
s.executables = []
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
|
|
||||||
s.add_runtime_dependency("factory_bot", "~> 5.1.0")
|
s.add_runtime_dependency("factory_bot", "~> 5.1.0")
|
||||||
s.add_runtime_dependency("railties", ">= 5.0.0")
|
s.add_runtime_dependency("railties", ">= 5.0.0")
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
When /^I run `([^"]+)` with a clean environment$/ do |command|
|
When(/^I run `([^"]+)` with a clean environment$/) do |command|
|
||||||
step <<~STEP
|
step <<~STEP
|
||||||
I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`
|
I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil, "DISABLE_SPRING" => "true"}, "#{command}")'`
|
||||||
STEP
|
STEP
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I run `([^"]+)` with Spring enabled$/ do |command|
|
When(/^I run `([^"]+)` with Spring enabled$/) do |command|
|
||||||
step <<~STEP
|
step <<~STEP
|
||||||
I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`
|
I successfully run `ruby -e 'system({"BUNDLE_GEMFILE" => nil}, "#{command}")'`
|
||||||
STEP
|
STEP
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
When /^I create a new rails application$/ do
|
When(/^I create a new rails application$/) do
|
||||||
options =
|
options =
|
||||||
%w[
|
%w[
|
||||||
--api
|
--api
|
||||||
|
@ -20,15 +20,15 @@ When /^I create a new rails application$/ do
|
||||||
cd("test_app")
|
cd("test_app")
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name|
|
When(/^I add "([^"]+)" from this project as a dependency$/) do |gem_name|
|
||||||
append_to_file("Gemfile", %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n})
|
append_to_file("Gemfile", %(gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n))
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I add "([^"]+)" as a dependency$/ do |gem_name|
|
When(/^I add "([^"]+)" as a dependency$/) do |gem_name|
|
||||||
append_to_file("Gemfile", %{gem "#{gem_name}"\n})
|
append_to_file("Gemfile", %(gem "#{gem_name}"\n))
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I print out "([^"]*)"$/ do |path|
|
When(/^I print out "([^"]*)"$/) do |path|
|
||||||
in_current_dir do
|
in_current_dir do
|
||||||
File.open(path, "r") do |f|
|
File.open(path, "r") do |f|
|
||||||
puts f.inspect
|
puts f.inspect
|
||||||
|
@ -36,7 +36,7 @@ When /^I print out "([^"]*)"$/ do |path|
|
||||||
end
|
end
|
||||||
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
|
append_to_file File.join("config", "application.rb"), <<~RUBY
|
||||||
class TestApp::Application
|
class TestApp::Application
|
||||||
#{string}
|
#{string}
|
||||||
|
@ -44,7 +44,7 @@ When /^I configure the factories as:$/ do |string|
|
||||||
RUBY
|
RUBY
|
||||||
end
|
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
|
append_to_file File.join("config", "application.rb"), <<~RUBY
|
||||||
class TestApp::Application
|
class TestApp::Application
|
||||||
config.generators do |g|
|
config.generators do |g|
|
||||||
|
@ -54,7 +54,7 @@ When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir|
|
||||||
RUBY
|
RUBY
|
||||||
end
|
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
|
in_current_dir do
|
||||||
content = File.read("Gemfile")
|
content = File.read("Gemfile")
|
||||||
File.open("Gemfile", "w") do |f|
|
File.open("Gemfile", "w") do |f|
|
||||||
|
|
|
@ -11,7 +11,7 @@ if RUBY_PLATFORM == "java"
|
||||||
Aruba.configure do |config|
|
Aruba.configure do |config|
|
||||||
config.before_cmd do
|
config.before_cmd do
|
||||||
# disable JIT since these processes are so short lived
|
# 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"]
|
java_options = ENV["JAVA_OPTS"]
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ if RUBY_PLATFORM == "java"
|
||||||
else
|
else
|
||||||
set_env(
|
set_env(
|
||||||
"JAVA_OPTS",
|
"JAVA_OPTS",
|
||||||
"-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}",
|
"-XX:+TieredCompilation -XX:TieredStopAtLevel=1 #{java_options}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ module FactoryBotRails
|
||||||
@generators.test_framework(
|
@generators.test_framework(
|
||||||
test_framework,
|
test_framework,
|
||||||
fixture: false,
|
fixture: false,
|
||||||
fixture_replacement: :factory_bot,
|
fixture_replacement: :factory_bot
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ module FactoryBotRails
|
||||||
def run
|
def run
|
||||||
@generators.fixture_replacement(
|
@generators.fixture_replacement(
|
||||||
fixture_replacement_setting,
|
fixture_replacement_setting,
|
||||||
dir: factory_bot_directory,
|
dir: factory_bot_directory
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ module FactoryBot
|
||||||
File.dirname(__FILE__),
|
File.dirname(__FILE__),
|
||||||
"factory_bot",
|
"factory_bot",
|
||||||
generator_name,
|
generator_name,
|
||||||
"templates",
|
"templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
File.expand_path(path)
|
File.expand_path(path)
|
||||||
|
|
|
@ -8,21 +8,21 @@ module FactoryBot
|
||||||
:attributes,
|
:attributes,
|
||||||
type: :array,
|
type: :array,
|
||||||
default: [],
|
default: [],
|
||||||
banner: "field:type field:type",
|
banner: "field:type field:type"
|
||||||
)
|
)
|
||||||
|
|
||||||
class_option(
|
class_option(
|
||||||
:dir,
|
:dir,
|
||||||
type: :string,
|
type: :string,
|
||||||
default: "test/factories",
|
default: "test/factories",
|
||||||
desc: "The directory or file root where factories belong",
|
desc: "The directory or file root where factories belong"
|
||||||
)
|
)
|
||||||
|
|
||||||
class_option(
|
class_option(
|
||||||
:suffix,
|
:suffix,
|
||||||
type: :string,
|
type: :string,
|
||||||
default: nil,
|
default: nil,
|
||||||
desc: "Suffix to add factory file",
|
desc: "Suffix to add factory file"
|
||||||
)
|
)
|
||||||
|
|
||||||
def create_fixture_file
|
def create_fixture_file
|
||||||
|
@ -43,7 +43,7 @@ module FactoryBot
|
||||||
insert_into_file(
|
insert_into_file(
|
||||||
factories_file,
|
factories_file,
|
||||||
factory_definition,
|
factory_definition,
|
||||||
after: "FactoryBot.define do\n",
|
after: "FactoryBot.define do\n"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,16 +55,16 @@ module FactoryBot
|
||||||
def factory_definition
|
def factory_definition
|
||||||
<<~RUBY
|
<<~RUBY
|
||||||
factory :#{factory_name}#{explicit_class_option} do
|
factory :#{factory_name}#{explicit_class_option} do
|
||||||
#{factory_attributes.gsub(/^/, ' ')}
|
#{factory_attributes.gsub(/^/, " ")}
|
||||||
end
|
end
|
||||||
|
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
def factory_attributes
|
def factory_attributes
|
||||||
attributes.map do |attribute|
|
attributes.map { |attribute|
|
||||||
"#{attribute.name} { #{attribute.default.inspect} }"
|
"#{attribute.name} { #{attribute.default.inspect} }"
|
||||||
end.join("\n")
|
}.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename
|
def filename
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe FactoryBotRails::DefinitionFilePaths do
|
||||||
directories = described_class.new(definition_file_paths).directories
|
directories = described_class.new(definition_file_paths).directories
|
||||||
|
|
||||||
expect(directories).to eq(
|
expect(directories).to eq(
|
||||||
"spec/fixtures/factories" => [:rb],
|
"spec/fixtures/factories" => [:rb]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ describe FactoryBotRails::Reloader do
|
||||||
|
|
||||||
def run_reloader(definition_file_paths)
|
def run_reloader(definition_file_paths)
|
||||||
FactoryBot.definition_file_paths = definition_file_paths
|
FactoryBot.definition_file_paths = definition_file_paths
|
||||||
FactoryBotRails::Reloader.
|
FactoryBotRails::Reloader
|
||||||
new(Rails.application, Rails.application.config).run
|
.new(Rails.application, Rails.application.config).run
|
||||||
end
|
end
|
||||||
|
|
||||||
def reloader_class
|
def reloader_class
|
||||||
|
|
Loading…
Reference in a new issue