require 'spec_helper' describe Mushikago::Tombo::Client do before :all do @client = Mushikago::Tombo::Client.new( :api_key => ENV['MUSHIKAGO_API_KEY'], :secret_key => ENV['MUSHIKAGO_SECRET_KEY'] ) end subject{ @client } it{ should respond_to(:capture) } it{ should respond_to(:captures) } it{ should respond_to(:delete) } it{ should respond_to(:info) } =begin context 'send capture request' do before :all do @response = @client.capture('http://www.tombo.ne.jp/', :thumbnail=>1) end subject{ @response } it{ subject.meta['status'].should == 200 } it{ subject.meta['message'].should == 'OK' } it{ subject.response.should_not be_nil } it{ subject['id'].should_not be_nil } it{ subject['image_url'].should_not be_nil } it{ subject['thumbnail_url'].should_not be_nil } end =end context 'send captures request' do before :all do @response = @client.captures end subject{ @response } it{ subject.meta['status'].should == 200 } it{ subject.meta['message'].should == 'OK' } it{ subject.response.should_not be_nil } it{ subject['total'].should_not be_nil } it{ subject['images'].should_not be_nil } it{ subject['images'].should be_a_kind_of(Enumerable) } it{ subject['images'].should have_at_most(subject['total'].to_i).items } context 'returned images should have keys' do subject{ @response['images'].first } it{ subject['image_id'].should_not be_nil } it{ subject['image_url'].should_not be_nil } it{ subject['image_size'].should_not be_nil } it{ subject['source_url'].should_not be_nil } it{ subject['image_format'].should_not be_nil } it{ subject['image_quality'].should_not be_nil } it{ subject['state'].should_not be_nil } it{ subject['tags'].should_not be_nil } it{ subject['tags'].should be_a_kind_of(Enumerable) } end end context 'send delete request' do before :all do @response = @client.delete('391d7fe4-e9d4-4975-85a3-e5d38a4cd97f') end subject{ @response } it{ subject.meta['status'].should == 200 } it{ subject['id'].should_not be_nil } it{ subject['id'].should == '391d7fe4-e9d4-4975-85a3-e5d38a4cd97f' } end context 'send info request' do before :all do @response = @client.info end subject{ @response } it{ subject.meta['status'].should == 200 } it{ subject['api_count'].should_not be_nil } it{ subject['disk_usage'].should_not be_nil } it{ subject['image_num'].should_not be_nil } end end