spec/models/contactology/campaigns/standard_spec.rb in contactology-0.1.2 vs spec/models/contactology/campaigns/standard_spec.rb in contactology-1.0.0
- old
+ new
@@ -2,36 +2,33 @@
require 'spec_helper'
describe Contactology::Campaigns::Standard do
context '.create' do
- context 'when successful' do
- use_vcr_cassette 'campaigns/standard/create/success'
- let(:list) { Factory :list, :name => 'campaign-standard-create-success' }
+ context 'when successful', :vcr => {:cassette_name => 'campaigns/standard/create/success'} do
+ let(:list) { create :list, :name => 'campaign-standard-create-success' }
let(:campaign) { create_campaign :recipients => list }
after(:each) { list.destroy; campaign.destroy }
subject { campaign }
it { should be_instance_of Contactology::Campaigns::Standard }
its(:id) { should_not be_nil }
end
- context 'with invalid data' do
- use_vcr_cassette 'campaigns/standard/create/invalid'
- let(:list) { Factory :list, :name => 'campaign-standard-create-invalid' }
+ context 'with invalid data', :vcr => {:cassette_name => 'campaigns/standard/create/invalid'} do
+ let(:list) { create :list, :name => 'campaign-standard-create-invalid' }
let(:campaign) { create_campaign :sender_email => 'bad@example', :recipients => list }
after(:each) { list.destroy }
subject { campaign }
it { should be_false }
end
- context 'with required attributes missing' do
- use_vcr_cassette 'campaigns/standard/create/failure'
- let(:list) { Factory :list, :name => 'campaign-standard-create-failure' }
+ context 'with required attributes missing', :vcr => {:cassette_name => 'campaigns/standard/create/failure'} do
+ let(:list) { create :list, :name => 'campaign-standard-create-failure' }
let(:campaign) { create_campaign :name => nil, :recipients => list }
after(:each) { list.destroy }
subject { campaign }
@@ -40,15 +37,14 @@
end
end
end
context '#send_campaign' do
- context 'when successful' do
- use_vcr_cassette 'campaigns/standard/send_campaign/success'
- let(:list) { Factory :list, :name => 'send-standard-campaign-success' }
- let(:contact) { Factory :contact }
- let(:campaign) { Factory :standard_campaign, :recipients => list }
+ context 'when successful', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/success'} do
+ let(:list) { create :list, :name => 'send-standard-campaign-success' }
+ let(:contact) { create :contact }
+ let(:campaign) { create :standard_campaign, :recipients => list }
before(:each) { list.subscribe contact }
after(:each) { list.destroy; contact.destroy; campaign.destroy }
subject { campaign.send_campaign }
@@ -56,32 +52,40 @@
it { should be_instance_of Contactology::SendResult }
it { should be_successful }
its(:issues) { should be_empty }
end
- context 'when unsuccessful (high spam score)' do
- use_vcr_cassette 'campaigns/standard/send_campaign/failure'
- let(:list) { Factory :list, :name => 'send-standard-campaign-failure' }
- let(:contact) { Factory :contact }
- let(:campaign) { Factory :standard_campaign, :recipients => list, :content => {'text' => 'OMG BUY VIAGRA'} }
+ context 'when unsuccessful (high spam score)', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/failure'} do
+ let(:list) { create :list, :name => 'send-standard-campaign-failure' }
+ let(:contact) { create :contact }
+ let(:campaign) { create :standard_campaign, :recipients => list, :content => {'text' => 'OMG BUY VIAGRA'} }
before(:each) { list.subscribe(contact) }
after(:each) { list.destroy; contact.destroy; campaign.destroy }
subject { campaign.send_campaign }
it { should be_instance_of Contactology::SendResult }
- it { should_not be_successful }
- its(:issues) { should_not be_empty }
its(:score) { should be < 100 }
+
+ it 'should not be successful' do
+ pending('This is incorrectly passing successfully on Contactology.') do
+ should_not be_successful
+ end
+ end
+
+ it 'should have reported issues' do
+ pending('This is incorrectly passing successfully on Contactology.') do
+ subject.issues.should_not be_empty
+ end
+ end
end
- context 'when unsuccessful (attributes missing)' do
- use_vcr_cassette 'campaigns/standard/send_campaign/failure_missing_attributes', record: :new_episodes
- let(:list) { Factory :list, :name => 'send-standard-campaign-failure' }
- let(:contact) { Factory :contact }
- let(:campaign) { Factory :standard_campaign, :recipients => list }
+ context 'when unsuccessful (attributes missing)', :vcr => {:cassette_name => 'campaigns/standard/send_campaign/failure_missing_attributes'} do
+ let(:list) { create :list, :name => 'send-standard-campaign-failure' }
+ let(:contact) { create :contact }
+ let(:campaign) { create :standard_campaign, :recipients => list }
before(:each) { list.subscribe(contact); campaign.id = nil }
after(:each) { list.destroy; contact.destroy; campaign.destroy }
subject { campaign.send_campaign }
@@ -106,8 +110,8 @@
private
def create_campaign(attributes = {})
- Contactology::Campaigns::Standard.create Factory.attributes_for(:standard_campaign).merge(attributes)
+ Contactology::Campaigns::Standard.create attributes_for(:standard_campaign).merge(attributes)
end
end