Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Tools
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: June 2011

Matthew Kocher

Guiderails: our Rails 3 templates

Matthew Kocher
Monday, June 6, 2011

One of our goals for the first day a project starts at Pivotal is to deliver something the customer can see working. One of the ways we accomplish this is making sure getting up and running with all of our (more) reasonable defaults only takes a few minutes. We’ve been using guiderails for this internally for a while now, and soft launched it last week. I’m happy to give a full introduction today.

Currently Guiderails supports choosing:

  • Mysql or Postgres
  • RR or Mocha
  • Webrat with Saucelabs support
  • Cucumber with Capybara (no suacelabs support)
  • SASS (with HAML)

And includes by default:

  • A ci_build.sh script for running your project in CI.
  • A local git repo
  • An rvmrc
  • Bundler, auto-tagger, JSON, Heroku, rspec-rails, Jasmine, and Headless gems (in the global or development groups)
  • Jasmine initialized for JavaScript testing
  • Respec installed
  • Some testing related rake tasks

For more details, check it out on github at https://github.com/pivotal/guiderails.

Guiderails is a great way to get going quickly on a project. Many thanks to the Pivots that contributed.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dan Podsedly

New in Pivotal Tracker: Stay signed in across browsers, all-HTTPS, 3rd party tools RSS feed

Dan Podsedly
Monday, June 6, 2011

As we blogged about last week, all pages in Tracker that require you to sign in are now served exclusively over secure HTTPS.

As part of this update, we’ve also improved how “remembered” sessions work. Select the remember me checkbox on the signin page, and you’ll stay signed in for two weeks in that browser. This now works across multiple browsers .To clear all of your remembered sessions, just sign out anywhere, and resetting your password will clear all remembered sessions as well.

We’ve also made it easier to keep with all of the latest and greatest 3rd party tools and add-ons for Tracker, with a new RSS feed. Follow this link to add the feed to your feed reader, or click the RSS link at the top of the 3rd party tools page.

If you haven’t been there recently, there are now around 80 third party tools listed, including the popular TrackerBot, an iPad/iPhone client for Tracker, Pivotal Tracker Analytics, an on-demand business intelligence application from GoodData, the Pivotal Tracker Story Board, a Chrome extension that shows your current iteration as a card wall, and many others!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Testing your gem against multiple rubies and rails versions with RVM

Pivotal Labs
Sunday, June 5, 2011

I recently wanted to make it easier for contributors to ActiveHash to test their changes against multiple versions of Rails, with multiple versions of Ruby. My stories looked like this:

As a contributor
I want to be able to run `bundle install`, then quickly run the suite spec suite against the latest released version of rails
So that I can develop quickly using a familiar workflow

As a gem maintainer
I want to be able to run the spec suite against 3 different versions of ruby, each with 5 different versions of rails
So that I can release the gem with confidence that I'm not going to break people's apps

In this post I’ll explain how I did that with a (relatively) simple shell script.

The final script looks like this:

#!/bin/sh

set -e

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
  source "/usr/local/rvm/scripts/rvm"
else
  printf "ERROR: An RVM installation was not found.n"
fi

function run {
  gem list --local bundler | grep bundler || gem install bundler --no-ri --no-rdoc

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.2...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.2 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.5...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.5 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.11...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.11 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against the latest released version of activesupport / activerecord...'
  ACTIVE_HASH_ACTIVERECORD_VERSION="" bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against edge activesupport / activerecord...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=edge bundle update activerecord activesupport
  bundle exec rspec spec
}

rvm use ruby-1.8.7@active_hash --create
run

rvm use ree-1.8.7@active_hash --create
run

rvm use ruby-1.9.2@active_hash --create
run

echo 'Success!'

Here’s a breakdown of what’s happening:

First the script tells the shell to exit immediately if any of the commands in the script fail:

set -e

This is helpful for continuous integration servers especially, so they fail fast. Next, the script loads RVM, looking first in the home directory, then for a system install:

if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
  source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
  source "/usr/local/rvm/scripts/rvm"
else
  printf "ERROR: An RVM installation was not found.n"
fi

The next section defines a function which, when invoked, runs the spec suite against 5 different versions of activerecord/activesupport:

function run {
  gem list --local bundler | grep bundler || gem install bundler --no-ri --no-rdoc

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.2...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.2 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.5...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.5 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against activesupport / activerecord 2.3.11...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=2.3.11 bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against the latest released version of activesupport / activerecord...'
  ACTIVE_HASH_ACTIVERECORD_VERSION="" bundle update activerecord
  bundle exec rspec spec

  echo 'Running bundle exec rspec spec against edge activesupport / activerecord...'
  ACTIVE_HASH_ACTIVERECORD_VERSION=edge bundle update activerecord activesupport
  bundle exec rspec spec
}

(I know, it’s not particularly DRY – pulling out the duplication into other functions is an exercise for the reader…)

This function sets an environment variable to describe the intended gem versions, then updates bundler and runs the suite. To make this work, I added the following to my Gemfile:

