Replies inline, below.

On Mon, Jul 18, 2011 at 8:20 PM, Derek Prior <derekpr...@gmail.com> wrote:
>> One of the patterns I am trying to
>> implement is from Ryan Bates' complex-form-examples[2]. Ryan's example
>> doesn't have any tests, so I am trying to write tests for the code.
>
> He's updated that with a later episode series. Search his site for "nested"
> and it's the first hit, I believe.

I've checked this, and I believe his github project to which I
referred uses the latest material from the railscast.

>> I am starting with a helper function that he wrote, which makes it
>> easy to add fields for an association into a form. The method does a
>> little reflection, renders a fields_for call into a string, and then
>> returns a link_to_function which calls a custom javascript function
>> that adds the fields to the form.
>
> The realization I'm coming to is that a helper spec isn't necessarily the
> best thing to cover this type of thing. RSpec is about specifying software
> behavior. The behavior you want to test is, if I recall correctly from the
> episode, that when the user clicks a link in the page, new association
> fields should be added to the form. I would likely skip the helper spec and
> test this with a request spec or cucumber scenario using capybara &
> selenium.

I think this is a very good point. Before I dipped from my cucumber
scenario directly into my helper spec, I should have written a request
spec, or alternatively made my cucumber scenario more fleshed out.
Perhaps what led me down the wrong path was knowing the code I needed
to have before I had any tests.

Since this is an educational project and there is no deadline to speak
of, I have been very strict trying to write the minimal amount of code
to make my tests pass, and thus I have very literal tests. In real
life, I don't think that is always possible—how would we every write
e-mail validators?—but maybe I am over emphasizing it, still.
Thoughts?
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to