Sha256: 964bb8a04af55bde7689d39f9e5fda6a10092959e253f87de893302e7d981cf7

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

#encoding: utf-8
require 'ap'
require 'spec_helper'
require 'gherkin/json_parser'
require 'gherkin/formatter/json_formatter'

module Gherkin
  describe JSONParser do 

    def check_json(json)
      io = StringIO.new
      f = Formatter::JSONFormatter.new(io)
      p = JSONParser.new(f)
      p.parse(json, 'unknown.json')
      expected = JSON.parse(json)
      actual   = JSON.parse(io.string)

      actual.should == expected
    end

    it "should parse a barely empty feature" do
      check_json(%{{
        "keyword": "Feature", 
        "name": "One", 
        "description": "", 
        "line" : 3 
      }})
    end

    it "should parse feature with tags and one scenario" do
      check_json(%{{
        "tags": [
          {
            "name": "@foo",
            "line": 22
          }
        ],
        "keyword": "Feature", 
        "name": "One", 
        "description": "", 
        "line": 3,
        "elements": [
          {
            "type": "scenario",
            "steps": [
              {
                "name": "Hello",
                "multiline_arg": {
                  "type": "table",
                  "value": [
                    {
                      "cells": ["foo", "bar"]
                    }
                  ]
                }
              }
            ]
          }
        ]
      }})
    end

    it "shoud parse a complex feature" do
      check_json(fixture("complex.json"))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gherkin-2.2.0 spec/gherkin/json_parser_spec.rb
gherkin-2.2.0-i386-mswin32 spec/gherkin/json_parser_spec.rb
gherkin-2.2.0-i386-mingw32 spec/gherkin/json_parser_spec.rb
gherkin-2.2.0-universal-dotnet spec/gherkin/json_parser_spec.rb
gherkin-2.2.0-java spec/gherkin/json_parser_spec.rb