Sha256: ea2ca29df96d1d234d94b44530cd73f306342c73b3354f39776a78f853b23476

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

def create_user(name, type = 'User')
  first_name, last_name = name.split(' ')
  user = type.camelize.constantize.where(first_name: first_name, last_name: last_name).first_or_create(username: name.tr(' ', '').underscore)
end

Given /^(a|\d+)( published)? posts?(?: with the title "([^"]*)")?(?: and body "([^"]*)")?(?: written by "([^"]*)")?(?: in category "([^"]*)")? exists?$/ do |count, published, title, body, user, category_name|
  count     = count == 'a' ? 1 : count.to_i
  published = Time.now          if published
  author    = create_user(user) if user
  category  = Category.where(name: category_name).first_or_create if category_name
  title   ||= "Hello World %i"
  count.times do |i|
    Post.create! title: title % i, body: body, author: author, published_at: published, custom_category_id: category.try(:id)
  end
end

Given /^a category named "([^"]*)" exists$/ do |name|
  Category.create! name: name
end

Given /^a (user|publisher) named "([^"]*)" exists$/ do |type, name|
  create_user name, type
end

Given /^a store named "([^"]*)" exists$/ do |name|
  Store.create! name: name
end

Given /^I create a new post with the title "([^"]*)"$/ do |title|
  first(:link, 'Posts').click
  click_link "New Post"
  fill_in 'post_title', with: title
  click_button "Create Post"
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.17.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.16.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.15.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.14.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.13.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.12.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.11.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.10.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.9.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.8.pre features/step_definitions/factory_steps.rb
activeadmin-1.0.0.pre1 features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.7.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.6.pre features/step_definitions/factory_steps.rb
yousty-activeadmin-1.0.5.pre features/step_definitions/factory_steps.rb