Sha256: cfba05e2658b7d1523a948692af5d285d4fb2139e39127dbd6a15f40b37f4ced

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'json'

describe Parse::Model::Scaffold::ParseApi do

    subject { Parse::Model::Scaffold::ParseApi.new 'my_app_id', 'my_api_key' }

    it 'should exist after creation' do
        subject.should_not be_nil
    end

    it 'should use custom http headers' do
        subject.options.has_key?(:headers).should be_true
    end

    it 'should use app_id as an HTTP header' do
        subject.options[:headers].has_key?('X-Parse-Application-Id').should be_true
        subject.options[:headers]['X-Parse-Application-Id'].should eql('my_app_id')
    end

    it 'should use api_key as an HTTP header' do
        subject.options[:headers].has_key?('X-Parse-REST-API-Key').should be_true
        subject.options[:headers]['X-Parse-REST-API-Key'].should eql('my_api_key')
    end

    it 'should return a single object from get_first' do

        stub_request(:get, "https://api.parse.com/1/classes/testclass?limit=1")
            .to_return(
                :body => JSON.generate(
                    { :results => [{:name => 'mr. ding'}] }
                ),
                :headers => {'Content-Type' => 'application/json'}
            )

        obj = subject.get_first 'testclass'

        obj.nil?.should be_false
        obj.has_key?('name').should be_true
        obj['name'].should eql('mr. ding')
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parse-model-scaffold-0.11.0 spec/parse_api_spec.rb