Module: StoryFactoryMethods

Defined in:
lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb

Instance Method Summary collapse

Instance Method Details

#new_story(name, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb', line 2

def new_story(name, options = {})
  factory = options[:factory] || :story
  attributes = options[:attributes] || {}
  
  attributes.merge!({name: name})
  set_story_defaults(attributes)
  @story = Factory(factory, attributes)
  
  @story.reload
end

#set_story_defaults(attributes) ⇒ Object



13
14
15
16
# File 'lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb', line 13

def set_story_defaults(attributes)
  attributes[:offeror_id] ||= @me.id if @me && !attributes[:offeror_id]
  attributes[:project_id] ||= @project.id if @project && !attributes[:project_id]
end