4. #rackstackatl
TEST-DRIVEN DEVELOPMENT (TRADITIONAL)
Test-driven development is a software development process that relies
on the repetition of a very short development cycle.
First the developer writes an (initially failing) automated test case that
defines a desired improvement or new function,
then produces the minimum amount of code to pass that test,
then finally refactors the new code to acceptable standards.
12. #rackstackatl
LAZINESS OR ARROGANCE
“I just want to write code, not tests.”
“My code works when I push it.”
“It works on my machine.”
“QA does the tests.”
40. #rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require
'chefspec'
!
describe
'apt_package::install'
do
let(:chef_run)
{
ChefSpec::Runner.new.converge(described_recipe)
}
!
it
'installs
a
apt_package
with
the
default
action'
do
expect(chef_run).to
install_apt_package('default_action')
expect(chef_run).to_not
install_apt_package('not_default_action')
end
end
41. #rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require
'chefspec'
!
describe
'apt_package::install'
do
let(:chef_run)
{
ChefSpec::Runner.new.converge(described_recipe)
}
!
it
'installs
a
apt_package
with
the
default
action'
do
expect(chef_run).to
install_apt_package('default_action')
expect(chef_run).to_not
install_apt_package('not_default_action')
end
end
42. #rackstackatl
CHEF DEVELOPMENT KIT: CHEFSPEC
require
'chefspec'
!
describe
'apt_package::install'
do
let(:chef_run)
{
ChefSpec::Runner.new.converge(described_recipe)
}
!
it
'installs
a
apt_package
with
the
default
action'
do
expect(chef_run).to
install_apt_package('default_action')
expect(chef_run).to_not
install_apt_package('not_default_action')
end
end
45. #rackstackatl
SERVERSPEC
describe
package('httpd')
do
it
{
should
be_installed
}
end
!
describe
service('httpd')
do
it
{
should
be_enabled
}
it
{
should
be_running
}
end
!
describe
port(80)
do
it
{
should
be_listening
}
end