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: February 2012

Stephan Hagemann

Boulder Standup – Feb 16, 2012

Stephan Hagemann
Thursday, February 16, 2012

rspec should render_template still behaving weirdly

Specing a partial being rendered with render_template blows up. What to do?

render_template has been brittle for a long time. It obviously still is:

response.should render_template("template") #works fine
response.should render_template(partial: "template") #works fine
response.should render_template(partial: "template", locals: {local_array: []}) #blows up within rspec

You know how to fix it? Solve it here

RubyMine 4 is out

RubyMine “compare two files” isn’t broken

It is just really, really weird: if you have to scroll when comparing two files check the file that is above in the project drawer first. If you scroll up to do select the second file to compare, the compare window won’t open.

Stubbing can? can be hard

In a system with a lot of cancan abilities – what is the best way to stub a particular ability for controller specs? In the hierarchy of controllers, a lot of abilities may be checked, all of which would need to stubbed in order to get to the code under test.

Instead of stubbing the abilities, create a new, anonymous, ability class specific for your spec that gets all the necessary abilities and then stub current_ability to return an instance of that class. Internally cancan calls current_ability when you call can?: cancan controller additions

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Alexander Murmann

SF Standup 2012-02-14

Alexander Murmann
Tuesday, February 14, 2012

Help

Headless Selenium

Ken is running his integration tests in parallel on multiple Selenium instances. It’s working well for him, but having 6 Firefox windows up, makes working on the machine a pain. So he is wondering if there is a way to run FF in headless mode on OS X.

It was suggested to change the Mission Control settings so that Firefox always comes up in a separate space.

Which Gems for Twitter and Facebook

Tim wants to know which gems are currently en vogue for posting to Twitter and Facebook.

The gems to use are still the twitter gem and the koala gem

Assigning Command + Esc

Expose used to be assigned to Command + Esc. Now that that’s gone the key combination should be available to be linked to. However, it seems like the key combination still can’t be used.

Interestings

Capybara find(…) and stale elements

Davis’s help from yesterday about stale element exceptions in Capybara got resolved. It turns out that Capybara cache find results. If you execute find twice and move the element between the executions, Capybara will complaint about a stale element, instead of running find again.

Capybara has_selector vs. has_no_selector

Capybara’s has_selector and has_no_selector matchers will wait for the selector to match something, in order to deal with timing issues. When using the manually negated form not.has_selector Capybara can’t know that it is supposed for the condition to become true. In fact it will be waiting for the element to be there instead of the element not to be there. So if a element is supposed to disappear and you are using not.has_selector to test that, by the time Capybara runs the matcher your element might still be there and Capbara returns true and you get an error, although the element would have disappeared shortly after. The has_no_selector matcher on the other hand would keep checking until the element disappeared.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ronan Dunlop

Tracker Ecosystem News: Pivotal Booster

Ronan Dunlop
Tuesday, February 14, 2012

Happy Valentine’s Day from the Tracker Team!

In the spirit of this pop-western-religious-hallmark-day we’re going to indulge in a public display of beta affection.

Pivotal Booster, from our friends at the Railsware Company, is a beautiful OS X client. It’s free, it’s in beta, it’s easy to install and if you’re a mac user there’s no reason not to get it.

Two features we’d like to call out that make this a must have:
1) My Stories View… across all projects. Very handy… we like it.
2) Toggle between stories assigned to me and stories requested by me. Great for the coder… and the manager too.

Railsware promises even more functionality in the next month or two. Here’s a sneak peek we’ve obtained exclusively for the Tracker faithful.

Stay tuned to this blog – We’ll be highlighting more apps from the Tracker ecosystem in the near future.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ken Mayer

SF Standup – Feb 13, 2012 – The Sound of One Hand

Ken Mayer
Monday, February 13, 2012

Cries for help

Capybara is reporting “stale elements” for no good reason.

Any experience, war stories upgrading from jQuery 1.6 to 1.7, especially with the whole event delegation API change? [crickets] See interestings…

Interestings

Have a really big spec file that takes a long time to run? http://rubygems.org/gems/parallel_split_test, from our own Michael Grosser, will run a big spec file in smaller chunks.

url helpers cache results for better performance, but they seem to be losing custom options (in this case a locales setting).

In jQuery 1.6, triggering an event in an unattached DOM node would propagate the event up into the document, even though it was never attached to it. jQuery 1.7 (maybe 1.7.1) fixes this behavior.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Steve Ellis

NYC Standup: 2/5-10 Batched

Steve Ellis
Friday, February 10, 2012

Interesting

  • assert_template Matching: RSpec’s template matcher uses a reg ex, which is loose enough to cause some false positives.
  render "_foo_bar.haml"

will pass cause both of these to pass:

  should render_template "_foo_bar.haml"
  should render_template "_bar.haml"

