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: October 2008

Joe Moore

Standup 10/15/2008: this_method; dynamically creating tables for testing

Joe Moore
Wednesday, October 15, 2008
  • Where am I? — Ever need to find the name of the method you are currently within? Here’s a this_method method! The magic is in the REGEX, of course.
module Kernel
  private
  def this_method
    caller[0] =~ /`([^']*)'/ and $1
  end
end
  • One project wanted to test a very ActiveRecord-specific Module in an isolated, generic way. After spending time researching techniques of mocking and stubbing the many, many ActiveRecord methods that would be touched, they decided to just dynamically create an ActiveRecord and a DB Table for it on the fly! They even used single table inheritance (STI)
  describe "MyMagicModule Mixin" do
    before(:all) do
      ActiveRecord::Base.connection.create_table "some_base_models",
                                                   :force => true do |t|
        t.string   "name"
        t.string   "type"
        t.integer  "some_model_b_id", :limit => 11
      end
    end

    after(:all) do
      ActiveRecord::Base.connection.drop_table "some_base_models"
    end


    class SomeBaseModel < ActiveRecord::Base;end

    class SomeModelA < SomeBaseModel
      include MyMagicModule

      belongs_to: :some_model_b
    end

    class SomeModelB < SomeBaseModel
      include MyMagicModule
    end

    it 'should use special belongs_to stuff from MyMagicModule' do
       model_a = SomeModelA.create!(
                        :name=> "Model A",
                        :some_model_be => SomeModelB.create!(:name => "Model B"))
       # test the functionality from MyMagicModule
    end
  end
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

Standup 10/14/2008: Database Migrations

Pivotal Labs
Tuesday, October 14, 2008

Interesting Things

  • Rake migrations check if a migrations table is in sync with migration file and it does not really check what the state of the data in database.

Ask for Help

“Can we use migrations to load static data into an application”

People usually create a separate rake task to bootstap. Mixing it with migration was not working well before.

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

NYC Stand Up 10/14 2008

Pivotal Labs
Tuesday, October 14, 2008

A developer accidentally committed to an SVN external. Switching the SVN user to have read-only access to the external.

Casebook’s ccrb + Funkytown + JsUnit build opens parallels on development boxes. The issue is probably with the Funkytown configuration.

Adam Keyes is coming in to talk to us during lunch today.

Casebook is moving to Git.

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

Agile Python & JsUnit

Edward Hieatt
Tuesday, October 14, 2008

Looks like JsUnit gets a few pages devoted to it (about a dozen, actually) in the new book “Foundations of Agile Python Development”:

http://www.apress.com/book/view/1590599810

Thanks to Dave Smith for the pointer.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Adam Milligan

Version 0.3.2 of Desert gem released

Adam Milligan
Monday, October 13, 2008

We’ve uploaded a new version of the Desert gem on to RubyForge. This fixes the issues with template loading in Rails 2.1.0 and later.

From the changelog:

  • Fixed exception in testspec.rake when rspec is not loaded
  • Fix template loading on Edge Rails and on Rails 2.1.0

The Desert source is available on GitHub here.

The Gem is on RubyForge here.

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

Standup 10/13/2008: quiet Monday

Pivotal Labs
Monday, October 13, 2008

Interesting Things

  • Rails Counter cache might interfere with your app if you use column names that ends with _count for your associations. See more on Counter Cache on Rails wiki.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Pivotal Labs

NYC Stand Up 10/13 2008

Pivotal Labs
Monday, October 13, 2008

Interesting

“All your brunch is belong to us” – Damon McCormick

NYC Ruby Tomorrow

Erector 0.4.200 was released. New features include:

  • The Widget#join method, which joins an Array of text/widgets, with a separator which is text or a widget. This translates the standard idiom, without needing calls to raw.

    join [ "People", "Projects" ], ” | “

  • Added a Pretty Printer which can be enabled by Erector::Doc.prettyprint_default = true (for example in development.rb)

JsUnit runs very slowly on the CI box on OSX and eventually times out, unless we open a VNC window to the machine. We tried upgrading to a more recent JsUnit, but couldn’t get that to work at all.

Nanite looks really cool.

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

RR 0.6.0 Released

Pivotal Labs
Monday, October 13, 2008

I’m pleased to announce the 0.6.0 version of RR. The changes include:

  • Declaring Double subject objects without having to pass it in via the mock!, stub!, dont_allow!, instance_of!, and proxy! methods
  • Revised Double chaining API
  • satisfy matcher
  • hash_including matcher

Declaring Double Subjects (The bang methods)

In previous versions of RR, you always needed to pass in the subject of the double. For example:

subject = Object.new
mock(subject).does_something {:and_returns_me}
subject.does_something # :and_returns_me

Now you can have RR automatically create the subject object for you by using the ! method:

subject = mock!.does_something {:and_returns_me}.subject
subject.does_something # :and_returns_me

Now the bang methods by themselves don’t really add a whole lot, but when used in the context of Double chaining, they become a powerful addition.

Double Chaining

Nick Kallen presented the use case for Double chaining and contributed a patch for the 0.5.0 release of RR. It has proved useful and is now more fully incorporated into RR. Now you can pass in your subject or use the subject provided by RR by using the ! method. Here are some examples of Double Chaining:

mock(subject).first(1) {mock(Object.new).second(2) {mock(Object.new).third(3) {4}}}
subject.first(1).second(2).third(3) # 4

mock(subject).first(1) {mock!.second(2) {mock!.third(3) {4}}}
subject.first(1).second(2).third(3) # 4

mock(subject).first(1).mock!.second(2).mock!.third(3) {4}
subject.first(1).second(2).third(3) # 4

Of course you have access to the proxy facilities:

mock.proxy(User).find('1').mock.proxy!.children.mock.proxy!.find_all_by_group_id(10)
User.find('1').children.find_all_by_group_id(10) # Makes verifications pass and returns the actual children

You can also do branched Double chaining:

mock(subject).first do
  mock! do |expect|
    expect.branch1.mock!.branch11 {11} # or expect.branch1 {mock!.branch11 {11}}
    expect.branch2.mock!.branch22 {22} # or expect.branch2 {mock!.branch22 {22}}
  end
end
o = subject.first
o.branch1.branch11 # 11
o.branch2.branch22 # 22

Satisfy Matcher

Matthew O’Conner submitted a patch that added the satisfy matcher. This adds the ability to add arbitrary argument expectation matchers.

mock(object).foobar(satisfy {|arg| arg.length == 2})
object.foobar("xy")

Hash Including Matcher

Matthew O’Conner also submitted a patch that added the hash_including matcher. This adds a convenient way to assert that the passed-in hash includes certain key/value pairs.

mock(object).foobar(hash_including(:red => "#FF0000", :blue => "#0000FF"))
object.foobar({:red => "#FF0000", :blue => "#0000FF", :green => "#00FF00"})

Mailing list

RR has a mailing lists at:

  • double-ruby-users@rubyforge.org
  • double-ruby-devel@rubyforge.org

Also, RR’s rubyforge page is at http://rubyforge.org/projects/double-ruby and of course the github page is at http://github.com/btakita/rr.

Yes, and there is more to come

There are many interesting ideas floating around. Joseph Wilk has been playing around with adding Spies into RR. I’m also thinking about adding Double validation scoping into RR. Also, I’m impressed by Mocha’s warning of unused stubs. Josh Susser also proposed having a mode where a warning would occur if a mocked method is not implemented on the subject being mocked.

If you have any feature requests, please send an email to the mailing list or add it to the rubyforge tracker.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Joe Moore

Pivotal Labs Tech Talks now on iTunes!

Joe Moore
Saturday, October 11, 2008

At Pivotal, we host tech talks for our and guest developers. You can now subscribe to these video and audio tech talks on iTunes!

Just search for “Pivotal Labs” in iTunes, or click on the ‘Video’ or ‘Audio’ buttons on our Talks page. The current playlist includes:

  • Scrum – Christian Sepulveda gives an overview of the Scrum development process as it applies to software.
  • HAML – Felix Mario and Aaron Peckham talk about HAML.
  • Vertebra – Ezra Zygmuntowicz talks about Vertebra, the distributed cloud application programming platform Engine Yard is building.
  • Fire Eagle – Seth and Blaine talk about Fire Eagle, a location-awareness provider for online applications. Fire Eagle is a Yahoo! venture and gives applications and websites user-configurable information about the user’s location.
  • New Relic – Lewis Cirne demos New Relic’s real-time Rails performance monitoring and analysis tool.
  • Devver – Benk Brinkerhoff and Dan Mayer talk about Devver
  • Rubini.us – Evan Phoenix answers questions about Rubinius, a Ruby virtual machine and compiler written as much as possible in Ruby.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Nathan Wilmes

Standup 10/10/2008

Nathan Wilmes
Friday, October 10, 2008

One interesting thing this morning:

The RailsEnvy blog had a segment talking about a team of engineers building a series of social network plugins using the Pivotal Lab’s technology: Dessert.

Those of us used to Desert (one ‘s’) were wondering what Dessert might be, leading to this quip from Adam:

“Dessert is Desert with a lot of syntactic sugar.”

  • 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 >