Sha256: 83816a03ae3f6d37f3abf5fb2fcb19e06b42f8d234be2bdce8f3c24c56d92c2b

Contents?: true

Size: 847 Bytes

Versions: 25

Compression:

Stored size: 847 Bytes

Contents

require 'stringio'
require 'gherkin/formatter/json_formatter'
require 'gherkin/listener/formatter_listener'

# Monkey patching so that Hash.to_json has a predictable result.
class Hash
  alias orig_keys keys
  def keys
    orig_keys.sort
  end
end

Given /^a JSON formatter$/ do
  @io = StringIO.new
  @formatter = Gherkin::Formatter::JSONFormatter.new(@io)
end

Then /^the outputted JSON should be:$/ do |expected_json|
  require 'json'
  expected = JSON.pretty_generate(JSON.parse(expected_json))
  actual   = JSON.pretty_generate(JSON.parse(@io.string))
  announce actual
  begin
    actual.should == expected
  rescue # Haven't figured out how to order Hash on JRuby (JSON pure). Retry with possibly worse error message.
    expected = JSON.parse(expected_json)
    actual   = JSON.parse(@io.string)
    actual.should == expected
  end
end



Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
gherkin-2.1.4 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.4-i386-mswin32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.4-i386-mingw32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.4-universal-dotnet features/step_definitions/json_formatter_steps.rb
gherkin-2.1.4-java features/step_definitions/json_formatter_steps.rb
gherkin-2.1.3 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.3-i386-mswin32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.3-i386-mingw32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.3-universal-dotnet features/step_definitions/json_formatter_steps.rb
gherkin-2.1.3-java features/step_definitions/json_formatter_steps.rb
gherkin-2.1.2 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.2-i386-mswin32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.2-i386-mingw32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.2-universal-dotnet features/step_definitions/json_formatter_steps.rb
gherkin-2.1.2-java features/step_definitions/json_formatter_steps.rb
gherkin-2.1.1 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.1-i386-mswin32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.1-i386-mingw32 features/step_definitions/json_formatter_steps.rb
gherkin-2.1.1-universal-dotnet features/step_definitions/json_formatter_steps.rb
gherkin-2.1.1-java features/step_definitions/json_formatter_steps.rb