jenkoian/lunchme — pull request #3 by athieriot (2013-03-03 13:02:48+00:00)
Title: Add RSpec testing of the API layer

I struggled a moment to get this because I'm a dumb and opinionated person (By that, I mean I wanted to do it MY way :p )

Anyway, just use __rake__ or __rake test__ and rspec will do it's magic.
You have also access to __./watch_test__ which will execute the tests every time you save a file. (__./watch_server__ do server for the Sinatra server)

The good part is the usage of EmbeddedMongo. It's a Ruby library that simulate a real MongoDB server. That way. We can test the db access in a closed environment.

The bad part is that I didn't succeed to "mock" the database connection into the test. So we end up with an ugly "if test" in the application code.

One condition for that to work though. EmbeddedMongo is not available as a Gem so I imported it as a git submodule. You have to execute: __git submodule update --init --recursive__

I also set a __.travis.yml__ file that SHOULD work but we will need to test it on live and do some adjustments.

Tell me what you think !

P.S: Will do another PR for Javascript testing (Using testacular) because it's not well integrated with Ruby.