I’m in the process of setting up cruisecontrolrb with RCov as our
continuous integration server. We use rSpec for our unit tests, and
AFAIK all the integration tests and system tests are done offline
(i.e. scripted but not automated).
I’ve heard that many people use Cerberus or “straight” CruiseControl
with Ruby. Is there a consensus over which one is better, if any?
And how do people automate their system and integration tests in
Rails? Is there a standard way to do this?
I can’t speak to server-oriented tools like CC, but you might want to
check out ZenTest [1] for continuous testing on your own development
machine. It has a tool called “autotest” that will run in the
background and re-run your tests every time you save a file.
I believe all you have to do is a: sudo gem install ZenTest and then
cd to the root directory of your rails project and type “autotest”.
I recommend using cruisecontrol. It should be fairly easy to set up
and will run all of your tests every time you commit a file. It has
the added option (a plugin, perhaps?) of sending a message through
jabber to somebody, or a list of somebodies, or even an email.
Autotest is good for your own box, but when cruisecontrol sends out
insults humiliating a team member because they committed a broken
build, it gives them the incentive not to do it again!
We’ve been using cruisecontrol.rb for a little while now and it’s
great. We’ve added a little tweak so that it fires on a subversion
post-commit hook rather than polling and everytime a build is broken
it emails us.
I recommend using cruisecontrol. It should be fairly easy to set up and
will
run all of your tests every time you commit a file. It has the added
option
(a plugin, perhaps?) of sending a message through jabber to somebody, or
a
list of somebodies, or even an email.
Autotest is good for your own box, but when cruisecontrol sends out
insults
humiliating a team member because they committed a broken build, it
gives
them the incentive not to do it again!
I’ve heard that many people use Cerberus or “straight” CruiseControl
with Ruby. Is there a consensus over which one is better, if any?
And how do people automate their system and integration tests in
Rails? Is there a standard way to do this?
Will.
–
Ryan B.
Feel free to add me to MSN and/or GTalk as this email.
I’m using CruiseControl.rb as well for all my Rails apps and also for
pure Ruby apps (including a datawarehouse project), and I’m also using
Rspec like you. I’ve had small issues setting up growl notifications,
but that’s all !
I’m using CruiseControl.rb as well for all my Rails apps and also for
pure Ruby apps (including a datawarehouse project), and I’m also using
Rspec like you. I’ve had small issues setting up growl notifications,
but that’s all !
Ah yes, I’m after something for this too. The problem is that I have 600
tests and they take 300 seconds to run. I also stumbled across
unit_record.
I’m sure there’s something rspec’y out there.
I’m using CruiseControl.rb as well for all my Rails apps and also for
pure Ruby apps (including a datawarehouse project), and I’m also using
Rspec like you. I’ve had small issues setting up growl notifications,
but that’s all !
I don’t suppose there’s any way to decouple unit tests from the
database in rspec for those models that extend ActiveRecord? I looked
at unit_record, but that seems to be for Test::Unit only.
If there isn’t, I’m just going to label anything that extends
ActiveRecord::Base as an integration test.
Ah yes, I’m after something for this too. The problem is that I have 600
tests and they take 300 seconds to run. I also stumbled across unit_record.
I’m sure there’s something rspec’y out there.
Looks like the best option is here:
As far as I can tell, the big problem with isolation is that
ActiveRecord depends on the database to tell it what fields it has.
I’m not sure that a database is much better than using a config file
for schema information in this case…
ActiveRecord depends on the database to tell it what fields it has.
I’m not sure that a database is much better than using a config file
for schema information in this case…
D’oh. Haven’t been reading my own posts: schema.rb IS the config file
containing schema information in this case. So unitrecord is the way
to go.
And then change the model specs and controller specs to use
‘unit_spec_helper.rb’ instead of spec_helper.rb.
There is one outstanding bug that I haven’t resolved: request,
response and controller have gone away, and you are now required to
declare @request, @response and @controller in the before(:each)
method.
There is one outstanding bug that I haven’t resolved: request,
response and controller have gone away, and you are now required to
declare @request, @response and @controller in the before(:each)
method.
Okay, it looks like moving the controller specs out of the normal
directory tree means there’s no autorecognition of what’s a
controller, model, etc. So if you’re using this scheme, you have to
define the spec type by hand:
describe FooController, “Foo Controller”, :type => :controller do
end
describe FooModel, “Foo Model”, :type => :model do
I don’t suppose there’s any way to decouple unit tests from the
database in rspec for those models that extend ActiveRecord?
I use mock objects and other test doubles with RSpec. A unit test
should test a unit, not the full pathway from ActiveRecord through the
RAID array.
Can you explain how you mock out the ActiveRecord::Base stuff?
Mocking is definitely more useful at the functional level, where you
can simply set up stubs and expectations for the models, then make
sure the controller calls them correctly, meanwhile having its own
behavior tested.
At the unit test level, I use mocks for complicated objects that the
object under test has to deal with. As for the object under test
itself, it’s just as easy to mock any ActiveRecord::Base methods that
you don’t want to go through the database. You might even mock the
connection.
///ark
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.