Sha256: f40d0b4e3b2d5914afd580034e0d5b87420c86c30489fd2cfe2e70b9e5906580

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 KB

Contents

require 'rubygems'
require 'bundler'
Bundler.setup

require 'gherkin'
require 'stringio'
require 'gherkin/sexp_recorder'
require 'gherkin/output_stream_string_io'
require 'gherkin/json'
require 'gherkin/shared/lexer_group'
require 'gherkin/shared/tags_group'
require 'gherkin/shared/py_string_group'
require 'gherkin/shared/row_group'

module GherkinSpecHelper
  def scan_file(file)
    @lexer.scan(fixture(file))
  end

  def fixture(file)
    File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read
  end

  def rubify_hash(hash)
    if defined?(JRUBY_VERSION)
      h = {}
      hash.keySet.each{|key| h[key] = hash[key]}
      h
    else
      hash
    end
  end
end

RSpec.configure do |c|
  c.include(GherkinSpecHelper)
end

# Allows comparison of Java List with Ruby Array (rows)
RSpec::Matchers.define :r do |expected|
  match do |row|
    def row.inspect
      "r " + self.map{|cell| cell}.inspect
    end
    row.map{|cell| cell}.should == expected
  end
end

RSpec::Matchers.define :a do |expected|
  match do |array|
    def array.inspect
      "a " + self.map{|e| e.to_sym}.inspect
    end
    array.map{|e| e.to_sym}.should == expected
  end
end

RSpec::Matchers.define :sym do |expected|
  match do |actual|
    expected.to_s == actual.to_s
  end
end

RSpec::Matchers.define :allow do |event|
  match do |parser|
    parser.expected.index(event)
  end  
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
gherkin-2.2.8 spec/spec_helper.rb
gherkin-2.2.8-x86-mswin32 spec/spec_helper.rb
gherkin-2.2.8-x86-mingw32 spec/spec_helper.rb
gherkin-2.2.8-universal-dotnet spec/spec_helper.rb
gherkin-2.2.8-java spec/spec_helper.rb
gherkin-2.2.7 spec/spec_helper.rb
gherkin-2.2.7-x86-mswin32 spec/spec_helper.rb
gherkin-2.2.7-x86-mingw32 spec/spec_helper.rb
gherkin-2.2.7-universal-dotnet spec/spec_helper.rb
gherkin-2.2.7-java spec/spec_helper.rb
gherkin-2.2.6 spec/spec_helper.rb
gherkin-2.2.6-x86-mswin32 spec/spec_helper.rb
gherkin-2.2.6-x86-mingw32 spec/spec_helper.rb
gherkin-2.2.6-universal-dotnet spec/spec_helper.rb
gherkin-2.2.6-java spec/spec_helper.rb
gherkin-2.2.5 spec/spec_helper.rb
gherkin-2.2.5-x86-mswin32 spec/spec_helper.rb
gherkin-2.2.5-x86-mingw32 spec/spec_helper.rb
gherkin-2.2.5-universal-dotnet spec/spec_helper.rb
gherkin-2.2.5-java spec/spec_helper.rb