Skip to content

Commit 1c50861

Browse files
author
Awesome Code
committed
Auto corrected by following Lint Ruby Layout/HeredocIndentation
1 parent 6fecdd7 commit 1c50861

File tree

63 files changed

+1299
-1299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1299
-1299
lines changed

lib/factory_bot/convert_factory_girl_to_factory_bot.rb

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
Synvert::Rewriter.new 'factory_bot', 'convert_factory_girl_to_factory_bot' do
2-
description <<-EOF
3-
It converts factory_girl to factory_bot
4-
5-
require 'factory_girl'
6-
require 'factory_girl_rails'
7-
=>
8-
require 'factory_bot'
9-
require 'factory_bot_rails'
10-
11-
RSpec.configure do |config|
12-
config.include FactoryGirl::Syntax::Methods
13-
end
14-
=>
15-
RSpec.configure do |config|
16-
config.include FactoryBot::Syntax::Methods
17-
end
18-
19-
20-
FactoryGirl.define do
21-
factory :user do
22-
email { Faker::Internet.email }
23-
username Faker::Name.first_name.downcase
24-
password "Sample:1"
25-
password_confirmation "Sample:1"
26-
end
27-
end
28-
=>
29-
FactoryBot.define do
30-
factory :user do
31-
email { Faker::Internet.email }
32-
username Faker::Name.first_name.downcase
33-
password "Sample:1"
34-
password_confirmation "Sample:1"
35-
end
36-
end
37-
38-
user = FactoryGirl.create(:user)
39-
=>
40-
user = FactoryBot.create(:user)
2+
description <<~EOF
3+
It converts factory_girl to factory_bot
4+
5+
require 'factory_girl'
6+
require 'factory_girl_rails'
7+
=>
8+
require 'factory_bot'
9+
require 'factory_bot_rails'
10+
11+
RSpec.configure do |config|
12+
config.include FactoryGirl::Syntax::Methods
13+
end
14+
=>
15+
RSpec.configure do |config|
16+
config.include FactoryBot::Syntax::Methods
17+
end
18+
19+
20+
FactoryGirl.define do
21+
factory :user do
22+
email { Faker::Internet.email }
23+
username Faker::Name.first_name.downcase
24+
password "Sample:1"
25+
password_confirmation "Sample:1"
26+
end
27+
end
28+
=>
29+
FactoryBot.define do
30+
factory :user do
31+
email { Faker::Internet.email }
32+
username Faker::Name.first_name.downcase
33+
password "Sample:1"
34+
password_confirmation "Sample:1"
35+
end
36+
end
37+
38+
user = FactoryGirl.create(:user)
39+
=>
40+
user = FactoryBot.create(:user)
4141
EOF
4242

4343
within_files '{test,spec}/**/*.rb' do

lib/factory_bot/deprecate_static_value.rb

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
Synvert::Rewriter.new 'factory_bot', 'deprecate_static_value' do
2-
description <<-EOF
3-
It deprecates factory_bot static value
4-
5-
FactoryBot.define do
6-
factory :post do
7-
user
8-
association :user
9-
title "Something"
10-
comments_count 0
11-
tag Tag::MAGIC
12-
recent_statuses []
13-
status([:draft, :published].sample)
14-
published_at 1.day.from_now
15-
created_at(1.day.ago)
16-
updated_at Time.current
17-
update_times [Time.current]
18-
meta_tags(foo: Time.current)
19-
other_tags({ foo: Time.current })
20-
options color: :blue
21-
trait :old do
22-
published_at 1.week.ago
2+
description <<~EOF
3+
It deprecates factory_bot static value
4+
5+
FactoryBot.define do
6+
factory :post do
7+
user
8+
association :user
9+
title "Something"
10+
comments_count 0
11+
tag Tag::MAGIC
12+
recent_statuses []
13+
status([:draft, :published].sample)
14+
published_at 1.day.from_now
15+
created_at(1.day.ago)
16+
updated_at Time.current
17+
update_times [Time.current]
18+
meta_tags(foo: Time.current)
19+
other_tags({ foo: Time.current })
20+
options color: :blue
21+
trait :old do
22+
published_at 1.week.ago
23+
end
24+
end
2325
end
24-
end
25-
end
26-
=>
27-
FactoryBot.define do
28-
factory :post do
29-
user
30-
association :user
31-
title { "Something" }
32-
comments_count { 0 }
33-
tag { Tag::MAGIC }
34-
recent_statuses { [] }
35-
status { [:draft, :published].sample }
36-
published_at { 1.day.from_now }
37-
created_at { 1.day.ago }
38-
updated_at { Time.current }
39-
update_times { [Time.current] }
40-
meta_tags { { foo: Time.current } }
41-
other_tags { { foo: Time.current } }
42-
options { { color: :blue } }
43-
trait :old do
44-
published_at { 1.week.ago }
26+
=>
27+
FactoryBot.define do
28+
factory :post do
29+
user
30+
association :user
31+
title { "Something" }
32+
comments_count { 0 }
33+
tag { Tag::MAGIC }
34+
recent_statuses { [] }
35+
status { [:draft, :published].sample }
36+
published_at { 1.day.from_now }
37+
created_at { 1.day.ago }
38+
updated_at { Time.current }
39+
update_times { [Time.current] }
40+
meta_tags { { foo: Time.current } }
41+
other_tags { { foo: Time.current } }
42+
options { { color: :blue } }
43+
trait :old do
44+
published_at { 1.week.ago }
45+
end
46+
end
4547
end
46-
end
47-
end
4848
EOF
4949

