|
2 | 2 |
|
3 | 3 | require 'spec_helper' |
4 | 4 |
|
5 | | -describe Github::API do |
6 | | - subject { described_class.new(options) } |
7 | | - |
8 | | - it { described_class.included_modules.should include Github::Authorization } |
9 | | - it { described_class.included_modules.should include Github::MimeType } |
10 | | - it { described_class.included_modules.should include Github::Request::Verbs } |
11 | | - |
12 | | - context 'actions' do |
13 | | - let(:options) { { } } |
14 | | - let(:repos) { Github::Client::Repos } |
15 | | - |
16 | | - it { should respond_to :api_methods_in } |
17 | | - |
| 5 | +RSpec.describe Github::API do |
| 6 | + context '#actions' do |
18 | 7 | it 'dynamically adds actions inspection to classes inheriting from api' do |
19 | | - repos.should respond_to :actions |
20 | | - repos.new.should respond_to :actions |
| 8 | + repos = Github::Client::Repos |
| 9 | + expect(repos).to respond_to(:actions) |
| 10 | + expect(repos.new).to respond_to(:actions) |
21 | 11 | end |
22 | 12 |
|
23 | 13 | it 'ensures output contains api methods' do |
24 | | - methods = [ 'method_a', 'method_b'] |
25 | | - repos.stub(:instance_methods).and_return methods |
26 | | - expect(subject.api_methods_in(repos)).to eq(['method_a', 'method_b']) |
| 14 | + repos = Github::Client::Repos |
| 15 | + methods = [:method_a, :method_b] |
| 16 | + allow(repos).to receive(:instance_methods).and_return(methods) |
| 17 | + expect(repos.new.api_methods_in(repos)).to eq([:method_a, :method_b]) |
27 | 18 | end |
28 | 19 | end |
29 | 20 |
|
30 | | - context 'process_basic_auth' do |
31 | | - let(:options) { { :basic_auth => 'login:password' } } |
| 21 | + context '#extract_basic_auth' do |
| 22 | + let(:options) { { basic_auth: 'piotr:secret' } } |
32 | 23 |
|
33 | | - its(:login) { should eq 'login' } |
34 | | - |
35 | | - its(:password) { should eq 'password' } |
| 24 | + it "extracts login from :basic_auth param" do |
| 25 | + api = Github::API.new(options) |
| 26 | + expect(api.login).to eq('piotr') |
| 27 | + end |
36 | 28 |
|
37 | | - its(:basic_auth) { should eq 'login:password' } |
| 29 | + it "extracts password from :basic_auth param" do |
| 30 | + api = Github::API.new(options) |
| 31 | + expect(api.password).to eq('secret') |
| 32 | + end |
38 | 33 | end |
39 | 34 | end # Github::API |
0 commit comments