Testing the multi-subdomain Rails app

Writing tests for a multi-tenant, multi-subdomain app turns out to be very tricky to figure out, e.g.: I saw that, and understood the frustration. Integration tests ("request specs" or "feature specs") are built on a stack of frequently changing libraries and shifting API's. And the recipe for subdomain-aware testing isn't documented in any particular tool's notes. … Continue reading Testing the multi-subdomain Rails app

Self-validating Ruby objects with ActiveModel Validations

I'm importing lots of CSV restaurant inspection data with Ruby, and I need to make sure the cleaned up data matches the spec. For example, a violation must have a business_id and date. It can optionally have a code and description. My goal was to be able to write a class like this: ...and it would … Continue reading Self-validating Ruby objects with ActiveModel Validations

Yes, Rails does support case-insensitive queries

They're unfortunately just a little buried and a little undocumented. And so conventional wisdom is that Rails doesn't do case-insensitive finds. But in fact it does: Example 1: Find all the statutes whose name begins with texas, case-insensitively: Example 2: Same query, using the excellent Squeel gem which makes this a little nicer: Results: Both examples generate … Continue reading Yes, Rails does support case-insensitive queries

It is supremely important that we ensure our data is safe. . .

. . . it is supremely important that we ensure our data is safe, consistent and reliable. We can dramatically increase these factors by taking full advantage of the tools at hand. Yes. This is the most critical, important task in software development. A great set of posts, Coding Rails with Data Integrity by Jay … Continue reading It is supremely important that we ensure our data is safe. . .