Feature: Sign in to the member directory
As a member, I need to sign in to the system to modify my account details
Scenario: Successful signin
Given that I have a membership number and password
When I visit the sign in page
And I enter my membership number and password
And the password is correct
When I click sign in
Then I should have signed in successfully
From
https://github.com/theodi/member-directory/blob/master/features/signin.feature
cucumber features/signin.feature -f progress
UUUUUU
1 scenario (1 undefined)
6 steps (6 undefined)
0m0.004s
You can implement step definitions for undefined steps with these snippets:
When(/^I enter my membership number and password$/) do
pending # express the regexp above with the code you wish you had
end
Then(/^I should have signed in successfully$/) do
pending # express the regexp above with the code you wish you had
end
Drive out the code required to make the tests pass
Given /^that I have a membership number and password$/ do
member = Member.create(
:email => 'sam@foobar.com',
)
member.confirm!
@membership_number = member.membership_number
@password = 'p4ssw0rd'
end
When /^I enter my membership number and password$/ do
fill_in('member_membership_number', :with => @membership_number)
end
Then /^I should have signed in successfully$/ do
page.should have_content "Signed in successfully"
end
From
https://github.com/theodi/member-directory/blob/master/features/step_definitions/signin_steps.rb
Scenario: one without postcodes
When I successfully run `noodile sample.csv`
Then a file named "outputs/complete.no.postcodes.csv" should exist
Then /^a file named "([^"]*)" should exist$/ do |file|
check_file_presence([file], true)
end
def check_file_presence(paths, expect_presence)
prep_for_fs_check do
paths.each do |path|
if expect_presence
File.should be_file(path)
else
File.should_not be_file(path)
end
end
end
end
https://github.com/cucumber/aruba
All watched over by machines of loving graceRichard Brautigan
For example, this:
package 'nginx' do
action :install
end
installs stock nginx. Under the hood, Chef works out from the host OS whether it needs apt or yum or whatever, but we don't need to care about that
script 'Bundling the gems' do
interpreter 'bash'
cwd current_release_directory
user running_deploy_user
code <<-EOF
bundle install --without=development --quiet --path #{bundler_depot}
EOF
end
:(){ :|:& };:
in there (DON'T DO
THIS!)
TDD allows me to demonstrate my incompetence in the tests *as well* as in the code. Awesome.Sam, on Twitter
Things like
And /^I run "([^\"]*)"$/ do |command|
@result = @connection.exec(command, :silence => true)
@output = @result.output
@exit_code = @result.exit_code
end
Then /^I should( not)? see "([^\"]*)" in the output$/ do |boolean, string|
if (!boolean)
@output.should =~ /#{string}/
else
@output.should_not =~ /#{string}/
end
end
The Labfile
ecosystem "odc" do
container "web-certificate-01" do
distro "ubuntu"
release "precise"
persist true
ip "192.168.98.30"
mac "00:00:5e:16:89:b5"
chef_client (
{
:environment => "odc-production",
:run_list => [
"role[certificate]"
]
}
)
end
end
Feature: webserver
Background:
* I ssh to "web-certificate-01"
Scenario: Core dependencies are installed
* package "git" should be installed
Scenario: Ruby 1.9.3 is installed
When I run "su - certificate -c 'ruby -v'"
Then I should see "1.9.3" in the output
Scenario: configuration stuff is correct
* file "current/config/database.yml" should exist
When I run "cat current/config/database.yml"
Then I should see "host: 192.168.98.20" in the output
Then /^package "([^\"]*)" should be installed$/ do |package|
command = ""
if (dpkg = @connection.exec("which dpkg 2> /dev/null",
silence: true).output).length > 0
command = "#{dpkg.chomp} --get-selections"
elsif (yum = @connection.exec("which yum 2> /dev/null",
silence: true).output).length > 0
command = "#{yum.chomp} -q list installed"
end
@result = @connection.exec(command, :silence => true)
@result.output.should =~ /#{package}/
end
Add the recipe to the role
name 'certificate'
default_attributes 'user' => 'certificate',
'group' => 'certificate',
'migration_command' => 'bundle exec rake db:migrate'
run_list "role[base]",
"recipe[chef-client::cron]
name "base"
run_list "recipe[git]"
And now this test passes
site 'http://community.opscode.com/api/v1'
cookbook 'chef-client'
cookbook 'apt', '= 1.9.0'
cookbook 'git'
cookbook 'mongodb', :github => 'edelight/chef-mongodb'
cookbook 'mysql'
cookbook 'fail2ban', :github => 'opscode-cookbooks/fail2ban'
Vagrant.configure("2") do |config|
config.vm.define :certificate_theodi_org_01 do |config|
config.vm.provider :rackspace do |rs|
rs.flavor = /512MB/
rs.image = /Precise/
rs.auth_url = "https://lon.identity.api.rackspacecloud.com/v2.0"
end
config.vm.provision :chef_client do |chef|
chef.environment = "odc-production"
chef.chef_server_url = "https://chef.theodi.org"
chef.run_list = [
"role[certificate]"
]
end
end