Skip to content

Commit

Permalink
[aws|storage] Add mock for Fog::Storage::AWS#put_bucket_website
Browse files Browse the repository at this point in the history
  • Loading branch information
galfert committed Jan 8, 2012
1 parent f07e594 commit d91d4e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/fog/aws/requests/storage/put_bucket_website.rb
Expand Up @@ -44,6 +44,23 @@ def put_bucket_website(bucket_name, suffix, options = {})
end

end

class Mock # :nodoc:all

def put_bucket_website(bucket_name, suffix, options = {})
response = Excon::Response.new
if self.data[:buckets][bucket_name]
response.status = 200
else
response.status = 403
raise(Excon::Errors.status_error({:expects => 200}, response))
end

response
end

end

end
end
end
5 changes: 4 additions & 1 deletion tests/aws/requests/storage/bucket_tests.rb
Expand Up @@ -117,7 +117,6 @@
end

tests("#put_bucket_website('#{@aws_bucket_name}', 'index.html')").succeeds do
pending if Fog.mocking?
Fog::Storage[:aws].put_bucket_website(@aws_bucket_name, 'index.html')
end

Expand Down Expand Up @@ -222,6 +221,10 @@
Fog::Storage[:aws].put_bucket_acl('fognonbucket', 'invalid')
end

tests("#put_bucket_website('fognonbucket', 'index.html')").raises(Excon::Errors::Forbidden) do
Fog::Storage[:aws].put_bucket_website('fognonbucket', 'index.html')
end

end

# don't keep the bucket around
Expand Down

0 comments on commit d91d4e1

Please sign in to comment.