Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Brandon Barrette
Brandon Barrette
20,485 Points

Rspec & ODOT View Specs

I'm curious if it's necessary to have view specs if we are doing feature spec testing. I noticed it wasn't covered at all in the ODOT user authentication videos, but my tests throw errors here (mainly because we are changing the default views generated).

Any advice on good rspec testing practices would be extremely helpful! Thanks in advance!

2 Answers

Patrick Metcalfe
PLUS
Patrick Metcalfe
Courses Plus Student 7,563 Points

I wondered the same thing and here what I've come to understand. There are three separate test folders for models views and controllers. And the test in each should be unique to that part. Just like MVC is a separation of concerns, the tests must only depend on that part. The feature tests that were written are different and are thus not view tests or controller tests. They test to see if using the view the controller can update the model. Since they test the interconnection of the parts, they are in a separate folder: "features." They for example test the feature of creating a todo list using the view. Thus each part of MVC's test folder should only include the tests for that part. Model tests should only test model behavior and view tests should only test view behavior. A view test could be, for instance, testing that if a todo item is completed the time shows and the "Mark Complete Link" does not. That is a feature specific to the view and does not require the controller or the model. (Meaning your testing the view's code works as it should, not that the model's #completed? Method works.) I hope...

describes "your problem" do
  context "with an adequate solution" do
    it "is answered"do;end
  end
end
Brandon Barrette
Brandon Barrette
20,485 Points

Thanks! Not as many tutorials on view spec testing. Plus it seems tedious, especially if your rearrange your views. But, as I learned by not testing, it's better in the long run.