Scenario: Sign Up with LinkedIn
When I go to the home page
And I follow "Sign Up"
And I grant LinkedIn access
Then I should be on the new user page
My application has a hyperlink that opens the OAuth login on the OAuth provider’s website in a new window. Let’s presume the simple matter of wiring this up is already coded in my view.
Testing this with Cucumber requires telling the Selenium web driver to interact with the new popup window. We can do this using page.driver.browser.window_handles to find the newest window handle and scoping out actions to that window.
When /^I grant LinkedIn access$/ do
main, popup = page.driver.browser.window_handles
fill_in("Email", :with => "email@example.com")
fill_in("Password", :with => "password")
click_on("Ok, I'll Allow It")
And that’s it!
Keep in mind that if you use this test as-is, you will be hitting LinkedIn on the real Internet. This is great if you want a test that will always verify the real API, but not so good for CI, since it is Internet connection-dependent and slow. Consider using something like VCR or Artifice to stub out your service calls.
Today, Josh Knowles, Grant Hutchins, and I visited Franklin W. Olin College of Engineering in Needham, MA to talk to Prof. Mark L. Chang’s amazing new dotcom course. We talked about agile development, and more specifically how Pivotal does agile and why. We went through an example of test-driven development for a simple Rails app, and had a miniature inception for a fictitious product.
Some students asked for some resources, particularly for documentation, so I put together a collection of resources for anyone looking to pick up agile, TDD and Ruby on Rails. This is intentionally not an exhaustive list. I wanted to include the bare minimum for getting started on each topic as a jumping off point and include further references at the end.
A talk by Ian MacFarland, also available on iTunes. video and audio
What agile development means for Pivotal, with a healthy dose of how much fun it is to work here.
You can think of Pivotal Tracker as a digital card wall. It’s our most indispensable project tool.
This talk by Kerry Buckley is probably the best RSpec overview and tutorial I’ve seen. Read this and follow along with the code and you will know more than just the basics of how TDD with RSpec works.
The Pivotal Labs TDD framework for Android development with a great Getting Started Guide and JavaDoc.
A great interactive tutorial on git.
Learn Ruby through test-driven development. This tutorial covers a huge number of features of the Ruby language in a fun and interactive way.
Includes video tutorials and interactive exercises that go over the core concepts of Rails.
We commonly use the following gems on Pivotal projects:
- devise for authentication — check out their README and Wiki for documentation
- cancan for role-based authorization — again, check the README and wiki for documentation
- rspec-rails for TDD — see Wiki for installation, see above RSpec presentation for how to use it
- cucumber-rails for BDD and integration testing — see README for installation, this Railscast for an introduction
- paperclip for file attachment and storage — see README for documentation
- will_paginate for index pagination (ie: “Showing results for Page 1 of 30″) — check out the README