These two matchers are referenced from the blog post Segment.io and Ruby.
|[ ~/dev/gems/factory_girl master ] ✔ rake appraisal:3.2 spec:acceptance ☺ 1.9.3-p429|
|>> BUNDLE_GEMFILE=/Users/joshuaclayton/dev/gems/factory_girl/gemfiles/3.2.gemfile bundle exec /Users/joshuaclayton/.rbenv/versions/1.9.3-p429/bin/rake spec:acceptance|
|/Users/joshuaclayton/.rbenv/versions/1.9.3-p429/bin/ruby -S rspec spec/acceptance/activesupport_instrumentation_spec.rb spec/acceptance/aliases_spec.rb spec/acceptance/attribute_aliases_spec.rb spec/acceptance/attribute_existing_on_object_spec.rb spec/acceptance/attributes_for_spec.rb spec/acceptance/attributes_from_instance_spec.rb spec/acceptance/attributes_ordered_spec.rb spec/acceptance/build_list_spec.rb spec/acceptance/build_spec.rb spec/acceptance/build_stubbed_spec.rb spec/acceptance/callbacks_spec.rb spec/acceptance/create_list_spec.rb spec/acceptance/create_spec.rb spec/acceptance/define_child_before_parent_spec.rb spec/acceptance/defining_methods_inside_a_factory_spec.rb spec/acceptance/definitio|
|<?xml version="1.0" encoding="UTF-8"?>|
|<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">|
|/Users/joshuaclayton/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rspec-core-2.10.1/lib/rspec/core/formatters/base_text_formatter.rb:181:in `dump_failure_info': You have a nil object when you didn't expect it! (NoMethodError)|
|You might have expected an instance of Array.|
|The error occurred while evaluating nil.<<|
There's ways to do cleaner SRP that allow moving email delivery out of a model and controller and still be flexible for emailing different things based on type of user, etc.; it's merely a matter of how you solve the problem. simple.rb is the simplest thing that'll do basically the same exact thing that the original author intended - separate object, fast to test, blah blah blah. Introducing DI to override delivery is super simple and can be a lambda/Proc or method;
WithDeliveryEmail doesn't give a shit, as long as it has a
call method accepting the user to deliver the email to.
Is the solution of moving email delivery outside the callback of the user sensible? Can other developers figure out what the side effects of saving a user from the controller immediately? Does creating a user always ensure that an email is delivered? If the system does what it needs to do and all those can be answered with yes, I think it