11require 'spec_helper'
22
33describe Cloudability ::Client ::Organizations do
4+ let ( :client ) { Cloudability ::Client . new ( auth_token : 'token' ) }
45
5- before do
6- @client = Cloudability ::Client . new ( auth_token : 'token' )
7- end
8-
96 describe '#my_organization' do
107 it 'should be a Hashie::Mashe' do
118 stub_get ( '/1/organizations?auth_token=token' , 'organization' )
12- @ client. my_organization . should be_kind_of Hashie ::Mash
9+ client . my_organization . should be_kind_of Hashie ::Mash
1310 end
1411 end
1512
1613 describe '#organization_invitations' do
1714 it 'should be an Array' do
1815 stub_get ( '/1/organizations/invitations?auth_token=token' , 'organization_invitations' )
19- @ client. organization_invitations . should be_kind_of Array
16+ client . organization_invitations . should be_kind_of Array
2017 end
2118
2219 it 'should be an array of Hashie::Mashes' do
2320 stub_get ( '/1/organizations/invitations?auth_token=token' , 'organization_invitations' )
24- @ client. organization_invitations . each { |invite | invite . should be_kind_of Hashie ::Mash }
21+ client . organization_invitations . each { |invite | invite . should be_kind_of Hashie ::Mash }
2522 end
2623
2724 it 'should be mappable by ID' do
2825 stub_get ( '/1/organizations/invitations?auth_token=token' , 'organization_invitations' )
29- @ client. organization_invitations . map ( &:id ) . should be_kind_of Array
26+ client . organization_invitations . map ( &:id ) . should be_kind_of Array
3027 end
3128
3229 it 'should be mappable by ID and not be empty' do
3330 stub_get ( '/1/organizations/invitations?auth_token=token' , 'organization_invitations' )
34- @ client. organization_invitations . map ( &:id ) . should_not be_empty
31+ client . organization_invitations . map ( &:id ) . should_not be_empty
3532 end
3633 end
3734
3835 describe '#organization_roles' do
3936 it 'should be an Array' do
4037 stub_get ( '/1/organizations/roles?auth_token=token' , 'organization_roles' )
41- @ client. organization_roles . should be_kind_of Array
38+ client . organization_roles . should be_kind_of Array
4239 end
4340
4441 it 'should be an array of Hashie::Mashes' do
4542 stub_get ( '/1/organizations/roles?auth_token=token' , 'organization_roles' )
46- @ client. organization_roles . each { |role | role . should be_kind_of Hashie ::Mash }
43+ client . organization_roles . each { |role | role . should be_kind_of Hashie ::Mash }
4744 end
4845 end
4946
5047 describe '#invite_user' do
5148 it 'should be a Hashie::Mash' do
5249 stub_post ( '/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com' , 'organization_invitation' )
53- @ client. invite_user ( 'colbyaleyrb@gmail.com' ) . should be_kind_of Hashie ::Mash
50+ client . invite_user ( 'colbyaleyrb@gmail.com' ) . should be_kind_of Hashie ::Mash
5451 end
5552
5653 it 'should accept a hash with email and name' do
5754 stub_post ( '/1/organizations/invitations?auth_token=token&email=colbyaleyrb%40gmail.com&name=colby' , 'organization_invitation' )
58- expect { @ client. invite_user ( 'colbyaleyrb@gmail.com' , name : 'colby' ) } . not_to raise_exception
55+ expect { client . invite_user ( 'colbyaleyrb@gmail.com' , name : 'colby' ) } . not_to raise_exception
5956 end
6057 end
6158
6259 describe '#delete_invite' do
6360 it 'should should not raise an exception when id is provided' do
6461 stub_delete ( '/1/organizations/invitations/1?auth_token=token' , 'organization_invitation' )
65- expect { @ client. delete_invite ( 1 ) } . not_to raise_exception
62+ expect { client . delete_invite ( 1 ) } . not_to raise_exception
6663 end
6764
6865 it 'should require id as an argument' do
69- expect { @ client. delete_invite } . to raise_exception ( ArgumentError )
66+ expect { client . delete_invite } . to raise_exception ( ArgumentError )
7067 end
7168 end
7269
7370 describe '#update_invite' do
7471 it 'should should not raise an exception when id and role_id are provided' do
7572 stub_put ( '/1/organizations/invitations/1?role_id=1&auth_token=token' , 'organization_invitation' )
76- expect { @ client. update_invite ( 1 , 1 ) } . not_to raise_exception
73+ expect { client . update_invite ( 1 , 1 ) } . not_to raise_exception
7774 end
7875
7976 it 'should require id and role_id as arguments' do
80- expect { @ client. update_invite } . to raise_exception ( ArgumentError )
77+ expect { client . update_invite } . to raise_exception ( ArgumentError )
8178 end
8279 end
83- end
80+ end
0 commit comments