- As suggested in 09/03, one project switched to using Solr for search indexing. We were warned that wide range queries might be slow (looking for a value between 1… 10000) could be very slow, but it is not, at least with 400K indexed documents. We’ll watch out for slowdowns as the number of indexes increases.
Ask for Help
“JSUnit tests do not show line numbers for assertion failures, which makes it hard to know which assertion failed. Suggestions?”
Have fewer assertions per test, or use the message argument, such as
assertEquals(foo, bar, 'foo should be the same as bar.').
“Is there any way to see test failure stack traces as soon as a test fails or errors? This would be especially nice for slow-running Selenium tests.”
A few Pivots remember hacking on
Test::Unit and Rspec to display failure details immediately, but more research is needed. Perhaps there’s a plugin?
“Design Adam’s beard!”
Pivot Adam is shaving is beard and is looking for facial hair suggestions. Over the years he has displayed many of the “standard” beards and mustaches, so it’s time to get creative. Look to The Quest For Every Beard Type for inspiration. Here is your canvas:
Ask for Help
“Is there something wrong with Net::SSH in the latest versions of Capistrano? I can’t deploy to localhost…”
Not that anyone knows of. Have you tried turning it off and on again? The power button… it’s the little glowing button on the front… the button on the front… Are you from the PAST?
“Is there a good ruby Gem or Plugin for working with the Google Charts API?”
One pair used gchartrb but abandoned it almost immediately. So far, it’s string << string << string.
Unfortunately not. Desert plugins should have an
Ask for Help
“We are getting 504 Gateway errors and we thing it is because our mongrels are freezing up do to inability to allocate memory, what to do?”
Without more info on the problem a few possibilities were suggested, such as the OS might be swap thrashing or the OS has no more memory to allocate.
One suggestion is to cut down your swap space to 0 in an attempt to verify that your mongrels are asking for too much, basically remove to OS swapping memory to disk from the equation.
Another suggestion is to boost your swap up to some insane size, also to take it out of the equation, the theory being that we know mongrel can leak memory, we trust the OS to keep the used memory in RAM, and we have plenty of disk space, so why put your OS in the position of not grating a mongrel what it is asking for.
Both solutions above don’t seem ideal but, whatever, we are pragmatists, and if we combine those with periodic monitoring of the system using top/ps/vmstat, at least your mongrel can keep running and this may give you time to figure out why mongrel may be so memory hungry
- If your wanting better out-of-the-box error messaging you can use one or both of the following plugins:
If you choose to use both however ORDER DOES MATTER (use the order specified above) otherwise the validates_associated one just doesn’t seem to work.
- Hash Iterations is very expensive (this includes my_hash.keys and my_hash.to_a etc…). We think this is related to the way hashes are stored in large, sparsely populated hashtables. If you can, avoid iterating over a hash, and if you must, try using a SequencedHash (which is provided by the collections gem) which solves this by storing hashes as both traditional hashtables and arrays, allowing for fast random access (the hashtable) as well as fast iteration (the array).
Ask for Help
“We want to load a different set of libraries for our selenium test than our regular tests. We tried to create a ‘selenium’ environment and pass that to the rake:test task but that didn’t work, anyone know why?”
You cannot run in non ‘test’ environment with the rake tasks as the ‘test’ environment is hard coded into the test task, and passing a different RAILS_ENV seems to only have the effect of telling the ‘test’ environment what database to base it’s schema off of.
Proposed work around – pass a second environment variable e.g. selenium=true and switch on that. (it’s not ideal so we are still open to better solutions)
- If you have a “target” method on your model, things will get a bit weird when you try to access this method through an association. Since associations have their own “target” method, you actually need to call assocation.target.target, or probably better, don’t create methods called “target”.
- Since Time.now always returns the time for the local timezone, if you use it in your fixtures, but then have your app running under a different time zone, the times in your fixtures will be incorrect. Use the active support helpers such as 0.days.ago instead, or if you have a timezone configured in your environment, you can use Time.zone.now
Ask for Help
“How can I test the route helpers in RSpec? If I’m passing a complex set of options to a helper I’d like to test that it’s giving me what I expect.”
Nobody had any serious suggestions, although many humorous testing scenarios were mentioned.
- When using time zones in Rails 2.1, if you specify a zone, any datetime ActiveRecord attributes will be returned in that zone. E.g. if you specify Eastern Time, and then later request changed_at from an ActiveRecord, it will be returned in ET. However, if you ask for
Time.now it is always returned in the local time zone, regardless of TZ settings. This isn’t necessarily bad or unexpected behavior, but it can lead to test failures if you save a time to an ActiveRecord, get it back, and then compare the values. One workaround is to use
Time.zone.now, which will always respect the current time zone, although this doesn’t help with large existing codebases.
Ask for Help
“We’re FlexMock for some of our Test::Unit unit tests, and recently added some new tests; nothing that is exercising new parts of the code or creating new mocks. However, for some reason when we call previously existing mocks we get errors from Rspec. These are not exceptions or assertion failures, but full-stop errors as if there were a syntax error. Turns out Rspec reopens the Test::Unit::TestCase class and overwrites some behavior, although the cause of the errors remain entirely unclear. Anyone know why it would do that and how to prevent it in the future?”
A few people mumbled about Rspec magic, but actual help was not immediately forthcoming.