Skip to content

Commit

Permalink
Fix rubocop Style/FrozenStringLiteralComment offense
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalonsop committed Oct 22, 2019
1 parent 9ee8fe7 commit bde6c23
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Feature:
And the output should contain "test/factories/namespaced/users.rb"
And the file "test/factories/users.rb" should contain exactly:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :user do
name { 'MyString' }
Expand All @@ -28,13 +30,17 @@ Feature:
Scenario: The factory_bot_rails generators add a factory in the correct spot
When I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
end
"""
And I run `bundle exec rails generate model User name:string` with a clean environment
And I run `bundle exec rails generate model Robot name:string` with a clean environment
Then the file "test/factories.rb" should contain exactly:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :robot do
name { 'MyString' }
Expand All @@ -50,6 +56,8 @@ Feature:
Scenario: The factory_bot_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory
When I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
end
"""
Expand Down
12 changes: 12 additions & 0 deletions features/load_definitions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Feature: automatically load factory definitions
Scenario: generate a Rails application and use factory definitions
When I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :user do
name { 'Frank' }
Expand Down Expand Up @@ -60,6 +62,8 @@ Feature: automatically load factory definitions
"""
When I write to "custom_factories_path.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :user do
name { 'Frank' }
Expand Down Expand Up @@ -95,6 +99,8 @@ Feature: automatically load factory definitions
"""
When I write to "lib/some_railtie/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :factory_from_some_railtie, class: 'User' do
name { 'Artem' }
Expand Down Expand Up @@ -132,6 +138,8 @@ Feature: automatically load factory definitions
"""
When I write to "lib/some_railtie/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :factory_from_some_railtie, class: 'User' do
name { 'Artem' }
Expand Down Expand Up @@ -169,6 +177,8 @@ Feature: automatically load factory definitions
"""
When I write to "lib/some_railtie/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :factory_from_some_railtie, class: 'User' do
name { 'Artem' }
Expand All @@ -177,6 +187,8 @@ Feature: automatically load factory definitions
"""
When I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :user do
name { 'Frank' }
Expand Down
4 changes: 4 additions & 0 deletions features/reloading.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Feature:
"""
And I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :author, class: User do
name { 'Frank' }
Expand Down Expand Up @@ -84,6 +86,8 @@ Scenario: Initializing the reloader with I18n support
"""
And I write to "test/factories.rb" with:
"""
# frozen_string_literal: true
FactoryBot.define do
factory :user do
User::TRANSLATION
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/factory_bot/model/templates/factories.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

FactoryBot.define do
<%= factory_definition.rstrip %>
end

0 comments on commit bde6c23

Please sign in to comment.