socialcast 1.3.16 → 1.3.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,8 +49,8 @@ describe Socialcast::CommandLine::LDAPConnector do
49
49
  let(:ldap) { double(Net::LDAP, :open => nil, :encryption => nil, :auth => nil) }
50
50
 
51
51
  before do
52
- ldap.stub(:open).and_yield
53
- Net::LDAP.stub(:new).and_return(ldap)
52
+ allow(ldap).to receive(:open).and_yield
53
+ allow(Net::LDAP).to receive(:new).and_return(ldap)
54
54
  end
55
55
 
56
56
  def create_entry(cn, entry_attributes)
@@ -66,7 +66,7 @@ describe Socialcast::CommandLine::LDAPConnector do
66
66
  let(:connector) { Socialcast::CommandLine::LDAPConnector.new('connection_1', ldap_config) }
67
67
  let(:entry) { create_entry('user', :mail => 'user@example.com', :givenName => 'first name', :sn => 'last name') }
68
68
  before do
69
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
69
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
70
70
  end
71
71
  it do
72
72
  expect do |blk|
@@ -88,7 +88,7 @@ describe Socialcast::CommandLine::LDAPConnector do
88
88
  let(:connector) { Socialcast::CommandLine::LDAPConnector.new('connection_1', ldap_config) }
89
89
  let(:entry) { create_entry('user', :mail => nil, :givenName => 'first name', :sn => 'last name') }
90
90
  before do
91
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
91
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
92
92
  end
93
93
  it 'does not yield the entry' do
94
94
  expect do |blk|
@@ -108,7 +108,7 @@ describe Socialcast::CommandLine::LDAPConnector do
108
108
  let(:connector) { Socialcast::CommandLine::LDAPConnector.new('connection_1', ldap_config) }
109
109
  let(:entry) { create_entry('user', :uid => 'unique identifier', :givenName => 'first name', :sn => 'last name') }
110
110
  before do
111
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'uid', 'isMemberOf'])).and_yield(entry)
111
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'uid', 'isMemberOf'])).and_yield(entry)
112
112
  end
113
113
  it do
114
114
  expect do |blk|
@@ -137,7 +137,7 @@ describe Socialcast::CommandLine::LDAPConnector do
137
137
  }
138
138
  end
139
139
  before do
140
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
140
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
141
141
  end
142
142
  it "does not retrieve the profile photo data from ldap" do
143
143
  expect do |blk|
@@ -170,10 +170,10 @@ describe Socialcast::CommandLine::LDAPConnector do
170
170
  }
171
171
  end
172
172
  before do
173
- ldap.should_receive(:search).once.ordered.with(hash_including(:attributes => ['mail']))
173
+ expect(ldap).to receive(:search).once.ordered.with(hash_including(:attributes => ['mail']))
174
174
  .and_yield(employee_mail_entry)
175
175
  .and_yield(manager_mail_entry)
176
- ldap.should_receive(:search).once.ordered.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf']))
176
+ expect(ldap).to receive(:search).once.ordered.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf']))
177
177
  .and_yield(employee_entry)
178
178
  .and_yield(manager_entry)
179
179
  end
@@ -233,14 +233,14 @@ describe Socialcast::CommandLine::LDAPConnector do
233
233
  }
234
234
  end
235
235
  before do
236
- ldap.should_receive(:search).once.ordered.with(hash_including(:attributes => ['mail']))
236
+ expect(ldap).to receive(:search).once.ordered.with(hash_including(:attributes => ['mail']))
237
237
  .and_yield(employee_mail_entry1)
238
238
  .and_yield(employee_mail_entry2)
239
239
  .and_yield(employee_mail_entry3)
240
240
  .and_yield(manager_mail_entry1)
241
241
  .and_yield(manager_mail_entry2)
242
242
 
243
- ldap.should_receive(:search).once.ordered.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf']))
243
+ expect(ldap).to receive(:search).once.ordered.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf']))
244
244
  .and_yield(employee_entry1)
245
245
  .and_yield(employee_entry2)
246
246
  .and_yield(employee_entry3)
@@ -329,7 +329,7 @@ describe Socialcast::CommandLine::LDAPConnector do
329
329
  before do
