our blog

The Highgroove blog. Sit pit-side with us to learn how we work. Sometimes technical, sometimes business-oriented, but always focused on simple solutions.

Posts tagged with Ruby

You are browsing posts about Ruby. Check out all posts on our blog.

Pry Logo

Highgroove really likes Pry. It's a great tool for digging into your code and seeing what's going on with tons of great features. However, there are situations where using a standard binding.pry breakpoint will not block your program and allow you to inspect it. I recently ran into this situation when trying to debug an application that used Foreman to manage it's processes. Luckily, the pry-remote project turned out to be a great solution.

→ Read More

The latest version of Ruby comes standard now with Comma Separated Value support built right in via the CSV library written by one of our very own alumni, James Edward Gray II. You might know CSV as the extremely portable format file used for everything from Excel Documents, to Numbers Spreadsheets, to lists of emails, to even generic data files. The CSV library is quite generic and useful by itself, but sometimes, you really need the expanded capabilities that only an Excel or Numbers document can support. Read on to find out how to generate Excel and Numbers compatible .xlsx files with Ruby.

→ Read More

Tools on pegboard 2012-04-03 09.26.50

At Highgroove we really like testing and are constantly looking for ways to improve our testing process, how quickly our tests run, and how exactly we execute our tests. How often during your Test Driven Development (TDD) cycle do your tests fail "mysteriously"? You've written your tests, written your code, and most of them pass but one or two stubbornly fail even though you are fairly certain they should pass given the testing setup you've provided? At Highgroove we bias towards action so we are likely to launch a debugger session or a pry session to get to the bottom of this. Another approach, which won't break your existing TDD workflow, is to use your test-suite in place of a more traditional debugger. After the jump we'll talk about how we've been using this strategy to dig into code quickly and easily.

→ Read More

I don't always write database-bound tests, but when I do, I prefer them
to be idempotent.

Database-bound tests are a drag. Inconsistent tests are a pain. Database-bound, inconsistently failing tests are the worst!

The following commit message is from a real code base:

Run in transactions by default.

When we added controller specs they weren't being run w/any kind of DB cleaner b/c there was no default strategy and they weren't explicitly included in a group. Now, we use :transactions be default, setting request specs to use :truncation

Also, I saw a 2 second speed up from this change!

Let's look at what we changed in this commit to turn our inconsistently failing database-bound tests into slightly faster, consistent, database-bound tests.

→ Read More

by mike

vim-vroom

Published April 03, 2012 in Ruby Open Source Testing Technical What We Wrote

Vim logo

I started watching Gary Bernhardt's Destroy All Software screencasts recently and after watching a specific episode, I had to have his Ruby testing setup. After sitting in Vim config for a while, with some improvements I made, I started feeling like I should somehow contribute my changes back. After I started adding a few more changes suggested by fellow Taconaut Steven Harman, I decided it really needed to be a Vim Plugin.

→ Read More

by brian

Writing Readable Ruby

Published February 28, 2012 in Ruby Ruby on Rails Keeping it Simple Code

See below for how to avoid this

Ruby inherits the philosophy of "there's more than one way to do it," or TMTOWTDI, from Perl. Of course, TMTOWTDI is worthless unless at least a handful of those ways can be written clearly not just for the author, but (perhaps more importantly) for future readers and editors. So, how do you make the best use of the many ways Ruby and Rails allow you to do things?

→ Read More

by stafford

Mailcatcher: Making email testing a breeze

Published February 09, 2012 in Ruby Open Source Testing Awesome

Mailcatcher Logo One of my least favorite chores as a developer is dealing with email. I’m not talking about my inbox. That is a post for another day ;). I’m talking about emails sent by web applications. Whether it is a sign up confirmation email, a receipt from a purchase, or reminder for your dog’s birthday. Chances are, if you have a web application, it sends email.

Traditionally, my workflow for testing these emails has not been very elegant or even efficient. It would either involve creating a bunch of users with different emails accounts I own, or telling the back-end to send all emails to my email address. While both of these work to some extent, the former is very time consuming and the later isn’t really testing the system the way it is meant to be used.

Mailcatcher one-ups both of these methods big time. Mailcatcher provides you with a local SMTP server for you to send your emails to in your development environment. Mailcatcher also provides you with a webmail interface to view all the emails your system has sent.

→ Read More

Tools

