03 Nov '13, 6pm

RSpec formats and the Single Responsibility Principle

For years, my unit tests have largely followed the “method spec” format: describe SomeObject do describe "#some_method" do context "in some context" do it "does something" end context "in some other context" do it "does something else" end end describe "#some_other_method" do context "in some context" do it "does something" end context "in some other context" do it "does something else" end end end But I have a theory: this approach to testing encourages violations of the single responsibility principle. Our objects model our domain; they have specific behaviors and act on specific state. They’re not just random bags of methods. The methods on a model should make sense together. They should all reflect that object’s responsibility. The problem with the “method spec” format is that it’s entirely possible to add another method to the model without thinking about all of the o...

Full article: http://pivotallabs.com/rspec-formats-and-the-single-respo...

Tweets

Writing Rails engine rspec controller tests #rails

pivotallabs.com 04 Nov '13, 6pm

If you are trying to test controllers under a Rails engine, you might come across this error: Failure/Error: get :index Ac...

Testing with RSpec for Rails 4 is done

everydayrails.com 07 Nov '13, 11am

Testing with RSpec for Rails 4 is done August 21, 2013 As I type this, Leanpub’s robots are busily formatting Everyday Rai...

Everyday Rails Testing with RSpec, the book now...

everydayrails.com 07 Nov '13, 11am

Everyday Rails Testing with RSpec, the book now covers Capybara 2.0, RSpec's new syntax, and more February 13, 2013 Hey ev...