Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
before_install: gem install bundler -v 1.3.5
rvm:
- 2.1.0
- 2.0.0
- 1.9.3
- jruby
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Build Status](https://secure.travis-ci.org/cucumber/gherkin.png)](http://travis-ci.org/cucumber/gherkin)
[![Gem Version](https://badge.fury.io/rb/gherkin.svg)](http://badge.fury.io/rb/gherkin)
[![Dependency Status](https://gemnasium.com/cucumber/gherkin.png)](https://gemnasium.com/cucumber/gherkin)
[![Code Climate](https://codeclimate.com/github/cucumber/gherkin.png)](https://codeclimate.com/github/cucumber/gherkin)

A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two things:

Expand All @@ -7,7 +10,7 @@ A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two

Supported platforms:

* [Ruby](https://rubygems.org/gems/gherkin) 1.9.3-2.0.0 (MRI, JRuby, REE, Rubinius)
* [Ruby](https://rubygems.org/gems/gherkin) 1.9.3, 2.0.0, 2.1.0 (MRI, JRuby, REE, Rubinius)
* [Pure Java](http://search.maven.org/#search%7Cga%7C1%7Cgherkin) (jar file)
* [JavaScript](http://search.npmjs.org/#/gherkin) (Tested with V8/node.js/Chrome, but might work on other JavaScript engines)
* [.NET](http://nuget.org/List/Packages/gherkin) (dll file)
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/gherkin_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

Then "there should be no parse errors" do
@formatter.errors.should == []
expect(@formatter.errors).to eq []
end

Then /^there should be a parse error on (line \d+)$/ do |line|
Expand Down
5 changes: 1 addition & 4 deletions features/step_definitions/json_formatter_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ def keys
puts MultiJson.dump(MultiJson.load(actual_json), :pretty => true)
expected = MultiJson.load(expected_json)
actual = MultiJson.load(actual_json)
actual.should == expected
expect(actual).to eq expected
end



2 changes: 1 addition & 1 deletion features/step_definitions/json_parser_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
end

Then /^the outputted text should be:$/ do |expected_text|
@io.string.strip.should == expected_text
expect(@io.string.strip).to eq expected_text
end
8 changes: 4 additions & 4 deletions features/step_definitions/pretty_formatter_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'gherkin/json_parser'

module PrettyPlease

def pretty_machinery(gherkin, feature_path)
io = StringIO.new
formatter = Gherkin::Formatter::PrettyFormatter.new(io, true, false)
Expand All @@ -26,10 +26,10 @@ def json_machinery(gherkin, feature_path)
pretty_formatter = Gherkin::Formatter::PrettyFormatter.new(io, true, false)
json_parser = Gherkin::JSONParser.new(pretty_formatter, pretty_formatter)
json_parser.parse(json.string)

io.string
end

def parse(parser, gherkin, feature_path)
begin
parser.parse(gherkin, feature_path, 0)
Expand Down Expand Up @@ -63,7 +63,7 @@ def parse(parser, gherkin, feature_path)
next if feature_path =~ /iso-8859-1\.feature/
original = pretty_machinery(IO.read(feature_path), feature_path)
via_machinery = self.__send__("#{machinery}_machinery", original, feature_path)
via_machinery.should == original
expect(via_machinery).to eq original
rescue RSpec::Expectations::ExpectationNotMetError => e
announce "=========="
announce feature_path
Expand Down
30 changes: 15 additions & 15 deletions spec/gherkin/c_lexer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#encoding: utf-8
unless defined?(JRUBY_VERSION)
require 'spec_helper'
require 'gherkin_lexer_en'
require 'spec_helper'
require 'gherkin_lexer_en'

module Gherkin
module Lexer
describe "C Lexer" do
before do
@listener = Gherkin::SexpRecorder.new
@lexer = Gherkin::CLexer::En.new(@listener)
end
module Gherkin
module Lexer
describe "C Lexer" do
before do
@listener = Gherkin::SexpRecorder.new
@lexer = Gherkin::CLexer::En.new(@listener)
end

it_should_behave_like "a Gherkin lexer"
it_should_behave_like "a Gherkin lexer lexing tags"
it_should_behave_like "a Gherkin lexer lexing doc_strings"
it_should_behave_like "a Gherkin lexer lexing rows"
it_should_behave_like "encoding"
it_should_behave_like "a Gherkin lexer"
it_should_behave_like "a Gherkin lexer lexing tags"
it_should_behave_like "a Gherkin lexer lexing doc_strings"
it_should_behave_like "a Gherkin lexer lexing rows"
it_should_behave_like "encoding"
end
end
end
end
end
16 changes: 8 additions & 8 deletions spec/gherkin/formatter/ansi_escapes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ module Formatter
describe "instance methods" do
include AnsiEscapes

it "failed should be red" do
failed.should == "\e[31m"
it "failed is red" do
expect(failed).to eq("\e[31m")
end

it "failed_arg should be red bold" do
failed_arg.should == "\e[31m\e[1m"
it "failed_arg is red bold" do
expect(failed_arg).to eq("\e[31m\e[1m")
end
end

describe "class methods" do
subject { AnsiEscapes }

it "failed should be red" do
subject.failed.should == "\e[31m"
it "failed is red" do
expect(subject.failed).to eq("\e[31m")
end

it "failed_arg should be red bold" do
subject.failed_arg.should == "\e[31m\e[1m"
it "failed_arg is red bold" do
expect(subject.failed_arg).to eq("\e[31m\e[1m")
end
end
end
Expand Down
74 changes: 37 additions & 37 deletions spec/gherkin/formatter/filter_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,120 +23,120 @@ def verify_filter(filters, *line_ranges)
path = File.dirname(__FILE__) + "/../fixtures/" + file
source = File.new(path).read + "# __EOF__"
parser.parse(source, path, 0)

source_lines = source.split("\n")
expected = (line_ranges.map do |line_range|
source_lines[(line_range.first-1..line_range.last-1)]
end.flatten).join("\n").gsub(/# __EOF__/, '')
io.string.strip.should == expected.strip
expect(io.string.strip).to eq(expected.strip)
end

context "invalid mix" do
it "should throw exception on different filters" do
lambda do
it "throws exception on different filters" do
expect do
verify_filter(['@tag1', /regexp/, 88], 1..61)
end.should raise_exception(/Inconsistent filters/)
end.to raise_exception(/Inconsistent filters/)
end
end

context "tags" do
it "should filter on feature tag" do
it "filters on feature tag" do
verify_filter(['@tag1'], 1..61)
end

it "should filter on scenario tag" do
it "filters on scenario tag" do
verify_filter(['@tag4'], 1..19)
end

it "should filter on abother scenario tag" do
it "filters on abother scenario tag" do
verify_filter(['@tag3'], 1..37)
end

it "should filter on scenario outline tag" do
it "filters on scenario outline tag" do
verify_filter(['@more'], 1..14, 46..61)
end

it "should filter on first examples tag" do
it "filters on first examples tag" do
verify_filter(['@neat'], 1..14, 46..55)
end

it "should filter on second examples tag" do
it "filters on second examples tag" do
verify_filter(['@hamster'], 1..14, 46..49, 56..61)
end

it "should not replay examples from ignored scenario outline" do
it "does not replay examples from ignored scenario outline" do
self.file = 'scenario_outline_with_tags.feature'
verify_filter(['~@wip'], 1..2, 12..14)
end

it "should not replay examples from ignored scenario outline" do
it "does not replay examples from ignored scenario outline" do
self.file = 'scenario_outline_with_tags.feature'
verify_filter(['~@wip'], 1..2, 12..14)
end

it "should not choke on examples with only header" do
it "does not choke on examples with only header" do
self.file = 'examples_with_only_header.feature'
verify_filter(['@failing'], 1..7, 12..15)
end
end

context "names" do
it "should filter on scenario name" do
it "filters on scenario name" do
verify_filter([/Reading a Scenario/], 1..19)
end

it "should filter on scenario outline name" do
it "filters on scenario outline name" do
verify_filter([/More/], 1..14, 46..61)
end

it "should filter on first examples name" do
it "filters on first examples name" do
verify_filter([/Neato/], 1..14, 46..55)
end

it "should filter on second examples name" do
it "filters on second examples name" do
verify_filter([/Rodents/], 1..14, 46..49, 56..61)
end

it "should filter on various names" do
it "filters on various names" do
self.file = 'hantu_pisang.feature'
verify_filter([/Pisang/], 1..8, 19..32)
end

it "should filter on background name" do
it "filters on background name" do
self.file = 'hantu_pisang.feature'
verify_filter([/The background/], 1..5)
end

it "should not choke on examples with only header" do
it "does not choke on examples with only header" do
self.file = 'examples_with_only_header.feature'
verify_filter([/B/], 1..7, 12..15)
end
end

context "lines" do
context "on the same line as feature element keyword" do
it "should filter on scenario without line" do
it "filters on scenario without line" do
self.file = 'scenario_without_steps.feature'
verify_filter([3], 1..4)
end

it "should filter on scenario line" do
it "filters on scenario line" do
verify_filter([16], 1..19)
end

it "should filter on scenario outline line" do
it "filters on scenario outline line" do
verify_filter([47], 1..14, 46..61)
end

it "should filter on first examples line" do
it "filters on first examples line" do
verify_filter([51], 1..14, 46..55)
end

it "should filter on second examples line" do
it "filters on second examples line" do
verify_filter([57], 1..14, 46..49, 56..61)
end

it "should not choke on examples with only header" do
it "does not choke on examples with only header" do
self.file = 'examples_with_only_header.feature'
verify_filter([13], 1..7, 12..15)
verify_filter([14], 1..7, 12..15)
Expand All @@ -147,54 +147,54 @@ def verify_filter(filters, *line_ranges)
verify_filter([14], 1..2, 6..12, 14..14)
end

it "should fix issue 145 more tests" do
it "fixes issue 145 more tests" do
self.file = 'issue_145.feature'
verify_filter([13,15,18], 1..2, 6..13, 15..15, 16..18)
end
end

context "on the same line as step keyword" do
it "should filter on step line" do
it "filters on step line" do
verify_filter([17], 1..19)
end

it "should filter on scenario outline line" do
it "filters on scenario outline line" do
verify_filter([48], 1..14, 46..61)
end
end

context "on examples header line" do
it "should filter on first table" do
it "filters on first table" do
verify_filter([52], 1..14, 46..55)
end

it "should filter on second table" do
it "filters on second table" do
verify_filter([58], 1..14, 46..49, 56..61)
end
end

context "on examples example line" do
it "should filter on first table" do
it "filters on first table" do
verify_filter([53], 1..14, 46..53, 55..55)
end
end

context "on tag line" do
it "should filter on first tag" do
it "filters on first tag" do
verify_filter([15], 1..19)
end
end

context "multiline argument" do
it "should filter on table line" do
it "filters on table line" do
verify_filter([36], 1..14, 20..37)
end

it "should filter on first pystring quote" do
it "filters on first pystring quote" do
verify_filter([41], 1..14, 38..45)
end

it "should filter on last pystring quote" do
it "filters on last pystring quote" do
verify_filter([44], 1..14, 38..45)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/gherkin/formatter/json_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module Formatter
}
]
}
MultiJson.load(io.string).should == MultiJson.load(expected)
expect(MultiJson.load(io.string)).to eq(MultiJson.load(expected))
end

it "renders results as pretty json" do
Expand All @@ -121,7 +121,7 @@ module Formatter
}
]
}
io.string.should == MultiJson.dump(MultiJson.load(expected), :pretty => true)
expect(io.string).to eq(MultiJson.dump(MultiJson.load(expected), :pretty => true))
end

it 'supports append_duration' do
Expand Down Expand Up @@ -172,7 +172,7 @@ module Formatter
}
]
}
MultiJson.load(io.string).should == MultiJson.load(expected)
expect(MultiJson.load(io.string)).to eq(MultiJson.load(expected))
end
end
end
Expand Down
Loading