It's easy to say "We're agile" and "We use Behavior/Test Driven Development" and thus "we use the right tools to empower our developers!" but what are those tools? For me that discussion is entirely about the tool stack you choose, how that stack empowers you as a developer to do things right the first time. Luckily thanks to the ruby community as a whole we have a large number of high-quality choice to choose between.

→ Read More

I've often felt like Ruby Regexp captures are a bit clumsy.

Let's say we need to break apart phone numbers:

After executing this match, we might do something like this with the parsed number:

What's up with the dollar signs and the sequential numbers?

I feel like I'm writing assembly code and referring to registers or memory offsets or something.

If I'm a new Ruby programmer reading this code, I might have no idea what is going on here.

We can do better → Read More

In case you missed it, the awesome Globay Day of Coderetreat occurred on December 3rd. The amount of fun I experienced was unexpected and impressive! I learned some things too. Read on to find out what.

(Also, don't worry if you missed the code retreat, sad kitten has some good news for you at the end of this post.)

→ Read More

by andy

Fake It

Published December 06, 2011 in Ruby Code Testing

Place Kitten

One of the more complicated Ruby/Rails projects we work with at Highgroove has many points where it interacts directly with the filesystem.

Writing tests for an application whose code requires reading from or writing to the filesystem presents challenges, especially if done naively.

While it's tempting to simply use the real filesystem during unit tests, this presents a few problems:

  • The tests may be brittle, breaking on systems that are not setup just like the initial developer's local environment.
  • Setting up fixtures on the real filesystem may not be plausible; for instance, if the code interacts with system files (such as in the example coming below!).
  • Test code must be careful to clean up afterwards, even in error cases. Otherwise, the file system could be left polluted, dirtying the developer's machine and possibly breaking tests on the next run.
  • Tests running in parallel may interact with one another, causing random failures (e.g., on a continuous integration server or with parallel_tests).
  • The filesystem is slow; when attempting to make unit tests as fast as possible, the time to write, sync, and/or read from the filesystem may become significant.

So what's the solution? Fake the filesystem during unit tests.

More after the break.

→ Read More

Classify ALL the data!

Cluster analysis methods have been gaining popularity as a way of Relating pieces of data in large datasets with one another. Examples in social networking are obvious: friends on Facebook cluster into cliques and communities, which cluster into even larger groups. Demographics and other marketing research can also be aided by sorting prospective customers into groups based on preference.

→ Read More

by jonathan

Debugging Best Practices

Published November 16, 2011 in Ruby Ruby on Rails Keeping it Simple Awesome

At rubyhoedown, the inimitable Jim Weirich gave an awesome presentation on using the debugger in ruby. Before his new found respect for the ruby debugger, Jim told us that puts statements worked just fine for him.

And this is true. You can get by with puts. But, you can get by much faster using the debugger. Read on to find out when to use the debugger and how.

→ Read More

by vanstee

Map Reduce Jobs in Ruby with Wukong

Published October 25, 2011 in Ruby Open Source Code

Hadoop + Ruby

I recently got to work on some really interesting, big data problems at Highgroove. One of our clients needed to record every api call and analyze specific time periods for averages and usage metrics. Hadoop fits this use case pretty well with a distributed file system and map reduce framework built in. But, I'll be honest, I wasn't too happy about having to write map reduce jobs in Java. While looking for alternatives I found Wukong; a gem that adds a Ruby wrapper around the Hadoop Streaming utility. Here's an example of how easy it makes writing map reduce jobs.

→ Read More

by david

The Community is the Documentation, so are Highgroovers

Published September 27, 2011 in Ruby

Before getting the opportunity to work with the Highgroove team I spent considerable time checking out their website. It might have been embarrassing if it didn't have such a fun vibe to it. The picture on the front page of folks energetically making coffee certainly drew me to the site as much as having a good friend happily working there already. It definitely did not hurt that there was a Velociraptor craftily hidden behind the classic Konami code either. During my interviews I couldn't help but almost sound fanboy-ish in describing my own coffee-dorkdom and mentioning that I had read the blog and bios often during the preceding weeks. I did so just to get a feel for the team with and for whom I hoped to be working. What I didn't realize at the time was the breadth and depth of the knowledge base the crew has, and it is stunning!

Early in my tenure at Highgroove someone offhandedly said "the community is the documentation" and proceeded to comment that this why participation in (not just attendance of) conferences, Ruby User Groups, and hackfests is so critical to being a successful ruby developer. This proves itself to be more and more true the more I learn about Ruby.

→ Read More

Related Tags: