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
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: May 2011

David Stevenson

Standup 5/12/2011: Is it easy to patch a gem's dependencies to upgrade a version?

David Stevenson
Thursday, May 12, 2011

Ask for Help

“Rubymine is excluding code in our gem’s spec/ directory from being indexed, can that be changed?”

We assume this is an optimization, because most people aren’t interested in anything from a gem except the lib/ directory. There doesn’t appear to be a way to change this behavior.

“How can I override the gem version requirements on annoying gems in my project?”

We’re trying to bring in rails 2.3.2 + rack 1.1.x, but rails explicitly requires the old version of the rack gem. Can we do something sneaky to change the requirements without forking and modifying the gem??

“Is there a good set of practices for exposing ActiveRecord models to JavaScript?”

Like using Backbone.js model support? Or maybe just straight #to_json on models and embedding them into HTML templates?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

RubyGems Warningitis Outbreak

Alex Chaffee
Thursday, May 12, 2011

Have you upgraded RubyGems lately? Is your console suddenly filled with warnings like this?

NOTE: Gem::Specification#default_executable= is deprecated with no replacement. It will be removed on or after 2011-10-01.
Gem::Specification#default_executable= called from /Users/chaffee/.rvm/gems/ruby-1.9.2-p0/specifications/thin-1.2.7.gemspec:10.

You may be showing signs of a new malady known as Warningitis! So far there is no cure, but doing the following will temporarily cure your symptoms:

gem update --system 1.7.2

Several experimental treatments are being hastily developed as well, but these have not yet been approved by the FDA. Check the “scary warnings are scary” bug thread for more details.

This has been a public health alert. Please do not panic. SARS masks and iodine pills are not recommended at this time.

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

NY Standup 5/12/2011: It's class reloading.

Pivotal Labs
Thursday, May 12, 2011

Ask for Help

“A file is being loaded twice by Rails, and I’m not sure why. How do I figure out what’s reloading it?”

Try putting this at the top of the file:

puts caller
puts "-" * 80

#caller is a Kernel method which returns the backtrace at the time it’s called as an array of strings. Every time the file is loaded, you’ll see the backtrace of what loaded it. The second line makes a separator so you can see the break between stacktraces.

“Is there a command that will make a new file in a path of directories that don’t exist yet? Like mkdir -p but for files? Maybe touch -p?”

No. No one knows why.

Interesting Things

  • Chrome Tab Overview: Chrome can now show you an overview of all tabs in a window like Exposé does for windows. It’s an experimental feature. To enable it, go to , enable “Tab Overview”, and restart Chrome. Then three-finger swipe down to see all your tabs.

    Your humble reporter reminds the reader that Camino pioneered the “Tabspose” feature in 2007.

  • ERROR: current transaction is aborted: On Postgres, sometimes RSpec will show the error “ERROR: current transaction is aborted, commands ignored until end of transaction block.” The backtrace of this error is not useful, because it’s the backtrace of the first operation to use the database connection after some error occurred. These errors are tricky to debug.

    The people who hit it had luck with temporarily turning off use_transactional_examples in the RSpec config, which let them see the error. Just remember to turn it back on, because transactions keep your tests clean and fast. (Note: use_transactional_examples and use_transactional_fixtures are synonymous.)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mike Gehard

Using Jasmine to test CoffeeScript in a Rails 3.1 App

Mike Gehard
Wednesday, May 11, 2011

Lately I’ve had the opportunity to use Jasmine to test drive a whole bunch of Javascript and am loving it. If you haven’t had a chance to take Jasmine for a spin, I recommend you take some time to do so.

When I heard that Rails 3.1 was going to include CoffeeScript I decided to work to figure out how I could write both my production code as well as my specs in Coffeescript.

Using this gist as a guide, I came up with these detailed instructions:

Add Guard and Guard-Coffeescript to your Gemfile and run bundle.

Run guard init to create a Guardfile and edit it to contain the following:

guard 'coffeescript', :output => 'public/javascripts/compiled' do
  watch(/^app/assets/javascripts/(.*).coffee/)
end

guard 'coffeescript', :output => 'spec/javascripts/compiled' do
  watch(/^spec/javascripts/(.*).coffee/)
