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: April 2007

Joe Moore

Standup 04/30/2007

Joe Moore
Monday, April 30, 2007

Interesting Things

  • MoniTwitter is live! Check out the coolest site-monitoring mash-up in the history of site-monitoring mash-ups!
  • When you use :dependent => :destroy to cascade deletes, make sure you test them well! This really saved our bacon during a major rafactoring.

Ask for Help

  • “I always forget how to submit an HTML form with a link in Rails…” Here you go!

<%= link_to_function('Link Name', "$('form_id').submit()") %>

Total Stand-up Meeting Time: 20:00 minutes

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

Standup 04/27/07: Testing File Uploads

Pivotal Labs
Friday, April 27, 2007

The setup:

I’m told file uploading is a pain to test. We needed to. So we cruised through the tubes over to ruby-doc.org to check out the Net::HTTP rdoc — only to find that Net:HTTP::Post does not support multipart uploading and files. What to do, what to DO?!?

The research:

Some googling later, we find this article showing how to do it. A little copy-paste, a small spike later, and we have an external script capable of uploading files into our web-apps. But, lets brain-storm a little…

  • How can we make it better?
  • What would be a nice interface?

Well, the first step is to change the script such that it can be more easily integrated into rake test:functionals: make it less script-y; more library. The interface is somewhat inspired by the basic_auth method. All you have to say is Net::HTTP::Post.new().multipart_params = {}? You give it a hash, and it takes care of the rest. Huzzah! So lets open up Net::HTTP::POST and give it some new methods. Time for some CODE!!!

The Code

require 'net/https'
require "rubygems"
require "mime/types"
require "base64"
require 'cgi'

class Net::HTTP::Post
  def multipart_params=(param_hash={})
    boundary_token = [Array.new(8) {rand(256)}].join
    self.content_type = "multipart/form-data; boundary=#{boundary_token}"
    boundary_marker = "--#{boundary_token}rn"
    self.body = param_hash.map { |param_name, param_value|
      boundary_marker + case param_value
      when String
        text_to_multipart(param_name, param_value)
      when File
        file_to_multipart(param_name, param_value)
      end
    }.join('') + "--#{boundary_token}--rn"
  end

  protected
  def file_to_multipart(key,file)
    filename = File.basename(file.path)
    mime_types = MIME::Types.of(filename)
    mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
    part = %Q|Content-Disposition: form-data; name="#{key}"; filename="#{filename}"rn|
    part += "Content-Transfer-Encoding: binaryrn"
    part += "Content-Type: #{mime_type}rnrn#{file.read}"
  end

  def text_to_multipart(key,value)
    "Content-Disposition: form-data; name="#{key}"rnrn#{value}rn"
  end
end

Oh the utility:

Now that’s more like it. Hackish, since you have to stick headers into the request body, but effective. Notice the bit in there about MIME::Types. Did you see that? Yeah, we went there. Say it with me… Automatic mime type detection with a safe default. The absurd thing in there is that the MIME::Types gem (as of today) does not know about .rb files.

irb(main):007:0> MIME::Types.of('something.rb')
=> []

So now that you have that, it’s just a simple use of Net::HTTP with a blizzock to upload a file in a functional test.

File.open(File.expand_path('script/test.png'), 'r') do |file|
  http = Net::HTTP.new('localhost', 3000)
  begin
    http.start do |http|
      request = Net::HTTP::Post.new('/your/url/here')
      request.basic_auth 'lonely_user', 'really_long_password'
      request.multipart_params = {'file' => file, 'title' => 'title'}
      response = http.request(request)
      response.value
      puts response.body
    end
  rescue Net::HTTPServerException => e
    p e
  end
end

The questions:

So what do you think? How can this be made even better?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Christian Sepulveda

Preemptive Optimization

Christian Sepulveda
Thursday, April 26, 2007

Many software developers are overly sensitive to performance and spend a lot of
time and effort considering the performance of their code design. While I
understand their concerns and that they don’t want to be negligent, their
efforts are generally inefficient and sometimes misguided.

Performance bottlenecks are commonly not where you would have expected them to
be. A lot of upfront effort can be wasted on poor assumptions and planning.

Many respond to this argument by doing even more preemptive optimization design
and planning, so as to correctly identify the bottleneck. This is rarely as
efficient as simply implementing the original feature, profiling it, and then
tune or address the actual bottlenecks.

There are certain contexts where some preemptive optimization is appropriate,
such as network drivers or low-level protocol implementations. But in the
majority of cases, there is no need. Overall, the balance of concern is wrong,
in my opinion. Some advance thought for performance, so long as it doesn’t
disrupt your progress, probably won’t impact productivity much.

Unfortunately, I’ve been in many conversations where someone played the
“performance card” and derailed any discussion or progress while that tangent
had to be addressed. This is an example of a larger, more troubling problem in
software development.

There are many areas of presumed conventional wisdom than
few are willing to challenge. This combined with the typical myopia most
developers experience, whereas they see the problem they want to solve as
opposed to the one that is there, is one of the main risks to success for
software projects. Also, if the conventional wisdom and status quo was so
correct in software, why are there so many failed projects, blown schedules and
budgets, and quality and sustainability problems in the software industry?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 2.5

