March 25th, 2008 at 10:31 pm
(Rails)
Remember all that joy coding with Rails when you were a wee lad? Things seemed so blissful then, metaprogramming voodoo and that complex object relational mapping stuff were all taken care of behind the scenes.
Alas, whence it doth time to unleash your brilliant social networking app onto the unsuspecting public, your Ruby/Rails world came crashing down faster than FSJ can order a chai latte.
FastCGI, SCGI, Mongrel, Rack, Thin, Pound, Nginx, Apache.
Doing a virgin Rails application deployment would have been a trial by fire where you’ll trawl the Ruby and Rails forums looking for advice on which webserver is best suited to serve your future web application superstar or pray to the One and just deploy on faith.
You’ll settle for Mongrel or Rack if you were lucky enough to come across people who have been there before. Otherwise, be prepared to be regaled with war stories about how some web hosts *COUGH* Dreamhost *COUGH* arbitrarily shutdown your Rails processes for consuming a tad too much resources.
Wouldn’t it be nice if I could just do like what I did for PHP applications? Just upload the files onto the webserver and it just works(tm)?
Now you can! Well, technically only the people at Phusion can at this moment. Lai Hongli breaks the news about modrails, complete with requisite cool screencast.
I think this is a really cool development that makes life a whole lot simpler for people who just want to focus their energies on actual development rather than have to worry about how to configure the deployment environment properly. Even if this is Apache2 only now, it should be possible to port it over to other servers like Nginx, licence restrictions notwithholding.
1 Comment
March 24th, 2008 at 12:20 pm
(Behaviour Driven Development, Ruby)
RSpec allows a developer to specify that an error is raised within a block with the raise_error method. It's a nice expressive way of saying that your code should fail when it needs to.
But my tiny brain has often been confused with using it at times, more so when the error class requires parameters for instantiation and when used in conjunction with the and_raise method on a stub or a mock
Consider the snippet below where my Widget depends on Thingamajig to do its funky thing in order to run. But Thingamajig is rigged to explode in a mass of funkyness and make Widget all useless.
CODE:
-
describe Widget do
-
it "should re-raise errors as a Widget::UnrecoverableError" do
-
# expectations
-
thingamajig = stub(Thingamajig)
-
thingamajig.should_receive(:do_funky_thing).and_raise(Thingamajig::FunkyExplosion.new('The funky thang exploded yo'))
-
-
# our SUT
-
widget = Widget.new(thingamajig)
-
-
#verification
-
lambda { widget.run }.should raise_error(Widget::UnrecoverableError, 'The funky thang exploded yo')
-
end
-
end
Do you notice the inconsistency between the way errors are declared in the expectation and the actual verification?
CODE:
-
# expectations
-
thingamajig.should_receive(:do_funky_thing).and_raise(Thingamajig::FunkyThingExplosion.new('The funky thang exploded yo'))
-
-
#verification
-
lambda { widget.run }.should raise_error(Widget::UnrecoverableError, 'The funky thang exploded yo')
The expectation on the stub, 'thingmajig' needs the exception instantiated first while verification requires the class name and parameters used to instantiate the error instance.
And no, doing it like this doesn't work as expected:
CODE:
-
lambda { widget.run }.should raise_error(Widget::UnrecoverableError.new('The funky thang exploded yo'))
It's an unfortunate impedance mismatch that might be caused due to the way Ruby handles the raising of errors.
Comments