Skip to content

Instantly share code, notes, and snippets.

View josephwilk's full-sized avatar
💭
💻 🎨 🎵

Joseph Wilk josephwilk

💭
💻 🎨 🎵
View GitHub Profile
require 'open-uri'
require 'fastercsv'
class ZoneFinder
# Creates a ZoneFinder object
def initialize(network_data_path)
@network_data_path = network_data_path
end
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 }
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
require 'set'
module BagOfMatchers
class Bag
def initialize(list)
@list = Set.new(list)
end
def matches?(list)
default: rails
rails: --require step_definitions/common --require step_definitions/rails rails/
browser: --require step_definitions/common --require step_definitions/selenium browser/
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/
module Cucumber
module Parser
grammar Table
rule record
(cell_value separator record) / cell_value
end
rule separator
'|'
end
@josephwilk
josephwilk / feature_parser.erb
Created December 23, 2008 17:19
Cucumber treetop grammar
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 December 28, 2008 20:53
Cucumber ANTLR grammar
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 January 16, 2009 17:25
Background feature for Cucumber
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