everydayrails.com Archives - 14 December 2013, Saturday

For almost two years now, I’ve been telling people I never write view specs for my Rails applications. They’re hard to write and harder to manage over time. I don’t even talk about them in Everyday Rails Testing with RSpec –as a general rule, I try to either test view-related matters ...

Everyday Rails Testing with RSpec, the book now covers Capybara 2.0, RSpec's new syntax, and more February 13, 2013 Hey everyone, thanks again to all of you who have purchased Everyday Rails Testing with RSpec . I hope it’s gotten you on your way to better-tested apps. Sales have been...

Related:

Testing with RSpec for Rails 4 is done August 21, 2013 As I type this, Leanpub’s robots are busily formatting Everyday Rails Testing with RSpec into PDF, EPUB and MOBI for your digital reading convenience. Below are my release notes, sent to many of you already by email: Hi everyone, ...

Anyone who’s read Everday Rails Testing with RSpec knows I’m a big fan of Guard . When coupled with a spec server like Spork, Guard helps make test-driven development in Rails more practical by watching your code and automatically running your tests to let you know when they pass (or ...

I won’t spend a lot of time bad-mouthing fixtures—frankly, it’s already been done. Long story short, there are two issues presented by fixtures I’d like to avoid: First, fixture data can be brittle and easily broken (meaning you spend about as much time maintaining your test data as y...

Anyone who’s read Everday Rails Testing with RSpec knows I’m a big fan of Guard . When coupled with a spec server like Spork, Guard helps make test-driven development in Rails more practical by watching your code and automatically running your tests to let you know when they pass (or ...

Anyone who’s read Everday Rails Testing with RSpec knows I’m a big fan of Guard . When coupled with a spec server like Spork, Guard helps make test-driven development in Rails more practical by watching your code and automatically running your tests to let you know when they pass (or ...

Related:

Below is a list of books and other resources I recommend to anyone interested in learning Rails, Ruby, and Rails application testing. If you buy any of these, please consider purchasing through the provided Amazon affiliate links. I get a small cut that helps defray the expenses of ke...

I’m excited to share with you a new Chinese version of Everyday Rails Testing with RSpec , translated by Andor Chen and available now on Leanpub. Andor contacted me several months back about this project; I asked him to hold off on translating until the Rails 4.0-related updates were ...

Related:

Moving along with the steps I follow to create a new Rails application, I want to get into a little detail on some of the specific steps I outlined previously. These are the first steps in taking a Rails app beyond the default shell and making it do what you need to get done. While mo...

Related:

I won’t spend a lot of time bad-mouthing fixtures—frankly, it’s already been done. Long story short, there are two issues presented by fixtures I’d like to avoid: First, fixture data can be brittle and easily broken (meaning you spend about as much time maintaining your test data as y...

Related:

Write tests to test functionality you’re pretty confident works because you’ve been using it for awhile without tests. This is a good way to learn because, if a test fails, it’s apt to be due to your test and not your code. Try to write as many cases as you can to test as many nuances...

That said, early Rails books and tutorials focused more on speed (build a blog in 15 minutes!) than on good practices like testing. If testing were covered at all, it was generally reserved for a chapter toward the end. Newer works on Rails have addressed this shortcoming, and now dem...

Related:

If you’ve been using Reek to help in refactoring your Rails applications , you might run across warnings of Irresponsible Modules — that is, code with no comments to help explain what it does. A common knock on the Rails community is that we don’t document our code. I hate to admit it...

Everyday Rails Testing with RSpec: Updates for April, 2013 April 24, 2013 Last week I released another round of updates to Everyday Rails Testing with RSpec , and subsequently released a couple of minor updates since. For those of you who may have missed it: This is it, the final upda...

Diary of a Rails rescue project, part 2: Testing April 16, 2013 As mentioned previously , I’ve been spending spare cycles getting an outdated Rails application up to speed. Aside from the outdated versions of Rails and pretty much every gem used by the app, there’s a glaring problem: ...

Rescue projects are unique challenges. Chances are, you’re working with someone else’s code. (Or maybe you’re working with your own code, but it’s been so long you don’t remember the work or it represents a former self’s skill set.) If a project hasn’t been touched in awhile, you may ...

Everyday Rails Testing with RSpec, the book now covers Capybara 2.0, RSpec's new syntax, and more February 13, 2013 Hey everyone, thanks again to all of you who have purchased Everyday Rails Testing with RSpec . I hope it’s gotten you on your way to better-tested apps. Sales have been...

Related:

The Rails ecosystem moves quickly–too quickly, some might say–and as a result a given library’s API from just a few months ago may be deprecated today–or worse, it may just no longer work. Running bundle install with the Gemfile as-is, I could get gem versions that are no longer compa...

Behind the scenes, I’ve built a simple little blogging application with an articles scaffold and an authentication system. See Authentication from Scratch (Revised) from Railscasts (subscription required) to see the basic approach I followed to set up logins for the application. One p...

Related:

I actually got started by learning how to create generators in Rails 3 (used to create custom code in an existing Rails application), then extended that to Rails templates (used to create new Rails applications, pre-baked with my favorite gem installations and other tweaks). The best ...

I live in a town dominated by Python, PHP , and Java developers, so hiring someone who can come in and write Ruby code from day one is a challenge. I’ve been thinking about how I learned Ruby myself, how I’ve gone about helping others learn it, and what I would do differently if I had...

Everyday Rails Testing with RSpec: The Book is complete June 13, 2012 On Monday I posted the final, edited version of Everyday Rails Testing with RSpec , available now on Leanpub for $9 US. First, let me again thank everyone who purchased the early access, beta version of the book. I ...

? I mean it’s not done yet, but I wanted to go ahead and get the book out there for people to start reading. (If you’ve ever purchased a beta book from Pragmatic Programmers you know what I’m talking about.) I’ve got updated versions of the original RSpec articles from this blog in pl...

Rails authentication today: Options for 3.0 and 3.1 September 21, 2011 Early on in Everyday Rails , I outlined three options for adding authentication to your Rails applications . It’s still a popular subject—and with two major releases of Rails and a number of new authentication opti...

Keep it simple: If you don’t get request specs right away, don’t worry about it. They require some additional setup and thinking to not just work, but actually test what you need to test. Don’t stop testing your models and controllers, though—building skills at that level will help yo...

Related:

lets you call methods on an object without having to worry about the possibility of that object being nil and thus raising an exception. I know I sometimes forget about it, and I’ve looked at enough code from other developers to know that I’m not the only one. So today I’d like to giv...

If you’re just getting into Ruby or Rails now, and looking for some light reading, you’re in luck. Publishers like the Pragmatic Programmers, O’Reilly, Manning Publications, and others have tons of books available to help you learn. You could easily spend a few hundred dollars buildin...

Controllers are models too, as Piotr Solnica indicated in an excellent blog post . And in Rails applications, they’re pretty important models—so it’s a good idea to put them on equal footing, spec-wise, as your Rails models. Controller specs can be written more quickly than their inte...

Related:

I won’t spend a lot of time bad-mouthing fixtures—frankly, it’s already been done. Long story short, there are two issues presented by fixtures I’d like to avoid: First, fixture data can be brittle and easily broken (meaning you spend about as much time maintaining your test data as y...