spec/mailee-api.rb in mailee-0.2.0 vs spec/mailee-api.rb in mailee-0.2.1
- old
+ new
@@ -6,16 +6,16 @@
before(:each) do
Mailee::Config.site = "http://api.bdb28c0a0a4a3.softa.server:3000"
@moment = Time.now.strftime('%Y%m%d%H%M%S')
end
-
+
it "should import (quick)" do
result = Mailee::Quick.create :contacts => "rest_test_#{@moment}@test.com\nrest_test_2_#{@moment}@test.com\nrest_test_3_#{@moment}@test.com"
- result.should
+ result.should_not be nil
end
-
+
it "should have appropriate classes" do
Mailee.should
Mailee::Config.should
Mailee::Contact.should
Mailee::List.should
@@ -25,16 +25,16 @@
Mailee::Report.should
end
it "should get first contact" do
contact = Mailee::Contact.first
- contact.id.should
+ contact.id.should_not be nil
end
it "should create contact" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
- contact.id.should
+ contact.id.should_not be nil
end
it "should get all contacts" do
Array.new(25){|i| Mailee::Contact.create :email => "rest_test_#{@moment}_#{i}@test.com"}
contacts = Mailee::Contact.find(:all)
@@ -43,78 +43,78 @@
contacts.size.should be(10)
end
it "should create contact - and find by id" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
- contact.id.should
+ contact.id.should_not be nil
found_contact = Mailee::Contact.find(contact.id)
found_contact.id.should be(contact.id)
end
it "should create contact - and find by internal_id" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :internal_id => @moment
- contact.id.should
+ contact.id.should_not be nil
contact.internal_id.should == @moment
contact = Mailee::Contact.find(:first, :params => { :internal_id => @moment })
contact.internal_id.should == @moment
end
it "should create contact - with dynamic attributes" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :dynamic_attributes => {:foo => 'bar'}
- contact.id.should
+ contact.id.should_not be nil
contact.dynamic_attributes.attributes['foo'].should == 'bar'
end
it "should create list - and find by id" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
- list.id.should
+ list.id.should_not be nil
list = Mailee::List.find(list.id)
- list.id.should
+ list.id.should_not be nil
end
it "should create contact - and subscribe" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
- contact.put(:subscribe, :list => "rest_test_#{@moment}").should
+ contact.put(:subscribe, :list => "rest_test_#{@moment}").should_not be nil
end
it "should create contact - and unsubscribe" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
- contact.put(:unsubscribe).should
+ contact.put(:unsubscribe).should_not be nil
end
it "should create message" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
- message.id.should
+ message.id.should_not be nil
end
it "should create message - with emails" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :emails => 'foo@bar.com bar@foo.com'
#raise message.inspect
- message.id.should
+ message.id.should_not be nil
end
it "should create, test and send message" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
contact.put(:subscribe, :list => list.name)
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
- message.put(:test, :contacts => [contact.id]).should
- message.put(:ready, :when => 'now').should
+ message.put(:test, :contacts => [contact.id]).should_not be nil
+ message.put(:ready, :when => 'now').should_not be nil
end
# API specific methods
it "should create, subscribe and unsubscribe a contact" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
- contact.subscribe("rest_test_#{@moment}").should
- contact.unsubscribe.should
+ contact.subscribe("rest_test_#{@moment}").should_not be nil
+ contact.unsubscribe.should_not be nil
end
it "should search contacts" do
- Mailee::Contact.search("rest_test").should
+ Mailee::Contact.search("rest_test").should_not be nil
end
it "should create and find by internal id" do
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com", :internal_id => @moment
found = Mailee::Contact.find_by_internal_id(@moment)
@@ -130,22 +130,22 @@
it "should create, test and send message - specific methods" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
contact.put(:subscribe, :list => list.name)
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
- message.test([contact.id]).should
- message.ready.should
+ message.test([contact.id]).should_not be nil
+ message.ready.should_not be nil
end
it "should create, test and send after message - specific methods" do
list = Mailee::List.create :name => "rest_test_#{@moment}"
contact = Mailee::Contact.create :email => "rest_test_#{@moment}@test.com"
contact.put(:subscribe, :list => list.name)
message = Mailee::Message.create :title => "rest_test_#{@moment}", :subject => "rest_test_#{@moment}", :from_name => "rest_test_#{@moment}", :from_email => "rest_test_#{@moment}@test.com", :html => "rest_test_#{@moment}", :list_id => list.id
- message.test([contact.id]).should
- message.ready(10.days.from_now).should
+ message.test([contact.id]).should_not be nil
+ message.ready(10.days.from_now).should_not be nil
end
- it "should import (quick) - specific methods" do Mailee::Quick.import("rest_test_#{@moment}@test.com\nrest_test_2_#{@moment}@test.com\nrest_test_3_#{@moment}@test.com").should
+ it "should import (quick) - specific methods" do Mailee::Quick.import("rest_test_#{@moment}@test.com\nrest_test_2_#{@moment}@test.com\nrest_test_3_#{@moment}@test.com").should_not be nil
end
end
\ No newline at end of file