spec/mixpanel/mail_spec.rb in mixpanel-mail-0.1.1 vs spec/mixpanel/mail_spec.rb in mixpanel-mail-0.1.2
- old
+ new
@@ -1,11 +1,11 @@
require 'spec_helper'
describe Mixpanel::Mail do
- TOKEN, CAMPAIGN = 'abcd123', 'my-email'
+ TOKEN, CAMPAIGN = 'abcd123', Mixpanel::Mail::DEFAULT_CAMPAIGN
- it 'should intialize token & campaign' do
+ it 'should intialize token & default campaign' do
lambda {
mail = mp_mail
mail.params['token'].should eq(TOKEN)
mail.params['campaign'].should eq(CAMPAIGN)
}.should_not raise_exception
@@ -86,27 +86,28 @@
end
end
private
def mp_mail(options = {})
- ::Mixpanel::Mail.new(TOKEN, CAMPAIGN, options)
+ ::Mixpanel::Mail.new(TOKEN, options)
end
def mp_option_check(key, value_expectations = {})
value_expectations.each do |value, expectation|
mp_mail(key => value).params[key].should eq(expectation)
mp_mail(key.to_sym => value).params[key].should eq(expectation)
end
end
def verify_request_with_options(options = {}, expectations = {})
- stub_post
- mp_mail(options).add_tracking('my-dist-id', 'Hello World!')
- mp_mail.add_tracking('my-dist-id', 'Hello World!', options)
- a_post.with(:body => expectations.merge(
- 'token' => TOKEN,
- 'campaign' => CAMPAIGN,
- 'distinct_id' => 'my-dist-id',
- 'body' => 'Hello World!'
- )).should have_been_made.twice
+ expectations = expectations.merge(
+ 'token' => TOKEN,
+ 'campaign' => CAMPAIGN,
+ 'distinct_id' => 'my-dist-id',
+ 'body' => 'Hello World!')
+
+ verify_mixpanel_requests(expectations, 2) do
+ mp_mail(options).add_tracking('my-dist-id', 'Hello World!')
+ mp_mail.add_tracking('my-dist-id', 'Hello World!', options)
+ end
end
end