50. describe Player do
before(:each) do
@valid_attributes = {
:first_name => quot;value for first_namequot;,
:last_name => quot;value for last_namequot;,
:active => true
}
end
it quot;should create a new instance given valid attributesquot; do
Player.create!(@valid_attributes)
end
end
52. describe PlayersController do
# missing code here will be revealed soon
it quot;should respond successfully to get 'index' with list of
playersquot; do
Player.should_receive(:find).and_return(@players)
get 'index'
response.should be_success
assigns[:players].should == @players
end
end
55. 1. Isolated
2. Automated
Kent Beck suggests: 3. Quick to write
4. Quick to run
5. Unique
56. describe PlayersController do
before(:each) do
@player_1 = mock(Player, {:first_name => quot;Gregquot;,
:last_name => quot;Normanquot;,
:active => true})
@player_2 = mock(Player, {:first_name => quot;Adamquot;,
:last_name => quot;Scottquot;,
:active => true})
@players = [@player_1, @player_2]
end
it quot;should respond successfully to get 'index' with list of
playersquot; do
Player.should_receive(:find).and_return(@players)
get 'index'
response.should be_success
assigns[:players].should == @players
end
end
74. Feature: Name of feature
In order to derive some business value
As a user
I want to take certain actions
Scenario: Name of scenario
Given a prerequisite
When I take some specific action
Then I should notice the expected outcome
79. Feature: Player belongs to group
In order for a player to be included
As a recorder
I want to record when a player joins or leaves
Scenario: Record when a new player joins
Given a player is not in the system
When I request a list of active players
And I follow quot;Add Playerquot;
And I fill in quot;player_first_namequot; with quot;Gregquot;
And I fill in quot;player_last_namequot; with quot;Normanquot;
And I press quot;Save Playerquot;
Then I should see quot;Active Playersquot;
And I should see quot;Greg Normanquot;
81. When /^I follow quot;(.*)quot;$/ do |link|
clicks_link(link)
end
When /^I fill in quot;(.*)quot; with quot;(.*)quot;$/ do |field, value|
fills_in(field, :with => value)
end
When /^I press quot;(.*)quot;$/ do |button|
clicks_button(button)
end
Then /^I should see quot;(.*)quot;$/ do |text|
response.body.should =~ /#{text}/m
end
84. a little more effort than
just installing the Selenium gem
85. Feature: Check OSDC Site
In order to keep track of conference details
A participant
Should be able to browse the OSDC site
Scenario: Check the home page
Given I am on the OSDC home page
Then I should see the text quot;Welcome to the
Open Source Developers' Conferencequot;
86. require 'spec'
require 'selenium'
Before do
@browser = Selenium::SeleniumDriver.new(quot;localhostquot;,
4444, quot;*chromequot;, quot;http://localhostquot;, 15000)
@browser.start
end
After do
@browser.stop
end
Given /I am on the OSDC home page/ do
@browser.open 'http://www.osdc.com.au/'
end
Then /I should see the text quot;(.*)quot;/ do |text|
@browser.is_text_present(text).should == true
end
94. Sham.name { Faker::Name.name }
Sham.date do
Date.civil((2005..2009).to_a.rand,
(1..12).to_a.rand, (1..28).to_a.rand)
end
Player.blueprint do
first_name { Sham.name }
last_name { Sham.name }
active true
end
Round.blueprint do
date_played { Sham.date }
end
113. “Producing successful, reliable software
involves mixing and matching
an all-too-variable number
of error removal approaches,
typically the more of them the better.”
Robert L. Glass
Facts and Fallacies of Software Engineering
114. “Whether you are a hard-core
‘test first’ person is not the point.
The point is that everyone
can benefit from tests that are
automated, easy to write,
and easy to run.”
Hal Fulton
The Ruby Way
116. • Hal Fulton. The Ruby Way. Addison-Wesley, 2007
• Obie Fernandez. The Rails Way. Addison-Wesley,
2008
• David Chelimsky et al. The RSpec Book: Behaviour
Driven Development with Ruby. The Pragmatic
Programmers, 2009
• Robert L. Glass. Facts and Fallacies of Software
Engineering. Addison-Wesley, 2003