Rob Olson's blog



Rob OlsonRob Olson
Standup 04/07/2010: Passenger, Solr, Git, and rSpec timeouts
edit Posted by Rob Olson on Friday May 07, 2010 at 05:33PM

Ask for Help

Passenger Memory Bloat

"We found one of our passenger workers is using around 900MB of memory. Has anyone has problem with Passenger memory usage? We are using REE 1.8.7-2009.10."

Solr Master-Slave Replication

"We are interested in adding automatic failover to our Solr slave when the master fails. What are some strategies for doing this?"

Interesting Things

Git Push --force Blocked
If you find your git push being rejected, even when you use git push -f, it's probably because your git server is configured to not allow non fast-forward pushes. You'll need to change the server configuration to allow them.

spec --timeout
Be careful when running rspec with the --timeout option. When the timeout occurs the test process will be interrupted and it will print out a stack trace for wherever it was executing when it was interrupted. This can lead to a lot of confusion if you do not immediately realize it was the result of timing out and instead think that an exception actually occurred at that point.

Rob OlsonRob Olson
Standup 07/20/2009: render_template bug in RSpec
edit Posted by Rob Olson on Monday July 20, 2009 at 01:54PM

Interesting Things

Prior to RSpec 1.2.7, render_template in rspec-rails had a bug where render_template('new') would pass if 'newer' was rendered (or anything that started with 'new'). Internally render_template was converting the string argument to a regular expression which was allowing 'new' to positively match 'newer' even though it was not an exact match. In RSpec-Rails 1.2.7 this bug has been fixed.

Rob OlsonRob Olson
Using assert_select and friends in Helper Tests
edit Posted by Rob Olson on Monday July 06, 2009 at 08:19PM

Assertions such as assert_select, assert_tag, and css_select are powerful tools in view tests. Since view helpers generate a chunk of HTML, it is sometimes practical to use these assertions to test their return value.

If you attempt to use assert_select it will fail because there has not been a call to render, as is done in a view test. To get around this you can store the result of the helper method in @response.body. Once @response.body is populated, the assertions will work like expected.

Update: For people using RSpec, Pat Maddox posted a helpful suggestion in the comments showing how to use have_tag to accomplish the same thing in RSpec style.

Example

describe TagsHelper do
  describe "#tag_list"
    describe "when the user is not an admin"

      it "should not have links to delete the tags" do
        @response.body = helper.tag_list
        assert_select "a", 0
      end

    end
  end
end

Rob OlsonRob Olson
Use Autospec to Your Advantage
edit Posted by Rob Olson on Saturday July 04, 2009 at 11:15PM

I like Autotest because it allows me to stay within my code editor and let my test suite run automatically in the background. After each run I get a nice, unobtrusive, growl notification informing me whether my most recent change caused the tests to fail or pass.

It used to be that setting up and configuring Autotest for the OS X with pretty growl notifications was a nontrivial task. I remember that I spent several hours getting it working a year ago. However, there has been several developments with Autotest in recent months that greatly simplify the process. One of those enhancements is that Autotest can now use FSEvent introduced in OS X Leopard so that it no longer has to continuously poll the filesystem. This has the advantage of vastly reducing Autotest's CPU usage when idle.