end

Edit your spec/javascripts/support/jasmine.yml to have at least the following entries:

src_dir: public/javascripts/compiled
src_files:
  - **/*.js

spec_dir: spec/javascripts/compiled
spec_files:
  - **/*_spec.js

Start up the Jasmine server using rake jasmine and point your browser to http://localhost:8888. You should see 0 specs, 0 failures. Since you have changed the location that Jasmine looks for spec files, you aren’t picking up the example Jasmine specs any longer.

Create a new spec file in spec/javascripts/math_spec.coffee with the following contents:

describe 'Math:', ->
  describe 'fib()', ->
    it 'should calculate the numbers correctly up to fib(16)', ->
      fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]
      expect(Math.fib(i)).toEqual fib[i] for i in [0..16]

Refresh your browser, you should see one failing spec. Guard has compiled your .coffee file into a .js file that Jasmine will use.

Create a new implementation file in app/assets/javascripts/math.coffee with the following contents:

Math.fib = (n) ->
    s = 0
    return s if n == 0
    if n == 1
      s += 1
    else
      Math.fib(n - 1) + Math.fib(n - 2)

Refresh your Jasmine browser window and you should see 1 passing spec. Again, Guard has compiled your implementation file and Jasmine uses it to satisfy the spec.

At some point, it would be nice to figure out a way to run Jasmine specs directly from the .coffee files and against the implementation .coffee files without having to use Guard to compile them. With the above steps, you still have to check in the compiled files into source control so your tests can be run in the CI environment. If you miss one of the compiled specs or one of the compiled implementation files, your CI environment may report improper results.

If anyone has any ideas, I’d love to hear them.

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

NY Standup 5/11/2011: Chrome Frame for all my subjects!

Pivotal Labs
Wednesday, May 11, 2011

Ask for Help

“How can we expect in Jasmine that a jQuery dialog has closed?”

The dialog animates out (asynchronously, of course), and it’s hard to have a test pass when it successfully disappears.

“In Javascript, How can we create an array of n empty arrays?”

One attempt, (new Array(n)).map(function() { return [] }) failed, because new Array(n) creates an array, n elements long, full of undefined. As it turns out, map() skips undefined in an array.

[Correction: new Array(n) creates an array which says its length is n, but which doesn't have any elements, not even undefined. The following does map over the undefined elements (for n=3), but isn't very useful to us.

[undefined, undefined, undefined].map(function() { return [] })

Thanks to John Pignata for pointing that out.]

Interesting Things

  • The latest version of Chrome Frame for Internet Explorer doesn't require admin rights to install.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ryan Richard

Standup 5/11/2011

Ryan Richard
Wednesday, May 11, 2011

Ask for Help

“How can you resize the browser window from a Capybara test before visiting the page under test?”

Interesting Things

Tommy had a suggestion for testing scopes in Rails controller tests.

Here is an example of the type of test that he does not enjoy writing:

<code>
it "scopes products to active and available" do
    not_active = Factory(:product, :active => false)
    not_available = Factory(:product, :available => false)
    active_available = Factory(:product, :active => true, :available => true)
    get :index
    assigns(:products).should_not include(not_active)
    assigns(:products).should_not include(not_available)
    assigns(:products).should include(active_available)
end
</code>

Here is a nice way that he found to write the same test:

<code>
it "scopes products to active and available" do
    get :index
    assigns(:products).should == assigns(:products).active
    assigns(:products).should == assigns(:products).available
end
</code>

The only question is what to do with pagination? A work-around is for the controller to do:

<code>
def index
  @products_scope = Product.active.available
  @products = @products_scope.paginate(:per_page => blah blah blah)
end
</code>
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Dan Podsedly

New in Pivotal Tracker: Story tasks now draggable, enabled by default

Dan Podsedly
Wednesday, May 11, 2011

We’ve made a few improvements to how story tasks work in Pivotal Tracker. They’re now turned on by default for all new projects, they can be added to a new story before it’s saved, and you can drag them to rearrange their order.

