Nice, I see you have the obligatory JSON helpers in there as well :)


I always end up wishing for just a little more tooling than is readily
available for testing against APIs, but I feel silly writing it myself
since surely everyone has the same problems...





On Fri, Feb 14, 2014, at 10:50 AM, James Miller wrote:

Hey Ian,

This isn't specific to OAuth, but I mix in this API macros module to my
tests (I generally use rspec/rack-test for API testing):

[1]https://gist.github.com/bensie/9006703

Then in specs that require auth, I use authorize_token(token) or
authorize_basic(user, pass). Nothing fancy, but it works.

James




On Fri, Feb 14, 2014 at 10:45 AM, Ian Young <[2]i...@iangreenleaf.com>
wrote:

This seems like a common need, so thought I'd check and see if anyone
knows of a nice way to handle this. I keep ending up writing specs
against authenticated API endpoints, and want a nice way to a)
encapsulate the repetitive work of creating credentials for a user, and
b) automatically pass the credentials in the preferred form (HTTP
header, extra query param, whatever) on all authenticated requests. I
hate having a test suite where every request has `{"Authorization":
"token #{access_token}"}` cluttering it up. I use rspec, but would
assume that most solutions would be equally viable in MiniTest.

--

--

SD Ruby mailing list

[3]sdruby@googlegroups.com

[4]http://groups.google.com/group/sdruby

---

You received this message because you are subscribed to the Google
Groups "SD Ruby" group.

To unsubscribe from this group and stop receiving emails from it, send
an email to [5]sdruby+unsubscr...@googlegroups.com.

For more options, visit [6]https://groups.google.com/groups/opt_out.


--

--

SD Ruby mailing list

sdruby@googlegroups.com

[7]http://groups.google.com/group/sdruby

---

You received this message because you are subscribed to the Google
Groups "SD Ruby" group.

To unsubscribe from this group and stop receiving emails from it, send
an email to sdruby+unsubscr...@googlegroups.com.

For more options, visit [8]https://groups.google.com/groups/opt_out.

References

1. https://gist.github.com/bensie/9006703
2. mailto:i...@iangreenleaf.com
3. mailto:sdruby@googlegroups.com
4. http://groups.google.com/group/sdruby
5. mailto:sdruby%2bunsubscr...@googlegroups.com
6. https://groups.google.com/groups/opt_out
7. http://groups.google.com/group/sdruby
8. https://groups.google.com/groups/opt_out

-- 
-- 
SD Ruby mailing list
sdruby@googlegroups.com
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sdruby+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to