source :gemcutter
gemspec

group :development do
  activerecord_version = ENV['ACTIVE_HASH_ACTIVERECORD_VERSION']

  if activerecord_version == "edge"
    git "git://github.com/rails/rails.git" do
      gem "activerecord"
      gem "activesupport"
    end
  elsif activerecord_version && activerecord_version.strip != ""
    gem "activerecord", activerecord_version
  else
    gem "activerecord"
  end
  # other gems...
end

The Gemfile checks the ACTIVE_HASH_ACTIVERECORD_VERSION environment variable, and sets the correct gem version/git repo accordingly. If it gets a blank ACTIVE_HASH_ACTIVERECORD_VERSION it does not set the version in the Gemfile, so when the bash script calls bundle update activerecord it conveniently fetches the latest released version.

If you execute bundle update, it won’t have a ACTIVE_HASH_ACTIVERECORD_VERSION so it will fetch the latest, so the normal workflow still works as expected.

Finally, it runs the function in each of 3 rubies:

rvm use ruby-1.8.7@active_hash --create
run

rvm use ree-1.8.7@active_hash --create
run

rvm use ruby-1.9.2@active_hash --create
run

echo 'Success!'

RVM allows you to run a command with all of your installed rubies, but in this case I wanted to target 3 particular versions, and ensure that they work. RVM will fail if you don’t have the latest version of each ruby installed, and prompt you to install it. And since set -e was called at the top of the file, there’s no need to check the return code of any of the functions because the script will fail if any individual command fails.

If you are a gem maintainer, this is an easy way to ensure that your gem is highly compatible with standard Ruby / Rails setups.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NY Standup 6/3/2011: Reading and Rainbows

Pivotal Labs
Friday, June 3, 2011

Interesting Things

  • A more readable Solarized: Ethan Schoonover’s excellent color scheme Solarized is available for a number of applications, including iTerm 2. However, it can be hard to use in iTerm: the green looks yellow (bad for test output), the grey looks like the background (making RSpec backtraces disappear), and the selection highlight is barely visible. As Rajan points out, A fork by Wes Morgan fixes these problems. Wes also wins this week’s surprise award for best GitHub username.

  • git unpushed/unpulled: Kris wrote a couple of nice aliases to drop in your ~/.gitconfig. git unpushed shows the commits that you haven’t pushed to origin yet on your current branch. git unpulled shows the commits that are on origin’s version your current branch that you haven’t pulled down yet.

