Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Creating test for mail merge (not working state)

  • Loading branch information...
commit e0d108fe7fb3cbb9d6976c9969102caa1d5bcaef 1 parent 0f39603
@nahurst authored
View
10 db/schema.rb
@@ -11,6 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 0) do
+ActiveRecord::Schema.define(:version => 20130317223920) do
+
+ create_table "mail_merges", :force => true do |t|
+ t.text "data"
+ t.string "subject_template"
+ t.text "body_template"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
end
View
13 spec/factories/mail_merges.rb
@@ -1,9 +1,12 @@
-# Read about factories at https://github.com/thoughtbot/factory_girl
-
FactoryGirl.define do
factory :mail_merge do
- data "MyText"
- subject_template "MyString"
- body_template "MyText"
+ data [
+ {:email => 'leonardo@example.com', :name => 'Leonardo', :company => 'TMNT'},
+ {:email => 'donatello@example.com', :name => 'Donatello', :company => 'TMNT'},
+ {:email => 'michaelangello@example.com', :name => 'Michaelangello', :company => 'TMNT'},
+ {:email => 'raphael@example.com', :name => 'Raphael', :company => 'TMNT'}
+ ].to_json
+ subject_template "Great to see you {{name}}"
+ body_template "Hi {{name}}\nIt was great to see you at the {{company}} party!"
end
end
View
14 spec/models/mail_merge_spec.rb
@@ -1,5 +1,17 @@
require 'spec_helper'
describe MailMerge do
- pending "add some examples to (or delete) #{__FILE__}"
+ describe 'email generation' do
+
+ it 'should generate emails for a complete mail merge' do
+ mm = create(:mail_merge)
+ mm.generate_emails
+ mm.emails.length.should == 4
+
+ email = mm.first
+ email.to.should == "leonardo@example.com"
+ email.subject.should == "Great to see you Leonardo"
+ email.body.should == "Hi Leonardo\nIt was great to see you at the TMNT party!"
+ end
+ end
end
View
5 spec/spec_helper.rb
@@ -12,6 +12,9 @@
RSpec.configure do |config|
config.include(EmailSpec::Helpers)
config.include(EmailSpec::Matchers)
+
+ config.include FactoryGirl::Syntax::Methods
+
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
@@ -38,7 +41,7 @@
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
-
+
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
end
Please sign in to comment.
Something went wrong with that request. Please try again.