Sha256: 5841dd81ea7e653cd332a96a49dea57cab95b797b38fc0d3077a8178d70493c4

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

require File.expand_path(
        File.join(File.dirname(__FILE__), '..', 'spec_helper'))

module GitHubTest
  describe GitHub::Base do
    after(:each) do
      api.auth.clear
    end

    context 'general' do
      it 'has instance and class method api pointing to the same Api instance' do
        api1 = described_class.api
        api2 = described_class.new.api
        api1.should be_a GitHub::Api
        api1.should be_equal api2
        api1.should be_equal api
      end
    end

    context 'requests' do
      it 'submits appropriate requests to api as get/post methods (both class and instance)' do
        base = described_class.new
        api.should_receive(:request).with(:get, '/blah', anything()).twice
        base.get ('/blah')
        described_class.get ('/blah')

        api.should_receive(:request).with(:post, '/blah', anything()).twice
        base.post ('/blah')
        described_class.post ('/blah')
      end

      it 'prepends get/post calls by content of @base_uri variable' do
        base = described_class.new
        described_class.class_eval { @base_uri = 'http://base1.com' }
        api.should_receive(:request).with(:get, 'http://base1.com/blah', anything()).twice
        base.get ('/blah')
        described_class.get ('/blah')

        api.should_receive(:request).with(:post, 'http://base1.com/blah', anything()).twice
        base.post ('/blah')
        described_class.post ('/blah')
      end
    end                                                
  end
end # module GitHubTest

# EOF

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_hub-0.2.7 spec/git_hub/base_spec.rb
git_hub-0.2.0 spec/git_hub/base_spec.rb