330
330
  connection.merge!({ "mappings" => { "email" => "mailConnection" } })
331
331
  entry = create_entry 'user', :mailConnection => 'user@example.com'
332
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mailConnection', 'isMemberOf'])).and_yield(entry)
332
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mailConnection', 'isMemberOf'])).and_yield(entry)
333
333
  end
334
334
  it do
335
335
  expect do |blk|
@@ -362,7 +362,7 @@ describe Socialcast::CommandLine::LDAPConnector do
362
362
  }
363
363
  })
364
364
  entry = create_entry 'user', :mail => 'user@example.com', :givenName => 'first name', :sn => 'last name', :memberOf => ldap_groups
365
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'memberOf'])).and_yield(entry)
365
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'memberOf'])).and_yield(entry)
366
366
  end
367
367
  it do
368
368
  expect do |blk|
@@ -388,7 +388,7 @@ describe Socialcast::CommandLine::LDAPConnector do
388
388
  :isMemberOf => ["cn=External,dc=example,dc=com", "cn=TownHallAdmins,dc=example,dc=com"])
389
389
  end
390
390
  before do
391
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
391
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
392
392
  end
393
393
  it "sets the account_type to 'external' and does not include roles" do
394
394
  expect do |blk|
@@ -413,7 +413,7 @@ describe Socialcast::CommandLine::LDAPConnector do
413
413
  :isMemberOf => ["cn=TownHallAdmins,dc=example,dc=com", "cn=SbiAdmins,dc=example,dc=com"])
414
414
  end
415
415
  before do
416
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
416
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'])).and_yield(entry)
417
417
  end
418
418
  it "sets the account_type to 'member' and includes roles" do
419
419
  expect do |blk|
@@ -454,13 +454,13 @@ describe Socialcast::CommandLine::LDAPConnector do
454
454
  :isMemberOf => ["cn=SFOffice,dc=example,dc=com", "cn=Sales,dc=example,dc=com"])
455
455
  end
456
456
  before do
457
- ldap.should_receive(:search).once.ordered.with(
457
+ expect(ldap).to receive(:search).once.ordered.with(
458
458
  :return_result => false,
459
459
  :filter => "(objectClass=groupOfUniqueNames)",
460
460
  :base => "dc=example,dc=com",
461
461
  :attributes => ["gid"]).and_yield(group_entry1).and_yield(group_entry2).and_yield(group_entry3)
462
462
 
463
- ldap.should_receive(:search).once.ordered.with(
463
+ expect(ldap).to receive(:search).once.ordered.with(
464
464
  :return_result => false,
465
465
  :filter => "(mail=*)",
466
466
  :base => "dc=example,dc=com",
@@ -486,7 +486,7 @@ describe Socialcast::CommandLine::LDAPConnector do
486
486
  context "calling when a search is already being performed" do
487
487
  let(:connector) { Socialcast::CommandLine::LDAPConnector.new('connection_1', ldap_config) }
488
488
  before do
489
- ldap.should_receive(:search).and_yield(create_entry('user', :mail => 'user@example.com'))
489
+ expect(ldap).to receive(:search).and_yield(create_entry('user', :mail => 'user@example.com'))
490
490
  end
491
491
  it "raises an error" do
492
492
  expect do
@@ -502,7 +502,7 @@ describe Socialcast::CommandLine::LDAPConnector do
502
502
  context "calling when a search is already being performed, rescuing, then calling again" do
503
503
  let(:connector) { Socialcast::CommandLine::LDAPConnector.new('connection_1', ldap_config) }
504
504
  before do
505
- ldap.should_receive(:search).and_yield(create_entry('user', :mail => 'user@example.com'))
505
+ expect(ldap).to receive(:search).and_yield(create_entry('user', :mail => 'user@example.com'))
506
506
  end
507
507
  it "raises an error" do
508
508
  expect do
@@ -535,7 +535,7 @@ describe Socialcast::CommandLine::LDAPConnector do
535
535
  }
536
536
  end
537
537
  before do
538
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
538
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
539
539
  end
540
540
  it do
541
541
  expect do |blk|
@@ -559,7 +559,7 @@ describe Socialcast::CommandLine::LDAPConnector do
559
559
  }
560
560
  end
561
561
  before do
562
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
562
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
563
563
  end
564
564
  it 'does not yield' do
565
565
  expect do |blk|
@@ -581,7 +581,7 @@ describe Socialcast::CommandLine::LDAPConnector do
581
581
  }