Alex Chaffee
Monday, April 23, 2007
  1. Introductions. Anybody new? Any guests in the room?
  2. Help! Anybody need assistance?
  3. Neat! Interesting things we want to share.
  4. Status. Only if there’s time — project or individual reports.

(Based on Standup 2.0.)

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Full-stack web app testing with Selenium and Rails

Alex Chaffee
Monday, April 23, 2007

Brian Takita and Alex Chaffee gave a presentation at the
SDForum Silicon Valley Ruby Conference over the weekend,
entitled Full-stack web app testing with Selenium and Rails. We’re going to do it again at Agile 2007 (and we’ll have an extra half-hour next time, so we’ll have time to do some interactive pairing with some unsuspecting audience member).

Here are the slides, courtesy of SlideShare:

SlideShare | View | Upload your own
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Full-stack web app testing with Selenium and Rails

Alex Chaffee
Monday, April 23, 2007

Brian Takita and Alex Chaffee gave a presentation at the
SDForum Silicon Valley Ruby Conference over the weekend,
entitled Full-stack web app testing with Selenium and Rails. We’re going to do it again at Agile 2007 (and we’ll have an extra half-hour next time, so we’ll have time to do some interactive pairing with some hapless audience member).

Here are the slides, courtesy of SlideShare:

SlideShare | View | Upload your own
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Silicon Valley Ruby Conference Report

Alex Chaffee
Monday, April 23, 2007

Brian Takita and Alex Chaffee gave a presentation at the
SDForum Silicon Valley Ruby Conference over the weekend,
entitled Full-stack web app testing with Selenium and Rails (slides hosted at SlideShare).

We also attended a few talks (unfortunately we couldn’t attend the whole thing). A few highlights:

Mongrel HTTP handlers.

From Brian:

I’m at Ezra‘s Mongrel HTTP Handler’s talk and it looks like a way to
improve Tracker’s JSON performance.

The simple “Hello World” benchmark was something like this:

  • Rails: ~121 req/sec
  • Mongrel: ~900 req/sec

There is an in-process mode that a mongrel HTTP handler can be run in.
This handler will be run in process of your rails app. You have access
to Active Record. It just avoids ActionController.

Ezra wrote a framework named Merb (Mongrel + ERB).

Also, mongrel is thread safe. Also, Ezra shared that he wants to avoid
magic in Merb.

Ezra’s slides are online now.

Here’s what Josh wrote about Merb.

Heckle

Heckle
is a framework for doing “mutation testing” (like Jester for Java).
Kevin Clark demoed it and it looks like a valuable addition to any Ruby build (though
probably not as a requirement for a green build — more like part of a nightly metrics
run).

Microformats

Chris Wanstrath of Err the Blog gave a talk that was ostensibly about Web Services but that
actually ran a manic gamut from SOAP to
Microformats to
Firefox plugins to
command-line blogs to
mock object libraries.
His speaking style is deceptively laid-back — if you don’t pay close attention, especially to code examples, you’ll miss entire open-source
civilizations being born and collapsing. Fortunately, I had just given a talk so my neurons were all juiced up,
which meant I could just barely keep up. Bottom line for microformats: gem install mofo.

Update: More Slides

Check out SlideShare’s svrc tag for more slide presentations from the conference, including Ezra’s Mongrel Talk.

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

Standup 04/23/2007

Joe Moore
Monday, April 23, 2007

Interesting Things

Latest news from the “cool new stuff” front:

  • Check out these very educational slides about Mongrel HTTP Handlers, which allow you to use Mongrel with ActiveRecord, but bypass ActionController and other aspects of Rails.
  • Also check out Merb: Mongrel + Erb, a “little bitty lightweight ruby app server.”
  • Finally, Heckle, a mutation tester similar to Java’s Jester.

Total Stand-up Meeting Time: 9:00 minutes

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Keeping Your Design Three-Quarters-Baked

Alex Chaffee
Thursday, April 19, 2007

I just gave a talk at the
Web 2.0 Expo
with
Leslie Chicoine of Satisfaction.
We shared our insights into the challenge of integrating foundational design methods (interaction design, usability design, interface design, interaction design) into a team doing Agile development (rapid releases, week-long iterations, high feedback and communication). It was a lot of fun! The room was packed, the energy was high, and they laughed at our jokes!

Here are the slides:

You can also see the slides here at SlideShare. Let me know what you think!

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

The Challenge of Agile Design

Alex Chaffee
Thursday, April 19, 2007

I just gave a talk at the
Web 2.0 Expo
with
Leslie Chicoine of Satisfaction.
We shared our insights into the challenge of integrating foundational design methods (interaction design, usability design, interface design, interaction design) into a team doing Agile development (rapid releases, week-long iterations, high feedback and communication). It was a lot of fun! The room was packed, the energy was high, and they laughed at our jokes!

Here are the slides:

SlideShare | View | Upload your own

You can also see the slides here at SlideShare. Let me know what you think!

  • 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. 1
  2. 2
  3. 3
  4. →
  • 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 >