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

Launching Focused Jasmine Specs From RubyMine

Charles Hansen
Wednesday, May 8, 2013

RubyMine is great for launching focused rspec tests, but is a little trickier for launching Jasmine specs, but we have had it working on my current project using a shell script and RubyMine external tools .  The script relies on using sed to parse the first line of your spec file, so this actually only runs the describe block at the top of your file.  The steps for our setup below.

  • Create a shell script somewhere in your project:
  • Go to RubyMine -> Preferences -> External Tools -> +
  • This should launch a new tool dialog.  Fill in name, descriptions, etc
  • For program, you should link the script you just created.
  • For parameters, you should use “$FilePath$”
  • Bind this external tool under keymaps (look for the name you just gave it).  We use command-option-control-f8
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 11/29/12: Time.now, more like Time.at(2011)

Charles Hansen
Thursday, November 29, 2012

Helps

mock object nil when it shouldn’t be

(rdb:1) @registration

RSpec::Mocks::Mock:0x3fda7eabfd68 @name=”mocked registration”

(rdb:1) @registration.present?
false
(rdb:1) @registration.nil?
false

  • mock objects don’t always define nil? or present?

Interestings

David Chelimsky handing off rspec

David Chelmisky is stepping down as the RSpec lead after 6+ years. http://blog.davidchelimsky.net/2012/11/28/myron-marston-and-andy-lindeman-are-rspecs-new-project-leads/

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 11/28/12: Mohawk Day!

Charles Hansen
Wednesday, November 28, 2012

Helps

Request log output in controller specs

We are getting info level log out put when running our specs from the controller examples. I don’t know how they are getting turned on nor how to turn them off

  • Crickets

default host when using url helpers in regular classes

How do most projects handle the default host for url helpers when the helper is being included in presentation classes etc?

  • Pass your controller to your presenter and ask the controller for url helpers

making rspec2 custom example groups

any one know how to define custom example groups in rspec and associate them with specs in a given folder.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 11/26/12

Charles Hansen
Monday, November 26, 2012

Interestings

dotenv Gem

Have you tried this gem? It kind of rocks it. Works great with a Heroku development environment. It even has files for different Rails modes, e.g. .env.test

https://github.com/bkeepers/dotenv

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Hunting Memory Leaks in Backbone

Charles Hansen
Tuesday, October 23, 2012

Ever notice your backbone app slows down considerably after using it for a few minutes? Or maybe your event callbacks are called more than once each time the event fires? Or my favorite, Chrome runs out of memory if you have a few tabs open that have run your entire Jasmine suite? This means you have backbone leaks.

I just spent the last week hunting these down in a very large app. It turns out the problem is tractable with a few guidelines. None of this is ground-breaking, but I wanted to put it all in one place.

1) The object retaining tree in the Chrome heap profiler is amazing. Use it.

2) Restrict use of views in closures, or as contexts to callbacks in event bindings. This is explained in much more detail here. I’ve also personally found nothing but trouble with _.bind for similar reasons.

More specifically, never use model.bind or model.on in a view without keeping track of that binding and remembering to unbind it when you want to tear down the view. This is the motivation for coccyx

3) ParentViews with childViews need to keep track of their children. When you tear down the parent view, you also tear down the child views. Before implementing this step, the object retaining tree for my zombie views was shockingly large. Afterwards, it was a manageable ~4 retainers for the zombies.

Parents keeping track of their children seems simple enough, but it is easy to lose track of the little devils.

For example:

ParentView = Backbone.View.extend({
    render: {
        //render the rest of the view first

        this.collection.each(function(model){
            var childView = new ChildView({model: model});
            this.$("ul").append(childView.render().$el);
        });
    }
});

loses any reference to the child views, and they will almost certainly leak (assuming the child views bind events to their models that need to be cleaned up).

Using the principles names from coccyx, the same code needed to be rewritten as

ParentView = Backbone.View.extend({
    render: {
        //render the rest of the view first

        this.tearDownRegisteredSubviews();

        this.collection.each(function(model){
            var childView = new ChildView({model: model});
            this.$("ul").append(liView.render().$el);

            this.registerSubView(childView);

        });
    }
});

where tearDownRegisteredSubviews calls tearDown on any registered subviews. This way, the only child views still in memory are those initialized in the most recent call to render. Those remaining views should be torn down when the parent is torn down.

View.tearDown itself can be a bit sticky because you still have to worry about event bindings from global objects and other difficult-to-clean sources, but those solutions are more project-specific.

Hope that points you in the right direction.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 10/26/2011: Nothing

Charles Hansen
Wednesday, October 26, 2011

Nothing today

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Standup 10/24/2011: Women who code meetup

Charles Hansen
Monday, October 24, 2011

Interesting Things

There will be a Women Who Code meetup on Tuesday. Sarah Mei will be giving a lightning talk at it about a day in the life of an engineer. The organization is for both women who are currently coders and those just interested in coding.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Charles Hansen

Charles Hansen
San Francisco

Subscribe to Charles's Feed

Author Topics

jasmine (1)
rubymine (1)
agile (5)
backbone (1)
javascript (1)
  • 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 >