Verifying doubles came out in RSpec 3, and it’s something that always sounded like such a brilliant yet obvious idea - make sure methods you stub actually exist. One friend in particular really stressed how many times this could have saved his tests from false positives. Sure, I thought, but usually I’d just modify something in the real code or modify the expectation to make sure it broke/worked in predictable ways, and move on. Then along came the perfect scenario while working on a little side project.
Below is the original spec and the corresponding controller method it's testing. (Things aren't especially DRY and a bunch of expectations are crammed into a single test to make things more explicit for this post.) # spec it 'sends the admin a message about a new order' do controller.stub(:params).and_return(fake_full_params) expect(AdminMailer).to receive(:order_confirmation).with(fake_email_params).and_return(Mail::Message.new) allow_any_instance_of(Mail::Message).…
As I prepare to upgrade some sites to Drupal 7, it seemed like a good time to document my workflow. I'd used Drush for local development on Drupal 6 sites and it eliminated the time spent manually downloading modules and updates. In Drupal 7, module updating isn't nearly as painful - in fact, it's built right into the admin pages (though you'll probably want to do this on a local or staging server first, just in case). A few sites I'm working on are hosted with a cPanel-based host that doesn't allow ssh access, so I can't just set up a git remote and push to the production server. Moving them to another host also isn't the best option right now. Git-ftp to the rescue. tl:dr Set up your site and Drush locally, commit changes to git, test then use git-ftp to push them to the production server
Here's to keeping up with one New Year's resolution!
Documenting and collecting resources has always helped me learn, not only for the occasional refresher but also a reminder of the progress I'm making (or not). For some of us, giving oneself a pat on the back every now and then isn't as forthcoming as it should be. Amidst the countless blog posts, tutorials, books, projects and rabbit holes, I'd like to begin collecting them a bit better. Just kidding, I'm kind of an information pack rat as anyone who's seen the multiple browsers on my computer, each with multiple windows containing dozens of tab, can attest. I'd like to start sharing more as a way to help others and help keep myself organized and focused. With that, here's the first This Month I Learned.