31. • Mac needs XCode first
http://developer.apple.com/xcode/
• Linux or Mac, use RVM bootstrap
http://bit.ly/unixrails
• Windows
http://railsinstaller.org
• Ubuntu on VirtualBox is fun too
32. Test your install
rails new kickballapp
cd kickballapp
bundle
rails server
(open a browser to http://localhost:3000)
45. RESTful Routes
• GET /locations (show all locations)
• GET /locations/3 (show one location)
• POST /locations (make a location)
• PUT /locations/3 (update one location)
46. Can also be nested
• GET /locations/3/games (show games for
one location)
47. ‘public’ folder
• For all static files
• Rails looks here first
• Offers caching options
58. In order to know who is on a team
As a league manager
I want to see a list of players on
the team page
59. Feature: Player listings
In order to know who is on a team
As a league manager
I want to see a list of players on the team page
Scenario: listing on a team page
Given I am on the teams page
When I follow "Ballshevicks"
Then I should see "Trotter"
60. Cucumber
Feature: Player listings
In order to know who is on a team
As a league manager
I want to see a list of players on the team page
Scenario: listing on a team page
Given I am on the teams page
When I follow "Ballshevicks"
Then I should see "Trotter"
62. Setting up Cucumber
1. Add `group :development, :test` to Gemfile
2. Add ‘cucumber-rails’, ‘capybara’ and
‘database_cleaner’ in that group
3. Run `bundle`
4. Run `rails generate cucumber:install`
5. `$EDITOR features/players.feature`
63. undefined local variable or method `node' for
#<Capybara::Driver::RackTest::Node:...>
(NameError)
• Comment out line 18 in features/
support/env.rb
• cucumber-rails 0.4.0 fixes this, but it’s still in
beta
74. Defining Steps
When I follow "Show" in the row with "Ballshevicks"
When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|
When %Q|I follow "#{link}" within "tr:contains('#{text}')"|
end
features/step_definitions/table_steps.rb
75. Defining Steps
When I follow "Show" in the row with "Ballshevicks"
Regular Expression
When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|
When %Q|I follow "#{link}" within "tr:contains('#{text}')"|
end
features/step_definitions/table_steps.rb
76. Defining Steps
When I follow "Show" in the row with "Ballshevicks"
Regular Expression
Capturing groups
When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|
When %Q|I follow "#{link}" within "tr:contains('#{text}')"|
end
features/step_definitions/table_steps.rb
77. Defining Steps
When I follow "Show" in the row with "Ballshevicks"
Regular Expression
Capturing groups
When /^I follow "([^"]*)" in the row with "([^"]*)"$/ do |link, text|
When %Q|I follow "#{link}" within "tr:contains('#{text}')"|
end
features/step_definitions/table_steps.rb
Definition in ruby code
78. web_steps.rb
Given I am on the (rake routes) page
When I press “button” / follow “link”
When I fill in “field” with “value”
When I select “option” from “field”
When I check “field”
Then I should see “text” (within “section”)
81. Use for direct testing of
• Models (test/unit/*.rb)
• Helpers (test/unit/helpers/*.rb)
• Controllers (test/functional/*.rb)
82. Example:
Player#last_name
class PlayerTest < ActiveSupport::TestCase
test "parses out last name" do
trotter = Player.new(:name => "Trotter Cashion")
assert_equal "Cashion", trotter.last_name
end
end
(Test First! At least try.)