Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# git pre-commit hook
#
# This will ensure 100% code coverage and all specs passing before allowing a commit
# to the git repo.
#
# Place the file at .git/hooks/pre-commit and use chmod a+x to make it executable.
system('rake clean >/dev/null 2>&1')
@bmabey
bmabey / cruise.rake
Created November 20, 2008 23:44
cc.rb task for rspec, cucumber, rcov (for both examples and featrues), metric_fu, kablame, and a niffty dev task to go along with it
# This assumes you have the metric_fu and kablame plugins installed.
# For kablame I like to modify it to include your stories or features dir as well as the specs.
# Set the artifacts dir for development
ENV['CC_BUILD_ARTIFACTS'] ||= File.expand_path("#{RAILS_ROOT}/metrics")
rspec_base = File.expand_path("#{RAILS_ROOT}/vendor/plugins/rspec/lib")
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
#!/usr/bin/env ruby
spec_commands = {"1.1.12" => "spec", "#does_not_match? version" => "~/p/ruby/rspec/bin/spec"}
base_line = "1.1.12"
number_of_runs = ENV['NUMBER_OF_RUNS'] || 50
class Array
def average
@average ||= self.inject{|sum,v| sum + v} / size.to_f
end
end
Feature: Backgrounds
In order to provide a context to my scenarios within a feature
As a feature editor
I want to write a background section in my features.
Scenario: run a scenario with a background with a passing step
When I run cucumber -q features/passing_background_sample.feature:6
Then it should pass with
"""
Feature: sample
Feature: Scoring
In order to provide an enjoyable experience to my customers
As a bowling alley manager my customers
should be able to have there games scored automatically
Scenario Outline:
@bmabey
bmabey / builder_steps.rb
Created February 5, 2009 21:08
Test Data Builder Cucumber Steps
module BuilderStepHelpers
def create_model(model_name, attributes={})
send("create_#{model_name.gsub(' ','_')}",attributes)
end
end
World do |world|
world.extend BuilderStepHelpers
end
@bmabey
bmabey / error with inline builder
Created February 11, 2009 01:08
fixjour problem
Scenario: User confirms his account # features/sign_up.feature:23
Given I signed up with "[email protected]/password" # features/step_definitions/clearance_steps.rb:13
can't convert Fixjour::MergingProxy into Hash (TypeError)
./features/step_definitions/clearance_steps.rb:16:in `/^I signed up with "(.*)\/(.*)"$/'
features/sign_up.feature:24:in `Given I signed up with "[email protected]/password"'
When I follow the confirmation link sent to "[email protected]" # features/step_definitions/clearance_steps.rb:53
Then I should see "Confirmed email and signed in" # features/step_definitions/webrat_steps.rb:89
And I should be signed in
#!/usr/bin/env ruby
require 'rubygems'
require 'tempfile'
require 'nokogiri'
require 'rdiscount'
# makers-mark
#
# Generates HTML from Markdown, replacing code blocks with syntax
1)
'Cucumber::Mate::Files::FeatureFile#steps_starting_with when 1 matching string step definition exists should return the step definition' FAILED
expected: 1,
got: 0 (using ==)
./spec/cucumber/mate/files/feature_file_spec.rb:135:
2)
'Cucumber::Mate::Files::FeatureFile#steps_starting_with when 1 matching regex step definition exists should return the step definition' FAILED
expected: 1,
got: 0 (using ==)
module ObjectLocators
def the_policy
if @policy
@policy
else
case Policy.count
when 0
raise "There is no @policy variable defined and no policy in the DB! Establish state in previous step or create a new policy."
when 1