Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Cucumber needs to tell FakeWeb the s3_domain_url path for uploading a…
Browse files Browse the repository at this point in the history
… file, and FakeWeb needs to return XML
  • Loading branch information
betesh authored and Jon Yurek committed Aug 20, 2015
1 parent 7b3d2bb commit 9578ba1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions features/step_definitions/s3_steps.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field|
definition = Paperclip::AttachmentRegistry.definitions_for(User)[field.downcase.to_sym]
path = "https://paperclip.s3.amazonaws.com#{definition[:path]}"
path = if defined?(::AWS)
"https://paperclip.s3.amazonaws.com#{definition[:path]}"
else
"https://paperclip.s3-us-west-2.amazonaws.com#{definition[:path]}"
end
path.gsub!(':filename', File.basename(file_path))
path.gsub!(/:([^\/\.]+)/) do |match|
"([^\/\.]+)"
end
FakeWeb.register_uri(:put, Regexp.new(path), :body => "OK")
FakeWeb.register_uri(:put, Regexp.new(path), :body => defined?(::AWS) ? "OK" : "<xml></xml>")
step "I attach the file \"#{file_path}\" to \"#{field}\""
end

Expand Down

0 comments on commit 9578ba1

Please sign in to comment.