5050
within_files '{test,spec}/factories/**/*.rb' do

lib/factory_girl/fix_deprecations.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
Synvert::Rewriter.new 'factory_girl', 'fix_deprecations' do
2-
description <<-EOF
3-
It converts deprecations
4-
5-
Factory
6-
7-
Factory.sequence :login do |n|
8-
"new_user_\#{n}"
9-
end
10-
Factory.define :user do |user|
11-
user.admin true
12-
user.login { Factory.next(:login) }
13-
user.sequence(:email) { |n| "user\#{n}@gmail.com" }
14-
user.after_create { |instance| create_list(:post, 5, user: instance) }
15-
end
16-
17-
=>
18-
19-
FactoryGirl.define do
20-
sequence :user do |n|
21-
"new_user_\#{n}"
22-
end
23-
factory :user do |user|
24-
admin true
25-
login { generate(:login) }
26-
sequence(:email) { |n| "user\#{n}@gmail.com" }
27-
after(:create) { |instance| create_list(:post, 5, user: instance) }
28-
end
29-
end
30-
31-
Test
32-
33-
Factory(:user) => create(:user)
34-
Factory.next(:email) => generate(:email)
35-
Factory.stub(:comment) => build_stubbed(:comment)
36-
Factory.create(:user) => create(:user)
37-
Factory.build(:use) => build(:user)
38-
Factory.attributes_for(:user) => attributes_for(:user)
39-
2+
description <<~EOF
3+
It converts deprecations
4+
5+
Factory
6+
7+
Factory.sequence :login do |n|
8+
"new_user_\#{n}"
9+
end
10+
Factory.define :user do |user|
11+
user.admin true
12+
user.login { Factory.next(:login) }
13+
user.sequence(:email) { |n| "user\#{n}@gmail.com" }
14+
user.after_create { |instance| create_list(:post, 5, user: instance) }
15+
end
16+
17+
=>
18+
19+
FactoryGirl.define do
20+
sequence :user do |n|
21+
"new_user_\#{n}"
22+
end
23+
factory :user do |user|
24+
admin true
25+
login { generate(:login) }
26+
sequence(:email) { |n| "user\#{n}@gmail.com" }
27+
after(:create) { |instance| create_list(:post, 5, user: instance) }
28+
end
29+
end
30+
31+
Test
32+
33+
Factory(:user) => create(:user)
34+
Factory.next(:email) => generate(:email)
35+
Factory.stub(:comment) => build_stubbed(:comment)
36+
Factory.create(:user) => create(:user)
37+
Factory.build(:use) => build(:user)
38+
Factory.attributes_for(:user) => attributes_for(:user)
39+
4040
EOF
4141

4242
if_gem 'factory_girl', { gte: '2.0.0' }

lib/factory_girl/use_short_syntax.rb

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
Synvert::Rewriter.new 'factory_girl', 'use_short_syntax' do
2-
description <<-EOF
3-
Uses FactoryGirl short syntax.
4-
5-
1. it adds FactoryGirl::Syntax::Methods module to RSpec, Test::Unit, Cucumber, Spainach, MiniTest, MiniTest::Spec, minitest-rails.
6-
7-
# rspec
8-
RSpec.configure do |config|
9-
config.include FactoryGirl::Syntax::Methods
10-
end
11-
12-
# Test::Unit
13-
class Test::Unit::TestCase
14-
include FactoryGirl::Syntax::Methods
15-
end
16-
17-
# Cucumber
18-
World(FactoryGirl::Syntax::Methods)
19-
20-
# Spinach
21-
class Spinach::FeatureSteps
22-
include FactoryGirl::Syntax::Methods
23-
end
24-
25-
# MiniTest
26-
class MiniTest::Unit::TestCase
27-
include FactoryGirl::Syntax::Methods
28-
end
29-
30-
# MiniTest::Spec
31-
class MiniTest::Spec
32-
include FactoryGirl::Syntax::Methods
33-
end
34-
35-
# minitest-rails
36-
class MiniTest::Rails::ActiveSupport::TestCase
37-
include FactoryGirl::Syntax::Methods
38-
end
39-
40-
2. it converts to short syntax.
41-
42-
FactoryGirl.create(...) => create(...)
43-
FactoryGirl.build(...) => build(...)
44-
FactoryGirl.attributes_for(...) => attributes_for(...)
45-
FactoryGirl.build_stubbed(...) => build_stubbed(...)
46-
FactoryGirl.create_list(...) => create_list(...)
47-
FactoryGirl.build_list(...) => build_list(...)
48-
FactoryGirl.create_pair(...) => create_pair(...)
49-
FactoryGirl.build_pair(...) => build_pair(...)
2+
description <<~EOF
3+
Uses FactoryGirl short syntax.
4+
5+
1. it adds FactoryGirl::Syntax::Methods module to RSpec, Test::Unit, Cucumber, Spainach, MiniTest, MiniTest::Spec, minitest-rails.
6+
7+
# rspec
8+
RSpec.configure do |config|
9+
config.include FactoryGirl::Syntax::Methods
10+
end
11+
12+
# Test::Unit
13+
class Test::Unit::TestCase
14+
include FactoryGirl::Syntax::Methods
15+
end
16+
17+
# Cucumber
18+
World(FactoryGirl::Syntax::Methods)
19+
20+
# Spinach
21+
class Spinach::FeatureSteps
22+
include FactoryGirl::Syntax::Methods
23+
end
24+
25+
# MiniTest
26+
class MiniTest::Unit::TestCase
27+
include FactoryGirl::Syntax::Methods
28+
end
29+
30+
# MiniTest::Spec
31+
class MiniTest::Spec
32+
include FactoryGirl::Syntax::Methods
33+
end
34+
35+
# minitest-rails
36+
class MiniTest::Rails::ActiveSupport::TestCase
37+
include FactoryGirl::Syntax::Methods
38+
end
39+
40+
2. it converts to short syntax.
41+
42+
FactoryGirl.create(...) => create(...)
43+
FactoryGirl.build(...) => build(...)
44+
FactoryGirl.attributes_for(...) => attributes_for(...)
45+
FactoryGirl.build_stubbed(...) => build_stubbed(...)
46+
FactoryGirl.create_list(...) => create_list(...)
47+
FactoryGirl.build_list(...) => build_list(...)
48+
FactoryGirl.create_pair(...) => create_pair(...)
49+
FactoryGirl.build_pair(...) => build_pair(...)
5050
EOF
5151

5252
if_gem 'factory_girl', { gte: '2.0.0' }

lib/rails/add_active_record_migration_rails_version.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Synvert::Rewriter.new 'rails', 'add_active_record_migration_rails_version' do
2-
description <<-EOF
3-
It adds default ActiveRecord::Migration rails version.
4-
5-
class CreateUsers < ActiveRecord::Migration
6-
end
7-
8-
=>
9-
10-
class CreateUsers < ActiveRecord::Migration[4.2]
11-
end
2+
description <<~EOF
3+
It adds default ActiveRecord::Migration rails version.
4+
5+
class CreateUsers < ActiveRecord::Migration
6+
end
7+
8+
=>
9+
10+
class CreateUsers < ActiveRecord::Migration[4.2]
11+
end
1212
EOF
1313

1414
if_gem 'rails', { gte: '5.0.0' }

0 commit comments

Comments
 (0)