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

fix indent of generated factory file

This commit is contained in:
Takeo Fujita 2014-10-30 21:58:52 +09:00 committed by Joshua Clayton
parent a60c1c79f5
commit 3488c767c7
2 changed files with 13 additions and 4 deletions

View file

@ -10,11 +10,20 @@ Feature:
Scenario: The factory_girl_rails generators create a factory file for each model if there is not a factories.rb file
When I run `bundle install` with a clean environment
And I run `bundle exec rails generate model User name:string` with a clean environment
And I run `bundle exec rails generate model User name:string age:integer` with a clean environment
And I run `bundle exec rails generate model Namespaced::User name:string` with a clean environment
Then the output should contain "test/factories/users.rb"
And the output should contain "test/factories/namespaced_users.rb"
And the file "test/factories/users.rb" should contain "factory :user do"
And the file "test/factories/users.rb" should contain exactly:
"""
FactoryGirl.define do
factory :user do
name "MyString"
age 1
end
end
"""
And the file "test/factories/namespaced_users.rb" should contain "factory :namespaced_user, :class => 'Namespaced::User' do"
Scenario: The factory_girl_rails generators does not create a factory file for each model if there is a factories.rb file in the test directory

View file

@ -49,7 +49,7 @@ module FactoryGirl
def factory_definition
<<-RUBY
factory :#{singular_table_name}#{explicit_class_option} do
#{factory_attributes}
#{factory_attributes.gsub(/^/, " ")}
end
RUBY
end
@ -57,7 +57,7 @@ RUBY
def single_file_factory_definition
<<-RUBY
FactoryGirl.define do
#{factory_definition}
#{factory_definition.chomp}
end
RUBY
end