Sha256: a25ecf4cb7852a46e6c234c4d33fa40bf1a5abf4d0f631a10652aeba5be9b4b1
Contents?: true
Size: 1.06 KB
Versions: 6
Compression:
Stored size: 1.06 KB
Contents
def create_user(name, type = 'User') type.camelize.constantize. find_or_create_by_first_name_and_last_name *name.split(' '), :username => name.gsub(' ', '').underscore end Given /^(a|\d+)( published)? posts?(?: with the title "([^"]*)")?(?: and body "([^"]*)")?(?: written by "([^"]*)")? exists?$/ do |count, published, title, body, user| count = count == 'a' ? 1 : count.to_i published = Time.now if published author = create_user(user) if user title ||= "Hello World %i" count.times do |i| Post.create! :title => title % i, :body => body, :author => author, :published_at => published 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| click_link "Posts" click_link "New Post" fill_in :title, :with => title click_button "Create Post" end
Version data entries
6 entries across 6 versions & 1 rubygems