2009-09-15 16:56:20 -04:00
|
|
|
Then /^I should find the following for the last (.*):$/ do |model, table|
|
|
|
|
model_class = model.camelize.constantize
|
|
|
|
last_instance = model_class.last or raise "No #{model.pluralize} exist"
|
2009-09-15 17:38:40 -04:00
|
|
|
table.hashes.first.each do |key, value|
|
2009-09-15 16:56:20 -04:00
|
|
|
last_instance.attributes[key].to_s.should == value
|
2009-09-15 15:47:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-15 16:56:20 -04:00
|
|
|
Then /^there should be (\d+) (.*)$/ do |count, model|
|
|
|
|
model_class = model.singularize.camelize.constantize
|
|
|
|
model_class.count.should == count.to_i
|
2009-09-15 15:54:21 -04:00
|
|
|
end
|
|
|
|
|
2011-08-22 13:16:32 -04:00
|
|
|
Then /^the post "([^"]*)" should (not )?have the following tags?:$/ do |post_title, negate, table|
|
|
|
|
post = Post.find_by_title!(post_title)
|
|
|
|
|
|
|
|
table.hashes.each do |row|
|
|
|
|
tag = Tag.find_by_name(row[:name])
|
|
|
|
|
|
|
|
if negate
|
|
|
|
post.tags.should_not include(tag)
|
|
|
|
else
|
|
|
|
post.tags.should include(tag)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Transform /^table:(?:.*,)?tags(?:,.*)?$/ do |table|
|
|
|
|
table.map_column!("tags") do |tags|
|
|
|
|
tags.split(',').map {|tag| Tag.find_by_name! tag.strip }
|
|
|
|
end
|
|
|
|
table
|
|
|
|
end
|
|
|
|
|
2009-09-15 15:54:21 -04:00
|
|
|
Before do
|
|
|
|
Post.delete_all
|
2011-08-22 13:16:32 -04:00
|
|
|
Tag.delete_all
|
2009-09-15 16:56:20 -04:00
|
|
|
User.delete_all
|
2010-06-07 11:46:01 -04:00
|
|
|
Category.delete_all
|
2010-10-28 12:20:24 -04:00
|
|
|
CategoryGroup.delete_all
|
2009-09-15 15:54:21 -04:00
|
|
|
end
|
2010-10-28 12:20:24 -04:00
|
|
|
|