If you haven’t used story tasks before, they allow you to maintain a checklist of all of the specific things that need to be done before a given story can be considered finished. Typically, these are technical tasks, for example, a feature like “As a user, I can reset my password, so I can get back into the application” might break down to tasks along the lines of “Create new password reset controller”, “Add reset password link to signin page”, “Write functional test for resetting password”, etc.

To enable tasks for your existing project, go to Project Settings, and click the ‘Enable Tasks’ checkbox near the top of the page.

Once enabled, you can create tasks for a story by typing into the ‘add task’ field, and hitting enter. Drag a task to move it to a different position in the task list, click the checkbox next to it to mark it as complete, and hover over a task to edit or delete it (you’ll see an edit and delete button to the right of the task when hovering over it).

Stories that have tasks will now show a balloon icon next to the story title when collapsed, indicating that there is some more info available.

We have many more usability improvements and new features coming. To stay up to date, keep an eye on this blog, or follow @pivotaltracker on Twitter!

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

NYC Standup 5/10/2011

Pivotal Labs
Tuesday, May 10, 2011

Ask for Help

“Why does RubyGems 1.8.1 say ‘No method “basename” for #’ when running Spork?”

It looks like RubyGems thinks that somethings a Pathname when it’s actually a String. That’s weird, since it seems to be entirely inside RubyGems’ own code. It might have something to do with all the changes happening in RubyGems. The team’s downgraded to 1.7.2 and the problem went away.

Interestingly, 1.7.2 is the version currently listed on RubyGems.org. 1.8.1, however, is what gem update --system installs.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Stevenson

Standup 5/10/2011: How safe are you videos over RTMP?

David Stevenson
Tuesday, May 10, 2011

Ask for Help

“Is flash RTMP streaming a secure way to stream video so it can’t be downloaded?”

We’re using this with CloudFront + S3. But will it protect our content enough?

“RubyMine + rspec 2.6, why won’t my focused tests run?”

We hoped this could be easily fixable by detaching the rspec gems and reattching them, but no luck with our usual fixes.

“MixPanel, is it a good tool for analytics and log analysis? “

Compared to normal analyics tools or splunk for log analysis?

“Anyone ever stubbed out 3rd party calls to a Thrift RPC service before?”

Is there a better solution than some sort of standard generic ruby stubbing & expectation tool?

Interesting Things

  • Postgres is giving us some weird behavior on Heroku when we have column names longer than 27 characters. We think the update_attribute calls are not being persisted but no errors are generated.
  • There are finally some viruses/trojans for mac OSX that are gaining traction. Careful what you download!
  • The net-ssh-telnet gem makes running a scripted batch SSH session pretty easy. This might be a good tool for you, if you want something much less complicated than capistrano or chef server for remote automation.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Using git bisect to find where something broke

Pivotal Labs
Monday, May 9, 2011

We recently had an issue where our CI build broke over the weekend.

We used git bisect to figure out where the problem occurred.

We wrote a cucumber feature (feature/path/to/is_it_fixed.feature) that worked on Friday and fails today.

We start by setting up git bisect:

git bisect GOOD BAD

Where GOOD is the git SHA from last Friday and BAD is this morning’s SHA.

Then we created a shell script that will setup the environment and run the feature:

#!/bin/bash
set -e

git checkout .
rake db:drop
rake db:create
rake db:migrate
rake db:test:prepare
cucumber feature/path/to/is_it_fixed.feature:20 -r features

We then run this command with the following:

git bisect run /path/to/shell/script.sh

This will then automatically keep running until it finds the SHA that breaks that feature. At the end of the run, it helpfully prints “SHA __ caused the issue”.

Very cool.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (781)
  • rails (113)
  • testing (88)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (55)
  • techtalk (44)
  • rspec (38)
  • ironblogger (32)
  • productivity (30)
  • activerecord (29)
  • gogaruco (29)
  • git (28)
  • nyc (27)
  • rubymine (26)
  • bloggerdome (23)
  • mobile (22)
  • process (21)
  • pivotal tracker (21)
  • cucumber (20)
  • design (19)
  • jasmine (19)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • tracker ecosystem (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • css (13)
  • tdd (13)
  • selenium (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to Community Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. 5
  7. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • 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 >