582
582
  end
583
583
  before do
584
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
584
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
585
585
  end
586
586
  it 'does not yield' do
587
587
  expect do |blk|
@@ -602,7 +602,7 @@ describe Socialcast::CommandLine::LDAPConnector do
602
602
  }
603
603
  end
604
604
  before do
605
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
605
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
606
606
  end
607
607
  it "does not raise an error" do
608
608
  expect do |blk|
@@ -628,12 +628,12 @@ describe Socialcast::CommandLine::LDAPConnector do
628
628
  let(:entry) { create_entry 'user', :uid => 'unique identifier', :givenName => 'first name', :sn => 'last name' }
629
629
  before do
630
630
  filter = Net::LDAP::Filter.construct('(&(mail=*)(uid=unique identifier))')
631
- ldap.should_receive(:search).once
631
+ expect(ldap).to receive(:search).once
632
632
  .with(hash_including(:attributes => ['givenName', 'sn', 'uid', 'isMemberOf'], :filter => filter))
633
633
  .and_yield(entry)
634
634
  end
635
635
  it do
636
- connector.fetch_user_hash('unique identifier', {}).should == {
636
+ expect(connector.fetch_user_hash('unique identifier', {})).to eq({
637
637
  'account_type' => 'member',
638
638
  'contact_info' => {},
639
639
  'custom_fields' => [],
@@ -641,7 +641,7 @@ describe Socialcast::CommandLine::LDAPConnector do
641
641
  'last_name' => 'last name',
642
642
  'roles' => [],
643
643
  'unique_identifier' => 'unique identifier'
644
- }
644
+ })
645
645
  end
646
646
  end
647
647
 
@@ -650,12 +650,12 @@ describe Socialcast::CommandLine::LDAPConnector do
650
650
  let(:entry) { create_entry 'user', :mail => 'user@example.com', :givenName => 'first name', :sn => 'last name' }
651
651
  before do
652
652
  filter = Net::LDAP::Filter.construct('(&(mail=*)(mail=user@example.com))')
653
- ldap.should_receive(:search).once
653
+ expect(ldap).to receive(:search).once
654
654
  .with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'], :filter => filter))
655
655
  .and_yield(entry)
656
656
  end
657
657
  it do
658
- connector.fetch_user_hash('user@example.com', :identifying_field => 'email').should == {
658
+ expect(connector.fetch_user_hash('user@example.com', :identifying_field => 'email')).to eq({
659
659
  'account_type' => 'member',
660
660
  'contact_info' => {
661
661
  'email' => 'user@example.com'
@@ -664,7 +664,7 @@ describe Socialcast::CommandLine::LDAPConnector do
664
664
  'first_name' => 'first name',
665
665
  'last_name' => 'last name',
666
666
  'roles' => []
667
- }
667
+ })
668
668
  end
669
669
  end
670
670
 
@@ -674,12 +674,12 @@ describe Socialcast::CommandLine::LDAPConnector do
674
674
  let(:entry) { create_entry 'user', :mail => 'user@example.com', :givenName => 'first name', :sn => 'last name' }
675
675
  before do
676
676
  filter = Net::LDAP::Filter.construct('(&(objectclass=*)(mail=user@example.com))')
677
- ldap.should_receive(:search).once
677
+ expect(ldap).to receive(:search).once
678
678
  .with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'isMemberOf'], :filter => filter))
679
679
  .and_yield(entry)
680
680
  end
681
681
  it do
