I didn’t realize that Cucumber was so versatile…
Try adding the following to your Gemfile:
gem 'thin', :group => :test
and see what happens.
Ask for Help
- Double-entry/ledger based accounting in Rails (i.e. Quickbooks in Rails for free)
Ideally would be tied in with user/role system where each accounting entry would be tied to a user, but also reconciled against a master account.
Recommendations? Latest and greatest?
- Error message when opening Rubymine “Invalid Git Root”
This is likely because the project included a submodule that wasn’t configured correctly, fix this in under Rubymine’s version control preferences.
- Test 404 handling (e.g.
rescue_from ActiveRecord::RecordNotFound, :with => :render_record_not_found) with Cucumber by temporarily setting
ActionController::Base.allow_rescue = true. This is usually set to
JSON.pretty_generatehates Rails 3
- Use window.postMessage to communicate between IFrames in a standard way
This should work in most modern browsers. Follow the Mozilla docs, NOT the various blog posts about this.
Ask for Help
“Do you have to use to_param in functional tests?”
In the past you could simply provide an object in a param list in functional tests and the
to_param for the object would be called to get the proper value for the parameter. This is now broken, forcing you to use object.to_param every time.
Perhaps not helpful for existing projects but I recommend you use cucumber, webrat, or even selenium rather than Rails functional tests. Rails functional tests require that you specify parameters and specify them correctly. If you get them wrong your functional tests might continue to pass for the wrong reason. Here’s another “bad params in functional tests” post.
- Rubyconf program should be available today on their website
Here’s the gist of this post: gist.github.com/58876
Ever since I’ve started using Webrat, a lot of the pain of Selenium has gone away
for me. There’s still a little bit of pain though. Part of it is caused by the fact
in your current window under test. Well no more. Here’s a helper:
To use it with Cucumber, do like so:
World do |world| world.extend(SeleniumHelpers) world end
To use it with POS, do like so:
that it’s always going to return a
String, so you may have to massage the output
While Webrat’s DSL for traversing web apps is awesome, I’ve always found the
alternatives (Polonium for example) to not jive well with how I think. They’re
way better than talking directly to Selenium, you’re still locked in to a certain
fit your own style.
Now you can write your tests like so:
Credit should go to Brian Takita, since he did most of the hard work and I just wrote a method. Let me
know if you have any issues or ideas with the helper, and may all your tests be green.