forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnamespace_spec.rb
More file actions
41 lines (27 loc) · 890 Bytes
/
namespace_spec.rb
File metadata and controls
41 lines (27 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# 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