MacksMind

Technical Wizardry, Rants, and just a Whiff of Insanity

Entries for the ‘programming’ Category

Verifying select field value with Cucumber and Webrat

I’ve been using Cucumber and Webrat for only a couple months now. Today I needed something new and it wasn’t obvious how to make it work. Here’s an example of a test in Cucumber: Given I am Sam When I follow “Foo” Then the “Bar” field should contain “Baz” Which relies on Webrat: Then /^the [...]

Comments (13)

Using belongs_to in Rails model validations when the parent is unsaved

Can’t get there from here In one of my Ruby on Rails projects, I have a model validation which is dependent on attributes from a belongs_to parent. Normally, you can refer to a parent model as child.parent and access the parent’s attributes as child.parent.attr. The difficulty arises when the parent object is unsaved. Let’s look [...]

Comments (9)