Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created July 13, 2009 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/146312 to your computer and use it in GitHub Desktop.
Save mrchrisadams/146312 to your computer and use it in GitHub Desktop.
# 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
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
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
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