Sha256: 87028c81a0423b1bf4d395fc77d65955eb384846d5da095c03637014949c349f

Contents?: true

Size: 1.72 KB

Versions: 36

Compression:

Stored size: 1.72 KB

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'spec/gherkin'))
require 'gherkin'
require 'stringio'
require 'gherkin/sexp_recorder'
require 'rubygems'
require 'spec'
require 'spec/autorun'
require 'shared/lexer_spec'
require 'shared/tags_spec'
require 'shared/py_string_spec'
require 'shared/row_spec'

if defined?(JRUBY_VERSION)
  class OutputStreamStringIO < java.io.ByteArrayOutputStream
    def rewind
    end

    def read
      toString("UTF-8")
    end
  end
end

class StringIO
  class << self
    def new
      if defined?(JRUBY_VERSION)
        OutputStreamStringIO.new
      else
        super
      end
    end
  end
end

module GherkinSpecHelper
  def scan_file(file)
    @lexer.scan(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

Spec::Runner.configure do |c|
  c.include(GherkinSpecHelper)
end

# Allows comparison of Java List with Ruby Array (rows)
Spec::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

Spec::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

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

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

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
gherkin-1.0.18 spec/spec_helper.rb
gherkin-1.0.18-i386-mswin32 spec/spec_helper.rb
gherkin-1.0.18-i386-mingw32 spec/spec_helper.rb
gherkin-1.0.18-java spec/spec_helper.rb
gherkin-1.0.17 spec/spec_helper.rb
gherkin-1.0.17-i386-mswin32 spec/spec_helper.rb
gherkin-1.0.17-i386-mingw32 spec/spec_helper.rb
gherkin-1.0.17-java spec/spec_helper.rb
gherkin-1.0.16 spec/spec_helper.rb
gherkin-1.0.16-i386-mswin32 spec/spec_helper.rb
gherkin-1.0.16-i386-mingw32 spec/spec_helper.rb
gherkin-1.0.16-java spec/spec_helper.rb
gherkin-1.0.15 spec/spec_helper.rb
gherkin-1.0.15-i386-mswin32 spec/spec_helper.rb
gherkin-1.0.15-i386-mingw32 spec/spec_helper.rb
gherkin-1.0.15-java spec/spec_helper.rb
gherkin-1.0.14 spec/spec_helper.rb
gherkin-1.0.14-i386-mswin32 spec/spec_helper.rb
gherkin-1.0.14-i386-mingw32 spec/spec_helper.rb
gherkin-1.0.14-java spec/spec_helper.rb