The best solution presented was to explicitly say what you expect not to be rendered(should_not render_template “_bar.haml”). There has been some activity on Github recently around ActionController’s assert_template method, but none addressing this exact problem(1 example: https://github.com/rails/rails/pull/3879/files). The regex is complicated by the fact that it has to match ambiguous partials rendered with specific paths(should render_template “_bar.haml” needs to match render “foo/_bar.haml”).

  • Let It Be: If you declare a “let!” variable at the top of a file, and redeclare that variable with a “let” statement in a nested context, the variable will not be lazily loaded. RSpec evaluates it as a “let!”.

  • Binary Tempfiles: There is no way to open a new Tempfile in binary mode; you must open it first and then call foo.binmode.

  • Airbrake was acquired by Exceptional
    http://techcrunch.com/2012/02/07/exceptional-acquires-error-tracking-application-airbrake/

  • Auto compiling SASS, pre-3.0: Adam used ‘compass watch’ and Foreman to automate the regeneration of stylesheets in development. This prevents him from having to wait for the sass to recompile on the first request he makes after modifying stylesheets. https://github.com/ddollar/foreman

  • Should receive, in any order: Ian & Suman were attempting to write an RSpec 1.3 spec that asserted a method was called with an array that included the correct elements; however, the order of the elements within the array was not important. Seems there is no array_including equivalent to hash_including. The solution they came to was to use the block style expectation as defined here: https://www.relishapp.com/rspec/rspec-mocks/docs/argument-matchers

  foo.should_receive(:bar) do |arg1|
    arg1.should =~ [3,1,2]
  end

Anyone know of a built-in matcher for arrays similar to hash_including?

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ian Lesperance

Standup 02/10/2012: Who Reads the Manual, Anyway?

Ian Lesperance
Friday, February 10, 2012

Help

“Anyone know what DocumentCloud uses to generate the documentation for Backbone.js, Underscore.js, et. al.?”

It’s a mystery.

Interesting

  • MyMarks—if you use Xmarks to synchronize your bookmarks across browsers/machines, you can use MyMarks to browse them from your mobile device. It’s a Sinatra/jQuery Mobile app written by our very own Michael Grosser. It’s also on Github.
  • user_env_compile—an experimental Heroku Labs feature that makes your application’s configuration variables present during slug compilation. This is useful if, for example, you need the environment loaded when precompiling assets.
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
David Stevenson

Standup for 2/9/2012: NP in P time? As usual, no.

David Stevenson
Thursday, February 9, 2012

Ask for Help

“How can I know all the descendants of a class in the superclass at load time in ruby? I want to create a scope for each subclass.”

You can’t.

“What popovers should I use?”

We’ve used at least these two before:

  • QTip
  • Tipsy

“What recurring billing system should I use?”

We’ve had good luck with BrainTree and Recurly.

Interesting Things

  • backbone-forms is a plugin to backbone that provides model-based form views similar to rails’ form_for functionality.
  • EmberJS meetup will be Feb 21, at our new pivotal office!
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

BrowserID

Wednesday, February 8, 2012

Ben Adida, Mozilla’s Director of Identity, talks about BrowserID, “an experimental new way of signing into websites.”

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Ian Lesperance

Standup 02/07/2012: What’s the Sound of All Hands Clapping?

Ian Lesperance
Tuesday, February 7, 2012

Ask for Help

“Are there any good enum gems that work with Rails 3.2?”

Try simple_enum. But watch out: by default it will take your array of string values and store the numeric indices in the database. To avoid having to migrate your existing data, you can pass it a hash:

as_enum :status, :pending => "pending", :active => "active"

Interesting Things

“And… clap.”

A fun thing to try at standup: get everyone to clap once simultaneously without counting down.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Stephan Hagemann

IntelliJ Modules in Rubymine

Stephan Hagemann
Tuesday, February 7, 2012

IntelliJ has a feature called modules: “a functional unit which you can compile, run, test and debug independently.”

Modules in IntelliJ: Multiple top-level folders

A module in IntelliJ is a top-level view on a part of a codebase. IntelliJ is for Java, which is why I do not typically use it. I use Rubymine – no similar functionality exists here… but a way around that!

It may have been true at some point that these kind of modules were not something that Rails offered, but they have been around for quite a while: Engines!

Engines are typically seen as a way to package a Rails app that can be reused and configured in the context of other Rails apps. However, many big Rails projects can benefit from engines and their ability to structure a large codebase into smaller, more independent parts. Namespacing within one Rails app can achieve a similar effect, but engines take it to the next level: all the code, including views, javascript, and even rake tasks and migrations can be separated consistently. Now, if the apps were totally separate, several independent Rails apps might be the right solution, but if those are tied together by the same database, one might do more harm then good when ripping that code apart…

The Problem

Imagine a Rails project with the following folder structure:

rails_app/
  app/
  ...
  engines/
    custom_engine1/
    custom_engine2/
  ...

The engines are somewhat hidden away, two levels deep in the folder structure. Also, running specs for engines in these sub-folders won’t work from Rubymine, because the paths it tries to use are wrong.

Whether you are actually working with engines or just want to see multiple root folders in Rubymine at once, here is how to do it.

Make modules work in Rubymine

1) You can get modules to work in Rubymine by opening your Rails project in IntelliJ: Cmd + ; opens the project structure dialog, select Modules from the list on the left and create a new module with the + button. Or, you can simply add a few files to your project…

2) The .idea folder in the root of your project holds the Rubymine configuration files. Edit modules.xml and add a module line for every module you would like to create:

<!-- ROOT/.idea/modules.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/custom_engine1/module1.iml" filepath="$PROJECT_DIR$/custom_engine1/custom_engine1.iml" />
      <module fileurl="file://$PROJECT_DIR$/custom_engine2/module2.iml" filepath="$PROJECT_DIR$/custom_engine2/custom_engine2.iml" />
    </modules>
  </component>
</project>

In the root folder of every module create a .iml file with the name of that module like so:

<!-- ROOT/engines/custom_engine1/custom_engine1.iml -->
<?xml version="1.0" encoding="UTF-8"?>
<module type="RUBY_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$" />
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

Voila: The next time you open the project folder in Rubymine, the custom_engine folders show up as top-level entries in the projects file list!

Modules in Rubymine!

Here is the gist: https://gist.github.com/1764127

This worked for me with Rubymine 3.2.4 and IntelliJ IDEA 11 CE.

Edit March 14: make sure that all module names are distinct and no module names are substrings of other module names. This confuses RubyMine and can prevent specs from running successfully.

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