[rspec-users] Gem tutorials / setting up rspec in a gem
ramon.tayag at gmail.com
Tue Mar 30 22:19:04 EDT 2010
Thanks Ed I'll give this a shot too. I was able to get the
activerecord part working though. My problem was testing the
controller that I wanted to generate for the rails app.
Things that I'm used to being in the controller spec (get, put, etc)
aren't, because this RSpec installation is outside of rails. If I
could do this without putting a whole app I'd gladly do so as it
Those methods come from
action_controller/test_unit or active_support/test_unit. I tried
including both but it didn't work, and it's still fuzzy to me.
Now, if I waste too much time figuring this out, I may just do what
aslak suggested: put those tests in a rails app and write tests for
the app that is using this gem. In my mind it sounds slow, as aslak
probably has an automatic method to do this, but it definitely sounds
easier than learning what needs to be included/required.
On Wednesday, March 31, 2010, Ed Howland <ed.howland at gmail.com> wrote:
> Hi Ramon,
> Just a thought or 2.
> I'd still test/spec your gem outside of any Rails app, and I wouldn't
> use a sample Rails app in the spec folder.
> It sounds to me that you are writing a 'acts_as_xxxxx' type extension
> to ActiveRecord. You should only need the AR gem installed as a
> development dep for the gem.
> You'd need:
> gem.add_development_dependency "factory_girl", ">= 0"
> gem.add_development_dependency "rspec", ">= 0"
> gem.add_dependency 'activerecord', ">= 2.3"
> in your Rakefile. Note the use of FactoryGirl. This should help you
> fake stuff out for testing. No need for the full Rails stack, when all
> you need is to create
> some models.
> In my case, I created a models folder in my gem and put my usual model
> files in there. Then I require all of them in a Dir.each block in my
> With FactoryGirl, you don't even need to require them first, but in
> your case you probably need to to get the 'acts_as_xxxx'
> Ed Howland
what you think, we ink
More information about the rspec-users