Skip to content

Instantly share code, notes, and snippets.

@maurcs
Created February 15, 2010 20:45
Show Gist options
  • Save maurcs/304970 to your computer and use it in GitHub Desktop.
Save maurcs/304970 to your computer and use it in GitHub Desktop.
Then /^the "([^\"]*)" "([^\"]*)" should have a "([^\"]*)" attachment$/ do |meth, mdl, field|
user = mdl.constantize.send(meth,:order=>"created_at")
user.image.should be_a_kind_of Grip::Attachment
end
Given I am on create account
...
When I attach the file "features/support/assets/test_profile_image.jpg" to "user[image]"
When I press "Save Changes"
Then my account should be created
And the "last" "User" should have a "image" attachment
...
# Adds support for validates_attachment_content_type. Without the mime-type getting
# passed to attach_file() you will get a "Photo file is not one of the allowed file types."
# error message
When /^(?:|I )attach the file "([^\"]*)" to "([^\"]*)"$/ do |path, field|
type = path.split(".")[1]
case type
when "jpg"
type = "image/jpg"
when "jpeg"
type = "image/jpeg"
when "png"
type = "image/png"
when "gif"
type = "image/gif"
end
attach_file(field, path, type)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment