On Aug 16, 2009, at 8:01 PM, Chamnap <chamnapchh...@gmail.com> wrote:

I did the same thing as you did, but it doesn't work.  The respond_to
method still responses back in "application/xml". Any idea?

Did you spell it ACCEPT ( all caps )?


On Aug 15, 8:49 pm, David Chelimsky <dchelim...@gmail.com> wrote:
On Sat, Aug 15, 2009 at 5:35 AM, Chamnap<chamnapchh...@gmail.com> wrote:
I tried several hours to mock. What I want is basically to send "http accept" let's say "application/json" and want rails to send data back in json. Therefore, i need to mock that headers to do a test. I think
I mocked that header already, but rails still sends me back in xml.
Anyone could help me?

I think you mean stub (mocking means setting an expectation that a
message is received - sounds like you're just trying to set a value
for the controller to access).

Assuming you're using a rails version using rack (can't remember when
that was introduced - 2.1?), you can do this:

it "should return json" do
  request.env['ACCEPT'] = "application/json"
  get whatever_the_path_is
  ...
end

HTH,
David
_______________________________________________
rspec-users mailing list
rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/ rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to