spec/lib/mailroute/models/email_account_spec.rb in mailroute-0.0.4 vs spec/lib/mailroute/models/email_account_spec.rb in mailroute-0.0.5
- old
+ new
@@ -37,11 +37,11 @@
end
describe '#create' do
context 'when domain exists' do
let(:existing_domain) { Mailroute::Domain.get('example.com') }
-
+
context 'creating an email account by email address' do
subject(:email_account) { Mailroute::EmailAccount.create('admin@example.com') }
it 'should be created successfully' do
email_account.id.should_not be_nil
@@ -161,8 +161,46 @@
pending 'API responds with "Passwords don`t match"'
account = Mailroute::EmailAccount.get(53282)
expect {
account.set_password("new_password")
}.not_to raise_error
+ end
+ end
+
+ describe '#add_alias' do
+ let(:email_account) { Mailroute::EmailAccount.get(7718) }
+
+ context 'adding an alias' do
+ it 'should add one more alias' do
+ expect {
+ email_account.add_alias('noreply')
+ }.to change { email_account.reload.aliases.count }.by(1)
+ end
+
+ it 'should add an alias with given name' do
+ email_account.add_alias('sales')
+
+ email_account.aliases.map(&:localpart).should include 'sales'
+ end
+ end
+ end
+
+ describe '#bulk_add_aliases' do
+ let(:email_account) { Mailroute::EmailAccount.get(7718) }
+
+ context 'adding aliases' do
+ it 'should add one more alias' do
+ expect {
+ email_account.bulk_add_aliases(['a', 'b', 'c'])
+ }.to change { email_account.reload.aliases.count }.by(3)
+ end
+
+ it 'should add aliases with given names' do
+ email_account.bulk_add_aliases(['d', 'e'])
+
+ localparts = email_account.aliases.map(&:localpart)
+ localparts.should include 'd'
+ localparts.should include 'e'
+ end
end
end
end
\ No newline at end of file