From 01a23ffbe1ff6e7a938c836649d05002d4a08f59 Mon Sep 17 00:00:00 2001 From: Atul Bhosale Date: Sat, 25 Aug 2018 02:18:00 +0530 Subject: [PATCH] Update ModelGenerator to generate dynamic attributes --- features/generators.feature | 6 +++--- features/load_definitions.feature | 4 ++-- lib/generators/factory_bot/model/model_generator.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/generators.feature b/features/generators.feature index 2227e2c..7fa3963 100644 --- a/features/generators.feature +++ b/features/generators.feature @@ -18,8 +18,8 @@ Feature: """ FactoryBot.define do factory :user do - name "MyString" - age 1 + name { "MyString" } + age { 1 } end end @@ -38,7 +38,7 @@ Feature: """ FactoryBot.define do factory :user do - name "MyString" + name { "MyString" } end end """ diff --git a/features/load_definitions.feature b/features/load_definitions.feature index 13055af..2a21163 100644 --- a/features/load_definitions.feature +++ b/features/load_definitions.feature @@ -35,7 +35,7 @@ Feature: automatically load step definitions """ FactoryBot.define do factory :user do - name "Frank" + name { "Frank" } end end """ @@ -73,7 +73,7 @@ Feature: automatically load step definitions """ FactoryBot.define do factory :factory_from_some_railtie, class: 'User' do - name 'Artem' + name { 'Artem' } end end """ diff --git a/lib/generators/factory_bot/model/model_generator.rb b/lib/generators/factory_bot/model/model_generator.rb index 95e993a..d5a49eb 100644 --- a/lib/generators/factory_bot/model/model_generator.rb +++ b/lib/generators/factory_bot/model/model_generator.rb @@ -70,7 +70,7 @@ RUBY def factory_attributes attributes.map do |attribute| - "#{attribute.name} #{attribute.default.inspect}" + "#{attribute.name} { #{attribute.default.inspect} }" end.join("\n") end