Sha256: a44b5a2a5af90331eab16e7a15cb076ea3a6e4d8cf4ca2a5d7e6746384f4ed2b

Contents?: true

Size: 890 Bytes

Versions: 4

Compression:

Stored size: 890 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::API, '#namespace' do

  class Github::Foo < Github::API; end

  class Github::Foo::Test < Github::API; end

  let(:klass) { Github::Foo }

  let(:method_name) { :test }

  let(:options) { {arg: :custom} }

  subject(:instance) { klass.new }

  before { klass.namespace method_name }

  after { instance.instance_eval { undef :test } }

  it 'creates scope method' do
    expect(instance).to respond_to(method_name)
  end

  it 'returns scoped instance' do
    expect(instance.test).to be_a(Github::Foo::Test)
  end

  it 'passes options through' do
    expect(instance.adapter).to eql(:net_http)
    value = instance.test({adapter: :custom})
    expect(value.adapter).to eql(:custom)
  end

  it "doesn't redifine already existing scope" do
    expect(Github::API::Factory).to_not receive(:new)
    klass.namespace :test
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/api/namespace_spec.rb
github_api-0.12.2 spec/github/api/namespace_spec.rb
github_api-0.12.1 spec/github/api/namespace_spec.rb
github_api-0.12.0 spec/github/api/namespace_spec.rb