4

We have done a lot of work testing on the rails side of our application now and are starting to try out unit testing on the javascript side using Teaspoon/Mocha/Sinon/Expectjs.

Now that we are digging deeper we are trying to find the right way to access rails fixture data. For example we want to be able to make a correct api call to (mocked) server with an ActiveRecord model's id number (to call, e.g., /users/:some_id), but these are generated at runtime by the fixture generation.

So far the only way we've gotten this to work is to create a MagicLamp fixture which renders json (instead of, say, a rails partial) and then to call MagicLamp.loadJSON() instead of MagicLamp.load. However this seems like a hacky way to achieve this. Essentially we hoped there'd be a way to have a file like magic_lamp.rb where you can just set up a function similar to the fixture helpers that Rails generates (e.g., users(:name_of_user) for a users.yml file).

I'll admit I may be asking the wrong question here, because it seems like this should be trivial. Maybe we're on the wrong path?

0 Answers0