Dangerous

  • Random Rubyism: Newlee points out that assignment inside a conditional can be a funny thing. Sometimes people do this:

    if elephant = Savannah.look_for_elephant
      person.ride(elephant)
    else
      person.be_sad
    end
    

    That is, you can use assignment inside the conditional to put something in a variable and test for it existence at the same time. It’s a questionable practice, since it’s easy to mix up = and ==. Newlee, never one to give up easily, wanted to see just how questionable he could make it. What happens if you do this?

    person.ride(elephant) if elephant = Savannah.look_for_elephant
    

    If Savannah.look_for_elephant is truthy, you might get:

    NameError: undefined local variable or method `elephant'
    

    because it looks for elephant before the assignment takes place. That’s if you haven’t defined elephant yet. If there’s an existing local, you’ll get its value before the assignment in the if, and if there’s no local but there’s a method elephant, you’ll call the method.

    If Savannah.look_for_elephant is falsy, though, Person#ride will never get called. This means that Ruby first determines how to evaluate the left side of the statement, then evaluates the conditional, then (if the conditional is truthy) actually evaluates the the left side according to the way it was originally parsed.

    Weird.

Other

  • This week’s surprise award for best shirt is split: congratulations to Ian “Zabes” Zabel and Lee “Newlee” Edwards!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Glen Ivey

More details on Pivotal Tracker going (almost) all SSL

Glen Ivey
Friday, June 3, 2011

As Dan blogged last Tuesday, the next release to Pivotal Tracker is going to ensure that all project pages and other pages that require logins will only be served securely (via HTTPS/SSL).

This will make Tracker more secure against session-hijacking attacks. Unfortunately, it also requires that everyone log in to Tracker again when the site comes back up after the deploy. After the release is deployed, when you leave the normal maintenance page or grey screen you’ll be automatically forwarded to the Sign In page.

API access to a Tracker project will only require the use of HTTPS if the “Use HTTPS” check box in its Project Settings page is on.

Happy Tracking!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jacob Maine

Standup 6/3/2011: Get your papers!

Jacob Maine
Friday, June 3, 2011

Interesting Things

  • The GoGaRuCo call for papers is open!
  • There’s a Yammer Drinkup on June 8th.
  • You might expect that a where clause like id IN (NULL) would return an empty result set. Interestingly id NOT IN (NULL) also returns an empty result set. Welcome to three-valued logic.
  • Be aware that tests may cast Hash to HashWithIndifferentAccess.
# controller.rb

  @list = [{'key' => 'value'}]

# controller_test.rb

  assigns(:list).first.should be_instance_of HashWithIndifferentAccess # passes
  assigns(:list).first.should be_kind_of Hash # passes
  assigns(:list).first.should be_instance_of Hash # fails

Ask for Help

  • “What are some pointers for continuously deploying to staging, and maybe production?”

At a bare minimum, you’ll want to deploy only green builds and have a basic monitoring tool like Pingdom. To get the full benefit of continuous deployment, though, you need to be more sophisticated. You’re really interested in whether your latest deploy improved key metrics like conversion, usage and happiness. That gives you information about whether your next commit should pull out that feature or keep building on it. It’s truly rapid iteration with customer feedback, but it takes a lot of charts and graphs and faith that you’re measuring the right things.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NY Standup 6/2/2011: You play with words, you play with love

Pivotal Labs
Thursday, June 2, 2011

Ask for Help

“Why is IE not using some of the styles we’ve put on our body tag?”

It might be because older versions of IE don’t properly support CSS selectors which use more than one class. Even newer IE versions retain this behavior in quirks mode (since that’s the point of quirks mode), so make sure your doctype is correct. Stack Overflow has more info.

Interesting Things

  • In Ruby, private and protected may not mean what you think they mean.

    • private methods cannot be called with an explicit receiver. This is Ruby’s way of ensuring that they are only called on self, which is the implicit receiver. This leads a surprising result: you can’t call self.a_private_method, because it has an explicit receiver. Just call a_private_method instead.

      If you’re used to Java or C#, you might be surprised to know that subclasses can call their superclasses’ private methods (and vice versa). That may seems strange, since in Java that’s called protected. But…

    • protected methods in Ruby have a very different restriction: they can only be called from objects of the same class. Your humble reporter has never encountered a use for this kind of method, but there it is.

    Of course, any method can be called on any object using #send. We’re adults after all. We can make our own smart choices.

  • Jon Berger points us to a couple of great Ruby podcasts:

    • Ruby Rogues is a roundtable discussion featuring a number of the great contributors in the community. (iTunes)

    • The Ruby Show, hosted by Peter Cooper and Jason Seifer, covers news from across the Ruby and Rails world, including the latest gems and helpful blog posts. (iTunes)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NY Standup 6/1/2011: I require more speed

Pivotal Labs
Wednesday, June 1, 2011

Interesting Things

  • require ‘performance_patch’: Ruby 1.9′s require is much slower than Ruby 1.8′s. There’s a fix targeted for Ruby 1.9.3.
  • jQuery.fx.off: A few weeks ago, someone wondered how to test jQuery dialog, since it uses animations which make dismissing it asynchronous and hard to test. The answer: set jQuery.fx.off == true. jQuery will then skip animations and skip properties synchronously to their final states.
  • Reset Content vs jQuery: When a jQuery AJAX call receives a 205 Reset Content response, it doesn’t call your success callback.
  • Rails doesn’t like join tables with attributes: When you use a join table and has_and_belongs_to_many, the join can’t hold any extra information, just the presence of an association between two records. If you need to store metadata about that association, use a join model with has_many through: instead. If you even have extra columns on a join table, Rails will now give you a deprecation warning.
  • Creating a has_one: If Person has_one :account, you can person.build_account to build a new Account for it, or person.create_account to build and save it. Likewise, if Account belongs_to :person, you can account.build_person or account.create_person.

Stretch

Austin’s routine this morning gave all our thighs and calves a good stretch. And our jeans.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jacob Maine

Standup 6/1/2011: Speedy deals

Jacob Maine
Wednesday, June 1, 2011

Interesting Things

  • Groupon Now! in San Francisco just launched. Use it to find same-day deals.
  • If you haven’t used it yet, the Rack perftools.rb project is amazingly useful for performance optimization of web apps. Add the gem, append a few params to your normal requests, and get served an image showing the call flow of your app, with lots of details about method timing and expense. We’re trying to arrange a tech talk about perftools at Pivotal SF soon.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (783)
  • rails (117)
  • testing (90)
  • ruby (86)
  • ruby on rails (71)
  • jobs (62)
  • javascript (59)
  • techtalk (44)
  • ironblogger (42)
  • rspec (39)
  • bloggerdome (34)
  • productivity (34)
  • activerecord (30)
  • rubymine (30)
  • git (29)
  • gogaruco (29)
  • nyc (27)
  • design (24)
  • mobile (23)
  • pivotal tracker (22)
  • process (21)
  • cucumber (21)
  • jasmine (19)
  • ios (18)
  • tracker ecosystem (17)
  • webos (17)
  • objective-c (17)
  • fun (16)
  • android (16)
  • palm (16)
  • ci (16)
  • "soft" ware (16)
  • bdd (15)
  • tdd (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • css (14)
  • gem (13)
  • mouse-free development (12)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • api (12)
  • keyboard (11)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
Subscribe to Community Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Tools
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >