Permalink
Browse files

Ensure testing with multiple rubies

  • Loading branch information...
1 parent b6ee8e6 commit 1cd1d0cbc5970d86b7e8fb02dc9f236c4fff7c62 @txus txus committed Jan 18, 2012
Showing with 22 additions and 19 deletions.
  1. +1 −2 .travis.yml
  2. +2 −0 Readme.md
  3. +10 −10 test/gherkin/ast_test.rb
  4. +9 −7 test/gherkin/parser/lexer_test.rb
View
3 .travis.yml
@@ -1,8 +1,7 @@
env:
- - RBXOPT=-X19 JRUBY_OPTS="--1.9"
+ - RBXOPT=-X19
rvm:
- 1.9.2
- 1.9.3
- ruby-head
- rbx-head
- - jruby
View
2 Readme.md
@@ -1,6 +1,8 @@
# gherkin-ruby
Gherkin-ruby is a pure Ruby implementation of a [Gherkin](http://github.com/cucumber/gherkin) parser.
+Tested with MRI 1.9.2, 1.9.3, ruby-head and Rubinius head.
+
## Why this one over the official, fast, Ragel-based Gherkin parser?
* Less than 200 LOC.
View
20 test/gherkin/ast_test.rb
@@ -52,29 +52,29 @@ module AST
end
describe Scenario do
- let(:steps) do
- steps = [
+ before do
+ @steps = [
OpenStruct.new(line: 4),
OpenStruct.new(line: 5),
]
end
it 'is Enumerable' do
- instance = Scenario.new("Name", steps)
- instance.each.to_a.must_equal steps
+ instance = Scenario.new("Name", @steps)
+ instance.each.to_a.must_equal @steps
end
it 'has tags' do
tags = ['javascript', 'wip']
- instance = Scenario.new("Name", steps, tags)
+ instance = Scenario.new("Name", @steps, tags)
instance.tags.must_equal tags
end
end
describe Background do
- let(:steps) do
- steps = [
+ before do
+ @steps = [
OpenStruct.new(line: 4),
OpenStruct.new(line: 5),
]
@@ -85,13 +85,13 @@ module AST
end
it 'is Enumerable' do
- instance = Background.new(steps)
- instance.each.to_a.must_equal steps
+ instance = Background.new(@steps)
+ instance.each.to_a.must_equal @steps
end
describe 'when there are background steps' do
it 'records line' do
- instance = Background.new(steps)
+ instance = Background.new(@steps)
instance.pos("file", 3)
instance.line.must_equal 3
end
View
16 test/gherkin/parser/lexer_test.rb
@@ -2,22 +2,24 @@
module Gherkin
describe Parser do
- let(:lexer) { Parser.new }
+ before do
+ @lexer = Parser.new
+ end
it 'ignores commments' do
- lexer.tokenize("# this is a comment").must_equal []
+ @lexer.tokenize("# this is a comment").must_equal []
end
it 'parses newlines' do
- lexer.tokenize("\n\n").must_equal [[:NEWLINE, "\n"], [:NEWLINE, "\n"]]
+ @lexer.tokenize("\n\n").must_equal [[:NEWLINE, "\n"], [:NEWLINE, "\n"]]
end
it 'parses text and strips it' do
- lexer.tokenize(" Arbitrary text ").must_equal [[:TEXT, "Arbitrary text"]]
+ @lexer.tokenize(" Arbitrary text ").must_equal [[:TEXT, "Arbitrary text"]]
end
it 'parses tags' do
- lexer.tokenize("@javascript @wip").must_equal [
+ @lexer.tokenize("@javascript @wip").must_equal [
[:TAG, "javascript"],
[:TAG, "wip"],
]
@@ -27,15 +29,15 @@ module Gherkin
%w(Feature: Background: Scenario:).each do |keyword|
it "parses #{keyword}:" do
name = keyword[0..-2]
- lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]]
+ @lexer.tokenize(keyword).must_equal [[name.upcase.to_sym, name]]
end
end
end
describe 'Step keywords' do
%w(Given When Then And But).each do |keyword|
it "parses #{keyword}" do
- lexer.tokenize(keyword).must_equal [[keyword.upcase.to_sym, keyword]]
+ @lexer.tokenize(keyword).must_equal [[keyword.upcase.to_sym, keyword]]
end
end
end

0 comments on commit 1cd1d0c

Please sign in to comment.