[rspec-users] rspec-rails does not have a matcher for assert_generates

92 views
Skip to first unread message

deepak kannan

unread,
Jul 26, 2012, 6:07:44 AM7/26/12
to rspec...@rubyforge.org
hi,

rails minitest has assertions for assert_generates, assert_recognizes and assert_routing

rpsec's "routes_to" delegates to assert_recognizes
http://rubydoc.info/gems/rspec-rails/frames

But there is no mention of assert_generates

why does rspec-rails not have a matcher for assert_generates ?
i can of-course call 'assert_generates' from rspec

-- 
best,
deepak

David Chelimsky

unread,
Jul 26, 2012, 6:30:00 AM7/26/12
to rspec-users
On Thu, Jul 26, 2012 at 6:07 AM, deepak kannan <kannan...@gmail.com> wrote:
> hi,
>
> rails minitest has assertions for assert_generates, assert_recognizes and
> assert_routing
>
> rpsec's "routes_to" delegates to assert_recognizes
> http://rubydoc.info/gems/rspec-rails/frames
>
> But there is no mention of assert_generates
> http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_generates
>
> why does rspec-rails not have a matcher for assert_generates ?

I never found assert_generates useful for the way I approach testing.
If you give me an example of how/when you'd use it I can try to
explain.

> i can of-course call 'assert_generates' from rspec
>
> --
> best,
> deepak
>
> _______________________________________________
> rspec-users mailing list
> rspec...@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

deepak

unread,
Jul 27, 2012, 4:45:33 AM7/27/12
to rspec
> I never found assert_generates useful for the way I approach testing.
> If you give me an example of how/when you'd use it I can try to
> explain

bad habit mostly. to test cases where "url_for" is used

eg. in rails3.0 routes like,  post "ipn" => "payment#ipn"
do not generate a url_helper automatically
and url_for is used instead of adding the url_helper

On Jul 26, 3:30 pm, David Chelimsky <dchelim...@gmail.com> wrote:
> On Thu, Jul 26, 2012 at 6:07 AM, deepak kannan <kannan.dee...@gmail.com> wrote:
> > hi,
>
> > rails minitest has assertions for assert_generates, assert_recognizes and
> > assert_routing
>
> > rpsec's "routes_to" delegates to assert_recognizes
> >http://rubydoc.info/gems/rspec-rails/frames
>
> > But there is no mention of assert_generates
> >http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingA...
>
> > why does rspec-rails not have a matcher for assert_generates ?
>
> I never found assert_generates useful for the way I approach testing.
> If you give me an example of how/when you'd use it I can try to
> explain.
>
> > i can of-course call 'assert_generates' from rspec
>
> > --
> > best,
> > deepak
>
> > _______________________________________________
> > rspec-users mailing list
> > rspec-us...@rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

--
deepak

David Chelimsky

unread,
Jul 28, 2012, 7:36:24 AM7/28/12
to rs...@googlegroups.com
On Fri, Jul 27, 2012 at 4:45 AM, deepak <kannan...@gmail.com> wrote:
>> I never found assert_generates useful for the way I approach testing.
>> If you give me an example of how/when you'd use it I can try to
>> explain
>
> bad habit mostly. to test cases where "url_for" is used
>
> eg. in rails3.0 routes like, post "ipn" => "payment#ipn"
> do not generate a url_helper automatically
> and url_for is used instead of adding the url_helper

I'm confused - you're using assert_generates to test thing's that
don't get generated? Wouldn't you use assert_recognizes in that case,
in which case you would treat it like any other route:

{ :post => "ipn" }.should route_to("payment#pin")
> --
> You received this message because you are subscribed to the Google Groups "rspec" group.
> To post to this group, send email to rs...@googlegroups.com.
> To unsubscribe from this group, send email to rspec+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

deepak

unread,
Jul 30, 2012, 11:03:23 AM7/30/12
to rs...@googlegroups.com

I'm confused - you're using assert_generates to test thing's that
don't get generated? Wouldn't you use assert_recognizes in that case,
in which case you would treat it like any other route:

{ :post => "ipn" }.should route_to("payment#pin")


yes. my bad. this was due to the fact that the code uses 
url_for(controller: "payment", action: "ipn") 
everywhere. so the tests also reflect this fact.

was curious as to why rspec does not use assert_generates and assert_routing. which got cleared :-)

Reply all
Reply to author
Forward
0 new messages