With Rspec how can I make use of it?

54 views
Skip to first unread message

Div

unread,
May 26, 2011, 5:37:58 AM5/26/11
to webmock-users
Hi,
my application gets authorized by a sinatra service run on port 3001.
So when I ever I run rspec spec/controllers/testing_controller_spec.rb
it goes to a URL like this to get authorized 'http://localhost:3001/
validate.json?token_value=somexyz'. I bcz of this all my test cases
fails since each time before_filter is applied to check authenticity.
I tried stubbing this before(:each) as follows
stub_request(:get, "http://localhost:3001/users/validate.json?
token_value=token_dummy").to_return({:user=>User.first,:token=>UToken.first})
(Since my methods returns this two objects I returning as an array).

But when I run my spec it goes to API call & erroring out with an
exception
"<response><result><success type=\"boolean\">false</
success><message>undefined method `[]' for false:FalseClass</
message><status_code>10000000</status_code><status>Failure</
status><validation_errors nil=\"true\"></
validation_errors><timestamp>Thu May 26 09:25:16 UTC 2011</timestamp></
result><data></data></response>"

I am using rspec2.5.0 and rails 3.0.6 . Any solution or better ways to
do this will be highly appreciated.

Thanks

James

unread,
May 28, 2011, 12:19:24 PM5/28/11
to webmock-users
Hi Div,

Take a look in your log file to see where the undefined method error
is coming from; paste the backtrace here and someone might be able to
help.
Reply all
Reply to author
Forward
0 new messages