RailsCasts Pro episodes are now free!

Learn more or hide this

James OKelly's Profile

GitHub User: dreamr

Comments by James OKelly

Avatar

BTW, Ryan, whats up with the end of the video. You started to answer the question of whether or not this will move you off of rspec.

I did the switch awhile back from rspec to riotrb, and got so used to fast tests, I dumped rspec altogether. Then I dumped riotrb for minispec.

Havent looked back

Avatar

Don't test rails internals. Instead do something like

it "must have a products collection" do
  @topic.must_respond_to :products
  @topic.products.class.must_equal Array
  @topic.products.size.must_be :>=, 1
  @topic.products[0].class.must_equal Product
end

In these assertions you verify:

  • The @topic instance has access to the products collection
  • The collection is an array
  • The collection has elements
  • The collection's first element has a class of Product

Always test the expected result, and not the internal mechanisms. Test API and you will find that many of your testing issues vanish.

Avatar

If you dont want a framework and community with a gold standard you are free to go back to Java or PHP. Like it or not, Rails came up HUGE (and drug Ruby along with it) because DHH, and later the core teams decided on opinionated software. The Golden Path is what separates good rails code from bad more times then not.

For instance, you can jump around just about any auth plugin or roll your own. But if you dont include common idioms for rails authentication it will be unusable by most coders or gems. Do I think current_user is the best helper method name for this? Maybe, maybe not. But I am not going to start rolling my auth modules with anything else. Thank god for Golden Paths.

Oh, and if you are still writing pure javascript I have high doubts that you are very efficient.