Tim Harvey :: Blog

Icon

I help organizations who feel stuck

rSpec “Can’t find first {objectName}”

While cleaning up several rSpec tests for a Ruby on Rails app, I ran across an error that didn’t show up in Google. It didn’t make sense that my tests kept failing.

The solution was simple, but not obvious to a new rSpec user. The clean way to specify a validation is:

it { should validate_uniqueness_of( :title ) }

Unfortunately, I kept getting the error “Can’t find first Post” (where Post is the name of my object being tested. After some digging, it turns out that the shorthand notation assumes that you will have already added at least one Post to the database. It finds the first Post, then adds an identical one, expecting a failure.This would have been fine, but my “before” block didn’t have the usual

Post.create!( :title => 'Title' )

Instead, I had:

@valid_attributes = { :title => 'Title' }

So…you can either have your before block add at least one record, or skip the clean notation and do this:

it "should only accept unique Titles" do
  Post.create!(@valid_attributes)
  Post.new.should validate_uniqueness_of( :title )
end

That’s it!

Coldfusion 8 displays code and won’t execute

So after our Plesk 8 server crashed, Coldfusion didn’t come back up as expected. Our code wouldn’t execute and simply dumped the raw code to the browser. Displaying the code wasn’t what I had in mind.

After hours fighting with the crazy monster (and having to piece together instructions from countless online sources), I thought I’d pull it all together in one place. I hope you find this to be helpful!

For us, this applied to:

  • Plesk 8.4 for Linux (CentOS)
  • Coldfusion 8 Update 1

Error messages (or potential Google search bait) included:

  • There was an error while running the connector wizard
  • Connector installation was not successful
  • This web server is already configured for Jrun
  • ColdFusion 8 not started, will retry connector
  • Configuring the web server connector (Launched on the first run of the ColdFusion 8 start script)”
  • mod_jrun20.so
  • wsconfig.log
  • 0xb7e6d280
  • *** glibc detected *** free(): invalid pointer: 0xb7e6d280 ***
  • glibc detected
  • Error occurred during initialization of VM
  • Could not reserve enough space for object heap
  • From wsconfig.log: 02/18 21:53:44 error This web server is already configured for JRun. jrunx.connectorinstaller.ConnectorInstallerException: This web server is already configured for JRun. at jrunx.connectorinstaller.ApacheInstaller.installConnector(ApacheInstaller.java:186) at jrunx.connectorinstaller.ConnectorInstaller.installConnector(ConnectorInstaller.java:338) at jrunx.connectorinstaller.ConnectorInstaller.doIt(ConnectorInstaller.java:272) at jrunx.connectorinstaller.ConnectorInstaller.main(ConnectorInstaller.java:762)

Steps to correct the problem:

(The items after the # are console commands, I ran these all as “root”.)

Add Apache configuration and development compilation tools

# yum install httpd-devel

Correct paths in /opt/coldfusion/bin/connectors/apache_connector.sh

# cd /opt/coldfusion/bin/connectors</p>

<h1>vi .apache_connector.sh</h1>

<p>../../runtime/bin/wsconfig \
-server coldfusion \
-ws apache \
-dir /etc/httpd/conf \
-bin /usr/sbin/httpd \
-script /usr/sbin/apachectl \
-coldfusion

Add -apxs to set connector to do full recompile

# cd /opt/coldfusion/bin/connectors</p>

<h1>vi .apache_connector.sh</h1>

<p>../../runtime/bin/wsconfig \
-server coldfusion \
-ws apache \
-dir /etc/httpd/conf \
-bin /usr/sbin/httpd \
-script /usr/sbin/apachectl \
-coldfusion
-apxs

Kept getting “This web server is already configured for Jrun”, so had to destroy old compiled apache connector (which must have referenced the old config)

# mv /opt/coldfusion/runtime/lib/wsconfig \
/opt/coldfusion/runtime/lib/wsconfig-old

Run the apache_connector again, should see “CentOS release 4.5 (final)” several times with “Server version: Apache/2.0.52″ and then a bunch of /bin/sh compile commands roll past

# cd /opt/coldfusion/bin/connectors</p>

<h1>./apache_connector.sh

Will end with “The Apache connector was installed to /etc/httpd/conf”

Move the connectors script file so that it’s not trying to up (have to stop the services to make this work) from the Adobe KB

# /etc/init.d/coldfusion_8 stop</p>

<h1>cd /opt/coldfusion/bin</h1>

<h1>mv cf-connectors.sh cf-connectors-run.sh

Ahh, problem solved.

I hope this helped you out of a jam. I certainly appreciated all the people who took time to post the pieces and parts of the solution I had to pull together. Without their help, I don’t know how I would have gotten things sorted.

Finally have Exchange email working on the iPhone

Apple iPhoneThe iPhone now officially rocks my world.Yea, it should have been WAY easier to setup a simple integration with my work email, but that certainly wasn’t the case. However, the device offers so many other sexy features that I’m willing to overlook an evening of painful tinkering for the daily joy of using the iPhone. I mean, come on…how cool is it to cruise down the road and then accomplish the following sequence (at a stop light, of course):

  1. Hit Google Maps, using the cell towers to pinpoint my location
  2. Tap a quick search for the restaurant of my choice
  3. Locate the desired establishment, tap for details
  4. Tap the phone number, make reservations, then pound the gas upon green light

But really, I digress. Setting up IMAP for Exchange was pretty darn easy. The steps on the MonkeyKit blog made it a breeze. Most of it I had already done to accomplish email/vm integration with our VoIP phone system at work.The tricky part is sending email. Since we utilize PostINI for our spam processing, I have the SMTP service pretty darn locked down. That makes it about impossible to setup the iPhone to send email via SMTP through our firewall, into the Exchange server, and back out again without getting into some pretty heavy duty config. Since I’m the only one with this device, that seemed like overkill. I just can’t justify that kind of customization to our environment.Instead, I followed some advice I found from others facing the same problem to simply skip our Exchange server for SMTP and instead use Google. I setup my Gmail account to also allow sending emails as my work address. The iPhone sends any outbound messages through Gmail to the ultimate recipient. The recipient replies and those get routed into my work Inbox. Perfecto!Yea, the Treo was way the heck easier, but once again…it didn’t rock like the iPhone.

Get updates in your inbox

Enter your email address: