I like to see how software reacts when I step off the happy path and make a mistake. Today I found this interesting difference with an unknown (or misspelled) command line option: "--derp": https://gist.github.com/dogweather/aac2dce97936484e765c04105ef6fa06 https://gist.github.com/dogweather/937420a48708ee36f3d0268161d61b80 An interesting difference! Personally, Django is reacting like I'd expect. And so for me it's following the principle of least … Continue reading Making mistakes: Django startproject and Rails new
Tag: Ruby
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
A Docker dev config for Ruby on Rails
I use Docker for all my client work, and most of my personal projects too. I love it. It's saved me a ton of money because it uses so much less RAM than Vagrant — what I had been using. Benefits of this config Just docker-compose up to set up and launch the dev environment … Continue reading A Docker dev config for Ruby on Rails
Why I don’t use let/let! in my RSpec
At work, we're deciding on our test-writing style: let/let! blocks like let(:arg) { 5 } vs. instance variables defined in a setup method like @arg = 5. I've found no advantage to let; but I have experienced disadvantages. I've found no disadvantages to instance variables. And so, 👍 for instance variables. I've written many specs … Continue reading Why I don’t use let/let! in my RSpec
DigBang: Safely unsafe Ruby hash traversal
Here's Hash#dig!, a handy little piece of code I wrote for a project. It's similar to Ruby 2.3's Hash#dig, but raises an exception instead of returning nil when a key isn't found. #dig is to #[] as #dig! is to #fetch Ruby 2.3 introduces the new Hash#dig method for safe extraction of a nested value. It's … Continue reading DigBang: Safely unsafe Ruby hash traversal
Goodbye “X for Y”: the cryptic Ruby error is becoming friendlier
Anyone who's used Ruby has seen this message: r.rb:1:in `name': wrong number of arguments (3 for 2) (ArgumentError) This particular error has been driving me nuts for years. It's just so unnecessarily difficult to interpret — especially if Ruby's not the only language you use. I never remember which number is which. Compare to Python: TypeError: … Continue reading Goodbye “X for Y”: the cryptic Ruby error is becoming friendlier
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
Test Driven Devops
I like to apply Test Driven Development to my sysadmin work. For example, every time I add a new redirect to a web server configuration I want to make sure I haven't broken anything else. Further, I want my SSL configurations proactively checked daily for any possible error. I use Ruby RSpec and write tests … Continue reading Test Driven Devops
Efficiency with Sublime Text and Ruby
https://thunderboltlabs.com/blog/2013/11/19/efficiency-with-sublime-text-and-ruby/ An excellent set of core ST tips. I learned a couple really handy things even though I've been using Sublime Text for over a year.
Meteor Won’t Kill Rails Anytime Soon
This is in response to Why Meteor will kill Ruby on Rails. A pretty big claim, for sure. Now, Meteor is worth checking out, but Josh didn’t name any of the reasons why I and a whole lot of others choose Rails. So here we go. It was its built-in support for these got me interested: CRUD (Create / … Continue reading Meteor Won’t Kill Rails Anytime Soon