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