Forum: RSpec Speccing the format portion of a controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2009-02-07 12:32
(Received via mailing list)
Hi -- I have a hacky work-around for this, but wondered if anyone could
tell
me the canonical way of sending the get/put/etc. portion of a spec with
format information.I guess with something that might look like this:

def do_get
  get :index, :format => :xml
end

Cheers,
   Doug.
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-02-07 15:24
(Received via mailing list)
On Sat, Feb 7, 2009 at 5:16 AM, doug livesey <biot023@gmail.com> wrote:
> Hi -- I have a hacky work-around for this, but wondered if anyone could tell
> me the canonical way of sending the get/put/etc. portion of a spec with
> format information.

This is what is in the specs generated by rspec-rails:

  request.env["HTTP_ACCEPT"] = "application/xml"
  get :index

HTH,
David
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2009-02-07 17:02
(Received via mailing list)
Cheers for that -- that's what I thought was the hacky solution! ;)I'm
now
reassured that I'm not being evil -- thanks!
   Doug.

2009/2/7 David Chelimsky <dchelimsky@gmail.com>
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-02-07 17:16
(Received via mailing list)
On Feb 7, 2009, at 10:00 AM, doug livesey <biot023@gmail.com> wrote:

> Cheers for that -- that's what I thought was the hacky solution! ;)
> I'm now reassured that I'm not being evil -- thanks!

Not so fast! It works, and it's what rspec uses, but that doesn't make
it good ( as opposed to evil ).

I'd add support for something friendlier, but maybe it really belongs
in rails proper.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2009-02-07 19:39
(Received via mailing list)
On Sat, Feb 7, 2009 at 3:16 AM, doug livesey <biot023@gmail.com> wrote:.

def do_get
  get :index, :format => "xml"
end

should work.  Notice it's a string instead of symbol.

Pat
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2009-02-07 19:41
(Received via mailing list)
Well, I can guarantee that it's better than any home-grown solution I
would
attempt, so I'll be happy w/ that for now! ;)Cheers again,
   Doug.

2009/2/7 David Chelimsky <dchelimsky@gmail.com>
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-02-07 21:55
(Received via mailing list)
On Sat, Feb 7, 2009 at 10:20 AM, Pat Maddox <pergesu@gmail.com> wrote:
> On Sat, Feb 7, 2009 at 3:16 AM, doug livesey <biot023@gmail.com> wrote:.
>
> def do_get
>  get :index, :format => "xml"
> end
>
> should work.  Notice it's a string instead of symbol.

I should change the gen'd specs then. That's simpler, ay?
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 Doug Livesey (biot023)
on 2009-02-08 18:01
(Received via mailing list)
Groovy!Cheers,
   Doug.

2009/2/7 David Chelimsky <dchelimsky@gmail.com>
This topic is locked and can not be replied to.