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: June 2011

Pivotal Labs

NY Standup 6/15/2011: Time keeps on slippin’ into the future.

Pivotal Labs
Wednesday, June 15, 2011

Interesting Things

  • According to Newlee, a the name of a polymorphic belongs_to can’t end in a digit. That is, you can’t say,

    belongs_to :johnny_5, polymorphic: true
    

    without some very strange errors from Rails.

  • Chronic is a seriously awesome natural-language date/time parser for Ruby. If you’re on Ruby 1.9 and have been missing it, today’s a day to celebrate! Chronic is now fully Ruby 1.9 compatible.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joseph Palermo

SF Standup 06/14/2011: Case Sensitive File System

Joseph Palermo
Tuesday, June 14, 2011

Ask for Help

“Why do NULL values get inserted as strings when using mysql LOAD DATA INFILE after dumping the data with mysql -e”

Unfortunately this team only has control over the import, not the existing export. Their only option found was to replace occurrences of NULL with N after getting the import file.

Interesting Things

A team again reminds us to be aware that the default file system in OSX is case insensitive. They thought this was the reason git would not commit a lowercase file rename for them. However, this setting was later found for your .git/config file.

[core]
ignorecase = false
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Android Tidbits 6/13/2011: Great Expectations

Joe Moore
Tuesday, June 14, 2011

Great Expectations

Most of our Android projects are using great-expectations, which brings Jasmine-style test assertions. Thanks, Xian, for writing this!

Robolectric Enhancements — Stay Tuned

We have a bunch of Robolectric enhancements, including the ability to wire up BroadcastReceivers by just declaring them in AndroidManifest.xml. We’ll have to put some pull-requests together soon.

Roboguice uses Robolectric!

We use Roboguice on most of our Android projects for dependency injection. We discovered that Roboguice is using Robolectric for unit testing. Awesome!

Roboguice using Robolectric

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Edward Hieatt

What’s Your Start-up’s "Bus Count"?

Edward Hieatt
Monday, June 13, 2011

Tim Ferriss (author of “The 4-Hour Workweek” and lots more) recently posted an interview with Pivotal’s CEO Rob Mee on his blog titled “What’s Your Start-up’s Bus Count? Seven Myths of Entrepreneurship and Programming”. It’s a great read on how Pivotal Labs thinks about building fast, scalable software development teams and how commonly held beliefs are often counterproductive. Thanks for the post, Tim!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ryan Dy

SF Standup 06/13/2011: Ackmate and UTF8

Ryan Dy
Monday, June 13, 2011

Ask for Help

Interesting Things

  • If you are having trouble with find and files with textmate or ackmate you might want to add an exlcusion for “solrdata” in textmate folder references exclusion list. Apparently this is fixed in an undocumented version of ackmate on github.
  • Peter Cooper and Jason Siefer have a new Javascript podcast, subscribe today!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Tyler Schultz

Android: Unit testing custom views

Tyler Schultz
Saturday, June 11, 2011

Android Activity classes can become gigantic and unwieldy if you’re not careful. Testing complex Activities requires complex setup. To reduce that pain we try our best to keep the Activity lean. This means getting logic out of the Activity. One technique we use is to create custom views that we can test in isolation.

Here is an example of a view class that starts out with a ProgressBar spinner, and when the text is set, the spinner is hidden, and the text becomes visible:

public class LoadingTextView extends RelativeLayout {
    ...
    public void stopLoadingAndSetText(int text_res_id) {
        TextView textView = (TextView) findViewById(loading_text_text_view);
        textView.setText(text_res_id);
        textView.setVisibility(VISIBLE);

        findViewById(loading_text_spinner).setVisibility(View.GONE);
    }
}

Here is the layout xml that is associated with the custom view class. Notice the reference to the LoadingTextView class in the outermost tag (which has lost its formatting!!!):

<?xml version="1.0" encoding="utf-8"?>

<com.pivotallabs.views.loadingtextview android:layout_height="wrap_content" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">

    <linearlayout android:gravity="center" android:padding="10dip" android:orientation="horizontal" android:layout_height="wrap_content" android:id="@+id/loading_text_spinner" android:layout_width="fill_parent">
        <progressbar android:layout_height="wrap_content" android:layout_width="wrap_content" />
        <textview android:paddingLeft="10dip" android:text="Loading..." android:layout_height="wrap_content" android:layout_width="wrap_content" />
    </linearlayout>

    <textview android:visibility="invisible" android:layout_height="wrap_content" android:id="@+id/loading_text_text_view" android:layout_width="fill_parent" />

</com.pivotallabs.views.loadingtextview>

Robolectric will allow you to instantiate the Android subclasses in the JVM, but the problem is that newing the custom view class will not inflate the elements the view class expects to be present. To get around this you can take advantage of Robolectric’s simulated view inflating functionality. Use the LayoutInflator.from() method to get an inflator which can be used to inflate your view:

@RunWith(RobolectricTestRunner.class)
public class LoadingTextViewTest {
    private LoadingTextView loadingTextView;
    private View loadingSpinner;
    private TextView loadingTextTextView;

    @Before
    public void setUp() throws Exception {
        loadingTextView = (LoadingTextView) LayoutInflater.from(new Activity()).inflate(R.layout.loading_text, null);
        loadingSpinner = loadingTextView.findViewById(R.id.loading_text_spinner);
        loadingTextTextView = (TextView) loadingTextView.findViewById(R.id.loading_text_text_view);
    }

    @Test
    public void testStopLoadingAndSetTextShouldHideTheSpinnerAndShowTheTextView() throws Exception {
        assertThat(loadingSpinner.getVisibility(), equalTo(View.VISIBLE));
        assertThat(loadingTextTextView.getVisibility(), equalTo(View.INVISIBLE));

        loadingTextView.stopLoadingAndSetText(R.string.unit_tests_ftw);

        assertThat(loadingSpinner.getVisibility(), equalTo(View.GONE));
        assertThat(loadingTextTextView.getVisibility(), equalTo(View.VISIBLE));
    }

    @Test
    public void testStopLoadingAndSEtTextShouldSetTheTextOnTheTextView() {
        loadingTextView.stopLoadingAndSetText(R.string.unit_tests_ftw);

        assertThat((String) loadingTextTextView.getText(), equalTo("Unit Tests FTW!!!"));
    }
}

You can run these example tests yourself by checking out the RobolectricSample project on github.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Danny Burkes

Making WebMock, Selenium, and WebDriver Play Nicely

Danny Burkes
Friday, June 10, 2011

Update

Since this article was written, version 1.7.0 of WebMock has been released, which includes WebMock.disable! functionality, as well as fixes the problem with selenium-webdriver. So please use that, instead of webmock-disabler.

The Problem

Recently, one of my projects ran into a problem where our integration tests would intermittently fail with weird timeout errors and complaints about page elements that couldn’t be found.

A little googling revealed that we weren’t the only ones having this problem.

Apparently, WebMock, Selenium, and WebDriver don’t play nicely together, even if you tell WebMock to allow the outgoing connections necessary to drive the browser.

Some Gemfile hacking revealed that it was the mere presence of WebMock that caused the error. If we removed WebMock from our Gemfile, our integration tests ran fine, but then of course all of our tests that actually needed WebMock failed.

At that point, we could have decided to run our integration tests separately from the rest of the tests, but we really liked the idea of having all the tests run in the same VM, to avoid the duplicate VM startup time.

What we really needed was a way to turn WebMock on and off selectively for different types of tests.

The Solution

With some gnarly monkey patching and offensive use of alias_method, I have created webmock-disabler, a gem which provides new WebMock.disable! and WebMock.enable! methods. You can use these methods in individual tests, or on classes of tests as shown in the README.

The Result

We’re now able to run our tests that need WebMock in the same VM as those that would otherwise break if we didn’t do WebMock.disable!.

