spec/cli_spec.rb in socialcast-1.1.4 vs spec/cli_spec.rb in socialcast-1.1.5

- old
+ new

@@ -286,6 +286,31 @@ end it 'formats l and co according to template' do @result.should =~ %r{<location>San Francisco, USA</location>} end end + context 'with ldap.yml configuration including manager attribute mapping' do + before do + @entry = Net::LDAP::Entry.new("dc=example,dc=com") + @entry[:mail] = 'ryan@example.com' + @entry[:manager] = 'cn=bossman,dc=example,dc=com' + @manager_email = 'bossman@example.com' + + @entry.stub(:dereference_mail).with(kind_of(Net::LDAP), "manager", "mail").and_return(@manager_email) + Net::LDAP.any_instance.stub(:search).and_yield(@entry) + + @result = '' + Zlib::GzipWriter.stub(:open).and_yield(@result) + Socialcast.stub(:credentials).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'credentials.yml'))) + Socialcast::CLI.any_instance.should_receive(:load_configuration).with(/ldap.yml/).and_return(YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'ldap_with_manager_attribute.yml'))) + File.stub(:open).with(/users.xml.gz/, anything).and_yield(@result) + + RestClient::Resource.any_instance.stub(:post) + + Socialcast::CLI.start ['provision', '-c', 'spec/fixtures/ldap.yml'] + end + it 'adds a manager_email entry of bossman@example.com' do + @result.should =~ /<email>ryan@example.com<\/email>/ + @result.should =~ /<label>manager_email<\/label>\s*<value>bossman@example.com<\/value>/ + end + end end