Skip to content

Instantly share code, notes, and snippets.

View msassak's full-sized avatar

Mike Sassak msassak

View GitHub Profile
start = Time.now
puts "Starting to read file ..."
num = 0
File.open(ARGV[0]) do |f|
f.each { |l| num += l.split.length }
end
puts "The number of tokens is: #{num}."
puts "It took #{(Time.now - start) * 1000} ms"
# tags without a newline after them
# 1a) currently legal:
@hello Feature: foo
@goodbye Scenario: bar
Given baz
# 1b) proposed:
@hello
Feature: foo
@goodbye
# config.ru
require 'appengine-rack'
AppEngine::Rack.configure_app(
:application => 'testapp',
:version => 2)
require 'testapp.rb'
run Sinatra::Application
# testapp.rb
require 'rubygems'
@msassak
msassak / bad_gherkin.features
Created September 16, 2009 16:00
Possible Gherkin error scenarios
# It's difficult to decide what is invalid Gherkin, so I made this gist to try and figure it out
# Empty feature
Feature:
# Feature with GWT in desc
Feature: Suspicious
Given this is bad form
Whenever I do this
Then you should be suspicious because
irb(main):001:0> require 'cucumber'
=> true
irb(main):002:0> sm = Cucumber::StepMother.new
=> #<Cucumber::StepMother:0x1192ca0 @programming_languages=[], @adverbs=["Given", "When", "Then", "And", "But"], @unsupported_programming_languages=[], @language_map={}>
irb(main):003:0> sm.load_code_files("./cuke_steps.rb")
D, [2009-09-16T17:09:05.531395 #8769] DEBUG -- : Code:
D, [2009-09-16T17:09:05.535501 #8769] DEBUG -- : * ./cuke_steps.rb
D, [2009-09-16T17:09:05.535807 #8769] DEBUG -- :
# This will work
x = nil
a = lambda {
if x.nil?
"x is nil, as it should be"
else
"somehow x = #{x}"
end
}
class CommandParser
%%{
machine wire_command_parser;
action parse_error {
@sess.parse_error
}
action command {
command = data[0..p].pack("c*")
msassak@xanthippe:~/Work/gherkin(benchmarks) $ rake bench:tt
(in /Users/msassak/Work/gherkin)
grep Feature /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
1999
grep Scenario /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
10095
grep Given /Users/msassak/Work/gherkin/tasks/bench/generated/* | wc -l
60722
user system total real
183.780000 0.590000 184.370000 (185.416678)
========================================
============= Rails v2.1.0 =============
========================================
git checkout .
git clean -d -f
Note: moving to "v2.1.0" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
HEAD is now at 71528b1... Previously we only added the "lib" subdirectory to the load path when setting up gem dependencies for frozen gems. Now we add the "ext" subdirectory as well for those gems which have compiled C extensions as well. [Wincent Colaiuta]
# Valid in Gherkin, not in Treetop
Feature: test
Scenario Outline: a test
This table interpreted as part of the outline description
Examples:
| one | two | # Treetop fails here
| foo | bar |
Given <something> # Steps start the body of the scenario outline
And something <else>