682
- connector.fetch_user_hash('user@example.com', :identifying_field => 'email').should == {
682
+ expect(connector.fetch_user_hash('user@example.com', :identifying_field => 'email')).to eq({
683
683
  'account_type' => 'member',
684
684
  'contact_info' => {
685
685
  'email' => 'user@example.com'
@@ -688,7 +688,7 @@ describe Socialcast::CommandLine::LDAPConnector do
688
688
  'first_name' => 'first name',
689
689
  'last_name' => 'last name',
690
690
  'roles' => []
691
- }
691
+ })
692
692
  end
693
693
  end
694
694
 
@@ -713,30 +713,30 @@ describe Socialcast::CommandLine::LDAPConnector do
713
713
  }
714
714
  end
715
715
  before do
716
- ldap.should_receive(:search).once.ordered.with(
716
+ expect(ldap).to receive(:search).once.ordered.with(
717
717
  :return_result => false,
718
718
  :filter => "(objectClass=groupOfUniqueNames)",
719
719
  :base => "dc=example,dc=com",
720
720
  :attributes => ["gid"]).and_yield(group)
721
721
 
722
- ldap.should_receive(:search).once.ordered.with(
722
+ expect(ldap).to receive(:search).once.ordered.with(
723
723
  :return_result => false,
724
724
  :filter => "(mail=*)",
725
725
  :base => "dc=example,dc=com",
726
726
  :attributes => ["mail"]).and_yield(manager)
727
727
 
728
728
  filter1 = Net::LDAP::Filter.construct('(&(mail=*)(mail=user1@example.com))')
729
- ldap.should_receive(:search).once.ordered
729
+ expect(ldap).to receive(:search).once.ordered
730
730
  .with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf'], :filter => filter1))
731
731
  .and_yield(user1)
732
732
 
733
733
  filter2 = Net::LDAP::Filter.construct('(&(mail=*)(mail=user2@example.com))')
734
- ldap.should_receive(:search).once.ordered
734
+ expect(ldap).to receive(:search).once.ordered
735
735
  .with(hash_including(:attributes => ['givenName', 'sn', 'mail', 'manager_dn', 'isMemberOf'], :filter => filter2))
736
736
  .and_yield(user2)
737
737
  end
738
738
  it "caches managers and groups" do
739
- connector.fetch_user_hash('user1@example.com', :identifying_field => 'email').should == {
739
+ expect(connector.fetch_user_hash('user1@example.com', :identifying_field => 'email')).to eq({
740
740
  'account_type' => 'member',
741
741
  'contact_info' => {
742
742
  'email' => 'user1@example.com'
@@ -746,9 +746,9 @@ describe Socialcast::CommandLine::LDAPConnector do
746
746
  'last_name' => 'last name 1',
747
747
  'groups' => [],
748
748
  'roles' => []
749
- }
749
+ })
750
750
 
751
- connector.fetch_user_hash('user2@example.com', :identifying_field => 'email').should == {
751
+ expect(connector.fetch_user_hash('user2@example.com', :identifying_field => 'email')).to eq({
752
752
  'account_type' => 'member',
753
753
  'contact_info' => {
754
754
  'email' => 'user2@example.com'
@@ -758,7 +758,7 @@ describe Socialcast::CommandLine::LDAPConnector do
758
758
  'last_name' => 'last name 2',
759
759
  'groups' => ['sales_group_id'],
760
760
  'roles' => []
761
- }
761
+ })
762
762
  end
763
763
  end
764
764
  end
@@ -780,12 +780,12 @@ describe Socialcast::CommandLine::LDAPConnector do
780
780
  let(:ldap_instance) { double(Net::LDAP, :encryption => nil, :auth => nil) }
781
781
  context "passed hash for attribute" do
782
782
  it "returns a string that used defined string template" do
783
- connector.send(:grab, entry, { "value" => "123%{mail}", "mail" => "mail" }).should == "123sean@example.com"
783
+ expect(connector.send(:grab, entry, { "value" => "123%{mail}", "mail" => "mail" })).to eq("123sean@example.com")
784
784
  end
785
785
  end
786
786
  context "passed string for attribute" do
787
787
  it "returns exact string stored in entry" do
788
- connector.send(:grab, entry, "mail").should == "sean@example.com"
788
+ expect(connector.send(:grab, entry, "mail")).to eq("sean@example.com")
789
789
  end
790
790
  end
791
791
  context "passed string that can be constantized and the resulting Class responds to run" do
@@ -797,7 +797,7 @@ describe Socialcast::CommandLine::LDAPConnector do
797
797
  end
798
798
  end
799
799
  end
800
- connector.send(:grab, entry, "Socialcast::CommandLine::FakeAttributeMap").should == "sebn@exbmple.com"
800
+ expect(connector.send(:grab, entry, "Socialcast::CommandLine::FakeAttributeMap")).to eq("sebn@exbmple.com")
801
801
  end
802
802
  end
803
803
  context "passed string that must be classified and the resulting Class responds to run" do
@@ -809,7 +809,7 @@ describe Socialcast::CommandLine::LDAPConnector do
809
809
  end
810
810
  end
811
811
  end
812
- connector.send(:grab, entry, "socialcast/command_line/fake_attribute_map").should == "sebn@exbmple.com"
812
+ expect(connector.send(:grab, entry, "socialcast/command_line/fake_attribute_map")).to eq("sebn@exbmple.com")
813
813
  end
814
814
  end
815
815
  context "attribute passed has a collision between string and Class" do
@@ -824,7 +824,7 @@ describe Socialcast::CommandLine::LDAPConnector do
824
824
  Object.send(:remove_const, :Mail)
825
825
  end
826
826
  it "returns the result of the Class run method" do
827
- connector.send(:grab, entry, "mail").should == "sebn@exbmple.com"
827
+ expect(connector.send(:grab, entry, "mail")).to eq("sebn@exbmple.com")
828
828
  end
829
829
  end
830
830
  context "attribute passed constantizes to a module instead of a class" do
@@ -834,7 +834,7 @@ describe Socialcast::CommandLine::LDAPConnector do
834
834
  return "#{entry[:mail].first.gsub(/a/,'b')}"
835
835
  end
836
836
  end
837
- connector.send(:grab, entry, "FakeAttributeMap").should == "sebn@exbmple.com"
837
+ expect(connector.send(:grab, entry, "FakeAttributeMap")).to eq("sebn@exbmple.com")
838
838
  end
839
839
  end
840
840
  end
@@ -8,13 +8,13 @@ describe Socialcast::CommandLine::ProvisionPhoto do
8
8
  let(:another_profile_photo_id) { 4 }
9
9
 
10
10
  before do
11
- Socialcast::CommandLine::ProvisionPhoto.any_instance.stub(:default_profile_photo_id).and_return(default_profile_photo_id)
11
+ allow_any_instance_of(Socialcast::CommandLine::ProvisionPhoto).to receive(:default_profile_photo_id).and_return(default_profile_photo_id)
12
12
  end
13
13
 
14
14
  let(:ldap) do
15
15
  ldap_instance = double(Net::LDAP, :auth => nil, :encryption => nil)
16
- ldap_instance.should_receive(:open).and_yield
17
- Net::LDAP.should_receive(:new).and_return(ldap_instance)
16
+ expect(ldap_instance).to receive(:open).and_yield
17
+ expect(Net::LDAP).to receive(:new).and_return(ldap_instance)
18
18
  ldap_instance
19
19
  end
20
20
 
@@ -43,24 +43,24 @@ describe Socialcast::CommandLine::ProvisionPhoto do
43
43
  end
44
44
  before do
45
45
  entry = create_entry 'user', :mail => 'user@example.com', :jpegPhoto => photo_data
46
- ldap.should_receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
47
- Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
46
+ expect(ldap).to receive(:search).once.with(hash_including(:attributes => ['mail', 'jpegPhoto'])).and_yield(entry)
47
+ allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
48
48
  end
49
49
 
50
50
  context 'for when it does successfully post the photo' do
51
51
  before do
52
- user_search_resource.should_receive(:get).and_return(search_api_response.to_json)
52
+ expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json)
53
53
  user_resource = double(:user_resource)
54
- user_resource.should_receive(:put) do |data|
54
+ expect(user_resource).to receive(:put) do |data|
55
55
  uploaded_data = data[:user][:profile_photo][:data]
56
- uploaded_data.path.should =~ /\.png\Z/
56
+ expect(uploaded_data.path).to match(/\.png\Z/)
57
57
  end
58
- Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
58
+ allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', anything).and_return(user_resource)
59
59
  end
60
60
  context 'for a binary file' do
61
61
  let(:photo_data) { "\x89PNGabc" }
62
62
  before do
63
- RestClient.should_not_receive(:get)
63
+ expect(RestClient).not_to receive(:get)
64
64
  sync_photos
65
65
  end
66
66
  it 'uses the original binary to upload the photo' do end
@@ -68,7 +68,7 @@ describe Socialcast::CommandLine::ProvisionPhoto do
68
68
  context 'for an image file' do
69
69
  let(:photo_data) { "http://socialcast.com/someimage.png" }
70
70
  before do
71
- RestClient.should_receive(:get).with(photo_data).and_return("\x89PNGabc")
71
+ expect(RestClient).to receive(:get).with(photo_data).and_return("\x89PNGabc")
72
72
  sync_photos
73
73
  end
74
74
  it 'downloads the image form the web to upload the photo' do end
@@ -79,8 +79,8 @@ describe Socialcast::CommandLine::ProvisionPhoto do
79
79
  context 'for an image file' do
80
80
  let(:photo_data) { "http://socialcast.com/someimage.png" }
81
81
  before do
82
- user_search_resource.should_receive(:get).and_return(search_api_response.to_json)
83
- RestClient.should_receive(:get).with(photo_data).and_raise(RestClient::ResourceNotFound)
82
+ expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json)
83
+ expect(RestClient).to receive(:get).with(photo_data).and_raise(RestClient::ResourceNotFound)
84
84
  sync_photos
85
85
  end
86
86
  it 'tries to download the image from the web and rescues 404' do end
@@ -89,22 +89,22 @@ describe Socialcast::CommandLine::ProvisionPhoto do
89
89
 
90
90
  context 'when there is already a photo set' do
91
91
  before do
92
- Socialcast::CommandLine::ProvisionPhoto.any_instance.stub(:default_profile_photo_id).and_return(another_profile_photo_id)
92
+ allow_any_instance_of(Socialcast::CommandLine::ProvisionPhoto).to receive(:default_profile_photo_id).and_return(another_profile_photo_id)
93
93
  end
94
94
  let(:photo_data) { "\x89PNGabc" }
95
- before { user_search_resource.should_receive(:get).and_return(search_api_response.to_json) }
95
+ before { expect(user_search_resource).to receive(:get).and_return(search_api_response.to_json) }
96
96
  context 'for a regular sync' do
97
97
  before do
98
98
  sync_photos
99
- Socialcast::CommandLine.should_not_receive(:resource_for_path)
99
+ expect(Socialcast::CommandLine).not_to receive(:resource_for_path)
100
100
  end
101
101
  it 'does not post the new photo' do end
102
102
  end
103
103
  context 'when they do a force sync' do
104
104
  let(:options) { { :force_sync => true } }
105
105
  before do
106
- Socialcast::CommandLine.should_receive(:resource_for_path).with('/api/users/7', {}).and_return(user_submit_resource)
107
- user_submit_resource.should_receive(:put).and_return(true)
106
+ expect(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', {}).and_return(user_submit_resource)
107
+ expect(user_submit_resource).to receive(:put).and_return(true)
108
108
  sync_photos
109
109
  end
110
110
  it 'submits the photo anyways' do end
@@ -142,43 +142,43 @@ describe Socialcast::CommandLine::ProvisionPhoto do
142
142
  let(:sync_photos) { provisioner.sync }
143
143
  let(:binary_photo_data) { "\x89PNGabc".force_encoding('binary') }
144
144
  before do
145
- Socialcast::CommandLine::ProvisionPhoto::ApiSyncStrategy.any_instance.stub(:batch_size).and_return(2)
145
+ allow_any_instance_of(Socialcast::CommandLine::ProvisionPhoto::ApiSyncStrategy).to receive(:batch_size).and_return(2)
146
146
 
147
147
  ldap_instance1 = double(Net::LDAP, :encryption => nil, :auth => nil)
148
- ldap_instance1.should_receive(:open).and_yield
149
- Net::LDAP.should_receive(:new).once.ordered.and_return(ldap_instance1)
148
+ expect(ldap_instance1).to receive(:open).and_yield
149
+ expect(Net::LDAP).to receive(:new).once.ordered.and_return(ldap_instance1)
150
150
  entry1 = create_entry 'user', :mailCon => 'user@example.com', :photoCon => binary_photo_data
151
- ldap_instance1.should_receive(:search).once.with(hash_including(:attributes => ['mailCon', 'photoCon'])).and_yield(entry1)
151
+ expect(ldap_instance1).to receive(:search).once.with(hash_including(:attributes => ['mailCon', 'photoCon'])).and_yield(entry1)
152
152
 
153
153
  ldap_instance2 = double(Net::LDAP, :encryption => nil, :auth => nil)
154
- ldap_instance2.should_receive(:open).and_yield
155
- Net::LDAP.should_receive(:new).once.ordered.and_return(ldap_instance2)
154
+ expect(ldap_instance2).to receive(:open).and_yield
155
+ expect(Net::LDAP).to receive(:new).once.ordered.and_return(ldap_instance2)
156
156
  entry2 = create_entry 'user', :mailCon2 => 'user2@example.com', :photoCon2 => binary_photo_data
157
- ldap_instance2.should_receive(:search).once.with(hash_including(:attributes => ['mailCon2', 'photoCon2'])).and_yield(entry2)
157
+ expect(ldap_instance2).to receive(:search).once.with(hash_including(:attributes => ['mailCon2', 'photoCon2'])).and_yield(entry2)
158
158
 
159
- Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
159
+ allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/search', anything).and_return(user_search_resource)
160
160
 
161
- user_search_resource.should_receive(:get).once.with({:params => { :q => "\"user@example.com\" OR \"user2@example.com\"", :per_page => 2}, :accept => :json}).and_return(search_api_response.to_json)
161
+ expect(user_search_resource).to receive(:get).once.with({:params => { :q => "\"user@example.com\" OR \"user2@example.com\"", :per_page => 2}, :accept => :json}).and_return(search_api_response.to_json)
162
162
 
163
163
  user_resource1 = double(:user_resource)
164
- user_resource1.should_receive(:put) do |data|
164
+ expect(user_resource1).to receive(:put) do |data|
165
165
  uploaded_data = data[:user][:profile_photo][:data]
166
- uploaded_data.path.should =~ /\.png\Z/
166
+ expect(uploaded_data.path).to match(/\.png\Z/)
167
167
  end
168
- Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/7', anything).and_return(user_resource1)
168
+ allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/7', anything).and_return(user_resource1)
169
169
 
170
170
  user_resource2 = double(:user_resource)
171
- user_resource2.should_receive(:put) do |data|
171
+ expect(user_resource2).to receive(:put) do |data|
172
172
  uploaded_data = data[:user][:profile_photo][:data]
173
- uploaded_data.path.should =~ /\.png\Z/
173
+ expect(uploaded_data.path).to match(/\.png\Z/)
174
174
  end
175
- Socialcast::CommandLine.stub(:resource_for_path).with('/api/users/8', anything).and_return(user_resource2)
175
+ allow(Socialcast::CommandLine).to receive(:resource_for_path).with('/api/users/8', anything).and_return(user_resource2)
176
176
 
177
177
  sync_photos
178
178
  end
179
179
  it 'uses attributes from each connection' do end
180
180
  it 'is considered fully configured' do
181
- expect(provisioner.configured?).to be_true
181
+ expect(provisioner.configured?).to be_truthy
182
182
  end
183
183
  end
184
184
  context "with multiple incompletely configured ldap connections" do
@@ -188,7 +188,7 @@ describe Socialcast::CommandLine::ProvisionPhoto do
188
188
  expect { sync_photos }.to raise_error Socialcast::CommandLine::Provisioner::ProvisionError
189
189
  end
190
190
  it 'is not considered fully configured' do
191
- expect(provisioner.configured?).to be_false
191
+ expect(provisioner.configured?).to be_falsy
192
192
  end
193
193
  it 'provides a list of incomplete configurations' do
194
194
  expect(provisioner.unsupported_configurations).to eq(['example_connection_2'])