How would I spec this? --Rails subscriptions

I have a set of users
And a set of things … podcasts
Users should get a page that shows all of the podcassts with a check box

If they are subscribed then the check box is checked

Users table has first_name, last_name, user_name
Podcats table has podcast_name, description, url
Subscriptions table has user_id, podcast_id, subscription_type

Would the view go in the subscription views?

Is this a index view?

How do I mock out the view?

I think I want to spec something so that I set up three mock models for
podcasts:

before(:each) do
assigns[:user] = @user = stub_model(User,
:new_record? => false,
:user_id => 1,
:first_name => “Fred”,
:last_name => “Flintstone”,
:user_name => “fflintstone”
)
assings[:repository] = @repository = [stub_model(Podcast,
:new_record? => false,
:name => “podcast1”,
:host => “podcast.podcast.com”,

),
        stub_model(Podcast,
        :new_record? => false,
        :name => "podcast2",
        :host => "podcast.podcast.com",
),
        stub_model(Podcast,
        :new_record? => false,
        :name => "podcast3",
        :host => "podcast.podcast.com",
)

]
assigns[:subscription] = @subscription = [ stub_model(Subscription,
:new_record? => false,
:user_id => 1,
:podcast_id => 1
),
stub_model(Subscription,
:new_record? => false,
:user_id => 1,
:podcast_id => 2
)]
end

then look to make sure that it renders all of the podcasts and the ones
that are subscribed subscribed checkbox is selected:

It “should render the subscriber select form” do
render

now what?

end

Thanks

Brian Colfer

On 21 Apr 2009, at 00:34, Colfer, Brian wrote:

        :new_record? => false,
        :new_record? => false,
stub_model(Subscription,

render

I am going to go out on a limb…

I would suggest, if you have, time, that you do some research on using
Cucumber to express these specifications instead. These are precisely
the kind of brittle view tests (smelled by the large amounts of
mocking set up required) that I built loads of myself 9 months ago
when I first started with RSpec (and before I discovered Cucumber) and
have spent the last 6 months, once I’d learned better, dismantling
again and replacing with much more flexible, readable, Cucumber
features.

Sorry, I know that’s not a direct answer to your question, but you
might thank me for it eventually.

If you want some help learning Cucumber, try these resources:
http://cukes.info/
http://wiki.github.com/aslakhellesoy/cucumber

Hope that helps.

Matt W.
http://blog.mattwynne.net

Thanks Matt I’m fairly comfortable with cucumber and I have the
acceptance tests. I’m looking to see if I can follow through on the
BDD process.

Sent from Brian’s iPhone