Created
July 13, 2009 17:24
-
-
Save mrchrisadams/146312 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # User factories | |
| Factory.define :user do |f| | |
| f.user_name 'nag-o-meter' | |
| f.first_name 'John' | |
| f.last_name 'Doe' | |
| f.dob Date.new(1982, 5, 11) | |
| f.sequence(:email) {|n| "person#{n}@example.com" } | |
| f.password 'this_one_goes_to_eleven' | |
| f.password_confirmation { |u| u.password } | |
| f.accept_tos '1' | |
| f.active '1' | |
| f.newsletter '1' | |
| f.monthly_nagging '1' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) | |
| Spec::Mocks::MockExpectationError in 'User integrating with mailchimp API should create a working hominid object if user opts-in to the newsletter' | |
| <Hominid (class)> expected :new with (any args) once, but received it 0 times | |
| ./spec/models/user_spec.rb:127: | |
| Finished in 1.291039 seconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| after_create :check_against_mailchimp | |
| def add_to_mail_chimp | |
| @hominid = Hominid.new | |
| # do more stuff here once we know we have an object being instantiated | |
| end | |
| def check_against_mailchimp | |
| add_to_mail_chimp if newsletter? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe User, "integrating with mailchimp API" do | |
| before :each do | |
| @user = Factory.create(:user) | |
| end | |
| it "should create a working hominid object if user opts-in to the newsletter" do | |
| Hominid.should_receive(:new) | |
| end | |
| it "should send the user's details to mail chimp on sign up if they optin" do | |
| pending | |
| end | |
| it "should not send details to mailchimp if they opt-out" do | |
| pending | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment