spec/capistrano/cloudflare_spec.rb in capistrano-cloudflare-0.0.2 vs spec/capistrano/cloudflare_spec.rb in capistrano-cloudflare-1.0.0
- old
+ new
@@ -1,30 +1,22 @@
require 'spec_helper'
describe Capistrano::CloudFlare do
- before do
- @configuration = Capistrano::Configuration.new
- Capistrano::CloudFlare.load_into(@configuration)
- @options = { :domain => 'example.com',
- :email => 'me@example.com',
- :api_key => 'F' }
- stub_request(:post, 'https://www.cloudflare.com/api_json.html').to_return(
- :status => 200, :body => '{}'
- )
+ it { should be_a Module }
- end
+ describe '.send_request' do
+ it 'should POST to the cloudflare API and return the response body as a hash' do
+ options = {
+ domain: 'example.com',
+ email: 'me@example.com',
+ api_key: 'F'
+ }
- it { described_class.should be_a Module }
+ body = { 'result' => 'success' }
+ stub_request(:post, 'https://www.cloudflare.com/api_json.html').to_return(
+ :status => 200, :body => body.to_json
+ )
- specify 'cloudflare:cache:purge' do
- @configuration.find_task('cloudflare:cache:purge').should_not == nil
- expect { @configuration.find_and_execute_task('cloudflare:cache:purge') }.to raise_error
-
- @configuration.set(:cloudflare_options, @options)
- expect { @configuration.find_and_execute_task('cloudflare:cache:purge') }.to_not raise_error
- end
-
- specify 'send_request' do
- # TODO: Improve testing here
- described_class.send_request(@options).should be_a_kind_of(Hash)
+ Capistrano::CloudFlare.send_request(options).should eq(body)
+ end
end
end