Celebration time!

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

NY Standup 6/10/2011: Action-packed gemsets!

Pivotal Labs
Friday, June 10, 2011

Interesting Things

  • Reputedly, the webserver G-WAN offers you 2x the speed of nginx for delivering static files.

  • Case Commons and the Casebook team is proud to announce (an early version of) ActiveTable. In the spirit of ActiveHash, ActiveTable lets you store enumeration-style data in your source code and access it with an ActiveRecord-like interface. ActiveTable, however, uses temporary tables to store the data in each database connection, allowing you to use it in SQL queries and joins. Props go to Todd Persen for making it happen.

Events

  • Today is Walkabout NYC, a city-wide tech startup open house. It’s part of this year’s Internet Week NY. From 12pm to 6pm tech shops throughout NYC will open their doors to visitors who want to see how it all works. Pivotal’s participating, so stop by and see how we do what we do!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Gregg Van Hove

Standup 6/10/2011: scp’s magical tab completion

Gregg Van Hove
Friday, June 10, 2011

Ask for help

  • Some pivots on an Android project were trying to remember if there was any way to turn of overscroll glow in lists.

Interesting Things

  • DevOps Days is coming up on June 17 & 18. They appeared to be sold out before, but are now inviting people off the waiting list, so if you want to go sign up.

  • When using scp to get files from a remote machine, it actually uses ssh to get into the machine to do tab completion of the remote filesystem.

  • When running specs through rake, FactoryGirl factories are evaluated before fixture data is loaded, which is the opposite of what happens when running directly with spec. This manifests itself with really broken factories if they need to load fixture data but do it too early.

All this means is, don’t write your factories like this:

Factory.define :foo do |f|
  f.bar Bar.find_by_number(100)
end

Write them using the lambda syntax like this:

Factory.define :foo do |f|
  f.bar { Bar.find_by_number(100) }
end
  • Some pivots were noticing what seemed to be strange behavior when using the ‘and’ keyword in ruby, because it has the lowest precedence in the language.

Some demonstrations:

> def foo1
>   puts 'foo' and false
> end

> a = foo1
foo
 => nil
> a
 => nil

If you try to wrap the 'foo' and false in parentheses, be careful of your spacing:

> def foo2
>   puts ('foo' and false)
> end

> b = foo2
foo
 => nil
> b
 => nil

> puts('foo' and false)
SyntaxError: compile error
(irb) syntax error, unexpected kAND, expecting ')'
puts('foo' and false)
           ^

Using && is a little more predictable

> puts 'foo' && false
false
 => nil

Or the difference when assigning not just printing:

> x = 'foo' and false
 => false
> x
 => 'foo'
> y = 'foo' && false
 => false
> y
 => false
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Android Tidbits 6/9/2011: CD2M Resources

Joe Moore
Friday, June 10, 2011

C2DM

One of our projects just started implementing the Android Cloud to Device Messaging (C2DM) framework. We’ll keep you posted as we progress through the many pieces of this implementation. Various resources include:

  • Official Google code page: Google Projects for Android: C2DM
  • Sign up for the service — you’ll need a Google account, like GMail or a hosted Google account.
  • There is no official Android client library for handling these messages. There is a de-facto standard set of classes, as used in JumpNote and Google Chrome to Phone Extension. Most blog and forum posts say something like “Download those classes and tweak as needed.”
  • Wei Huang from Google posted an article about implementing C2DM.
  • Now for the Ruby part — wait, Ruby? Yes, there is a big server-side component to C2DM. Your message-pushing server must not obtain an authorization token from Google to communicate with the service, but also keep track of the authorization tokens from each device that needs to receive push notifications. We are implementing a server-side API for our devices to register their C2DM tokens. Also, the awesome folks at GroupMe have open sourced a c2dm gem for Ruby servers to both authorize with Google and post notifications.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (780)
  • 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 (20)
  • cucumber (20)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (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 >