Initializing the test database before a Cucumber session (in Rails)

In one of my side projects, I needed some setup data to be present in the test database before each Cucumber session. Since this took me a few moments to get right, I figured I’d document it here. Continue reading

Posted in Rails, Ruby | 4 Comments

The value of Behavior-Driver Development and cohorts

Plenty has been written on the merits of BDD, TDD, and friends. However, I’ll address them from a different angle: in previous posts, I argued that programming languages were remarkably similar to natural languages, and a later post suggested you always focus on the outcome. It follows, then, that software can be written much like a novel, and that’s where BDD/TDD comes in. Continue reading

Posted in Uncategorized | Comments Off on The value of Behavior-Driver Development and cohorts

Focus on outcomes

In everything I do, I try to keep the goal in mind. Focusing on the outcome now comes quite naturally to me, but I’ve noticed that what I now take for granted, others seem completely oblivious to. And this goal-oriented thinking is applicable to most undertakings. Continue reading

Posted in Architecture | Comments Off on Focus on outcomes

Cucumber tweaks

I’ve lately started to use Cucumber and Selenium (via Capybara) “for real” to be used as the testing mechanism on my latest Rails project. In fact, I’ve been relying on it quite heavily to test views : I skipped the RSpec tests for views, routes, and others, and only use RSpec for unit and controller specs. The rest is tested through Cucumber, since it drives the entire stack; previously, I would make some dumb mistakes where (e.g.) some form fields wouldn’t appear, but my views specs didn’t catch it. Continue reading

Posted in Rails | Comments Off on Cucumber tweaks

On programming fluency (cont’d)

In the previous post, I covered how I consider programming languages to be similar to (foreign) natural languages, and how one can go about learning the basics. We’ll now move on to how a coder can build on this initial limited knowledge to become proficient in his craft. Continue reading

Posted in Uncategorized | Comments Off on On programming fluency (cont’d)

On programming fluency

Over on Slashdot, a discussion on programming prompted me to organize various thoughts I’ve had on programming. Having acquired several languages as a child (i.e. effortlessly) and going on to learn other languages (both natural and programming languages) as a teenager (i.e. through deliberate practice), I’ve always thought of coding on the same terms as natural languages: a means to express oneself and communicate information. Continue reading

Posted in Uncategorized | Comments Off on On programming fluency

Leveraging Active Record reflections

I recently ran into an issue using the permanent records gem: when you permanently destroy a record (i.e. NOT soft delete), the dependent records with a `:dependent => :destroy` relationship are only soft deleted (i.e. marked as deleted, but kept in the database). Let’s see how we can implement the desired functionality by leveraging Active Record’s reflections. Continue reading

Posted in Rails, Ruby | Comments Off on Leveraging Active Record reflections

Learning Rails 3

Update: I have since been able to review the first edition (with complete content).

The Rails 3 framework has brought quite a lot of new, sexy features which in turn has prompted many people to learn to use the framework. But where should you start? Luckily, there are many great resources dedicated to Rails newbies, and below, I’ll compare two of them: Agile Web Development with Rails (AWD) and Rails 3 in Action (R3A). (If you just want to dip your toes in the Rails flavored water without investing in a guidebook, check out the Ruby on Rails tutorial, which is available online at no cost.) Continue reading

Posted in Rails | Comments Off on Learning Rails 3

Impostor syndrome and BOMTYCC problems

This post will be my attempt at describing how I keep on pushing myself to improve my skills and go beyond performance plateaus, despite struggling with impostor syndrome. Continue reading

Posted in Uncategorized | Comments Off on Impostor syndrome and BOMTYCC problems

Data wrangling and Ruby metaprogramming

I needed to combine customer data from 2 separate sources (a homebrew warehouse and CRM) and output a report. Given I’d be dealing with similar objects with overlapping attributes, it would be really easy to make a gigantic mess with duplicated code everywhere. Instead, we’ll see how Ruby’s metaprogramming capabilities come to the rescue to help us write DRY code. Continue reading

Posted in Automation, Ruby, SugarCRM Ruby gem | Comments Off on Data wrangling and Ruby metaprogramming