spec/mailstro/test_strategy_spec.rb in mailstro-0.0.7 vs spec/mailstro/test_strategy_spec.rb in mailstro-0.0.8
- old
+ new
@@ -27,42 +27,80 @@
Mailstro.unsubscribe('a@a.com', :watchers, 12)
end
end
- describe '.clear' do
- before do
- Mailstro.deliver(
- :to => 'a@a.com',
- :template_name => :welcome
- )
- end
+ describe '.has_delivered?' do
+ context "with a delivery" do
+ before do
+ Mailstro.deliver(
+ :to => 'a@a.com',
+ :template_name => :welcome
+ )
+ end
- it 'empties out the .deliveries array' do
- Mailstro::TestStrategy.deliveries.should_not be_empty
- Mailstro::TestStrategy.clear
+ it 'matches template name' do
+ Mailstro.should have_delivered(:welcome)
+ end
- Mailstro::TestStrategy.deliveries.should be_empty
- end
- end
+ it 'matches contact email and template name' do
+ Mailstro.should have_delivered(
+ :to => 'a@a.com',
+ :template_name => :welcome,
+ )
+ end
- describe '.has_delivered?' do
- it 'keeps a record of deliveries' do
- Mailstro.deliver(
- :to => 'a@a.com',
- :template_name => :welcome
- )
+ it 'does not match an invalid template name' do
+ Mailstro.should_not have_delivered(:build_failed)
+ end
- Mailstro.should have_delivered(:welcome)
+ it 'does not match an invalid contact email' do
+ Mailstro.should_not have_delivered(
+ :to => 'b@a.com',
+ :template_name => :welcome,
+ )
+ end
end
- it 'keeps a record of list deliveries' do
- Mailstro.deliver(
- :to => [:list_type, 10],
- :template_name => :welcome
- )
+ context "with a list delivery" do
+ before do
+ Mailstro.deliver(
+ :to => [:build_watchers, 'mailstro/mailstro-ruby'],
+ :template_name => :build_failed
+ )
+ end
- Mailstro.should have_delivered(:welcome)
+ it "matches against list type, name and template name" do
+ Mailstro.should have_delivered(
+ :to_list_type => :build_watchers,
+ :to_list_name => 'mailstro/mailstro-ruby',
+ :template_name => :build_failed,
+ )
+ end
+
+ it "does not match an invalid list type" do
+ Mailstro.should_not have_delivered(
+ :to_list_type => :customers,
+ :to_list_name => 'mailstro/mailstro-ruby',
+ :template_name => :build_failed,
+ )
+ end
+
+ it "does not match an invalid list name" do
+ Mailstro.should_not have_delivered(
+ :to_list_type => :build_watchers,
+ :to_list_name => 'mailstro/mailstro',
+ :template_name => :build_failed,
+ )
+ end
+
+ it "does not match an invalid template name" do
+ Mailstro.should_not have_delivered(
+ :to_list_type => :build_watchers,
+ :to_list_name => 'mailstro/mailstro-ruby',
+ :template_name => :welcome,
+ )
+ end
end
end
describe '.has_subsribed?' do
it 'keeps a record of subscribes' do