Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
💻 🎨 🎵

Joseph Wilk josephwilk

💭
💻 🎨 🎵
View GitHub Profile
View zone_finder.rb
require 'open-uri'
require 'fastercsv'
class ZoneFinder
# Creates a ZoneFinder object
def initialize(network_data_path)
@network_data_path = network_data_path
end
View gist:7936
module ValidationTestHelper
def assert_valid(field, *values)
__model_check__
values.flatten.each do |value|
o = __setup_model__(field, value)
if o.valid?
assert_block { true }
else
messages = [o.errors[field]].flatten
assert_block("unexpected invalid field <#{o.class}##{field}>, value: <#{value.inspect}>, errors: <#{o.errors[field].inspect}>.") { false }
View gist:21931
Feature: Compile C code into Ruby extensions.
In order to automate compilation process.
As a Gem developer.
I want rake tasks compile source code for me.
Scenario: Compile single extension
Given a safe project directory
And scaffold code for extension 'extension_one'
And 'tmp' folder is deleted
View bag_of_matcher.rb
require 'set'
module BagOfMatchers
class Bag
def initialize(list)
@list = Set.new(list)
end
def matches?(list)
View gist:27481
default: rails
rails: --require step_definitions/common --require step_definitions/rails rails/
browser: --require step_definitions/common --require step_definitions/selenium browser/
View cucumber.yml
default: rails
rails: --require features/support/rails_env --require features/step_definitions/common --require features/step_definitions/rails/ features/rails/
browser: --require features/support/browser_env --require features/step_definitions/common --require features/step_definitions/browser features/browser/
View table.tt
module Cucumber
module Parser
grammar Table
rule record
(cell_value separator record) / cell_value
end
rule separator
'|'
end
@josephwilk
josephwilk / feature_parser.erb
Created Dec 23, 2008
Cucumber treetop grammar
View feature_parser.erb
module Cucumber
# :stopdoc:
module TreetopParser
grammar Feature
rule root
space? header scenario_sequence space? {
def compile
feature_elements = scenario_sequence.compile
feature = Cucumber::Ast::Feature.new(nil, nil, header.text_value.strip, feature_elements)
feature
@josephwilk
josephwilk / gist:41042
Created Dec 28, 2008
Cucumber ANTLR grammar
View gist:41042
grammar Gherkin;
//options {
// language=Ruby;
//}
feature : NEWLINE* comment? NEWLINE* SPACE* tags? NEWLINE* SPACE* feature_keyword SPACE* line_to_eol NEWLINE+ (feature_elements .)* feature_elements ;
fragment
feature_elements
@josephwilk
josephwilk / background.feature
Created Jan 16, 2009
Background feature for Cucumber
View background.feature
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
You can’t perform that action at this time.