One of the really great things that Rails has done is provided us with script/console. This is such a handy utility and it works really well.
It’s no secret what I think of rack, but still, I’ll say it again. I think Rack is awesome, and although the spec is simple, when we conform to the spec we get new things from out of left field 😀 Enter (from field left) racksh This is pure gold IMHO. Install in the usual way:
$ gem install racksh
If we go back to the app we built up in my last post lets see how we can get a console for it.
∴ racksh ~ Loading Development Environment Rack::Shell v0.9.4 started in development environment. >>
See the awesomeness of rack there? Racksh does a very nice job at providing a console to all rack applications who follow the spec and also provide a config.ru file. Also, since it’s an awesome tool, it makes your fully stacked up application available at
$rack including goodness from Rack::Test so you get a whole bunch of methods for free 🙂 Lets try a few out.
∴ racksh ~ Loading Development Environment Rack::Shell v0.9.4 started in development environment. >> WagyuBlog::BlogEntry.all => [#] >> VegetableBlog::BlogEntry.all => [#] >> response = $rack.get("/wagyu") # snip response >> response.status => 200 >>
I’d suggest everyone checkout the docs and readme for both Racksh and Rack::Test to see what you can do with these great tools, and try them out. Use them with such frameworks as Sinatra, Rango, Pancake and many others 🙂