Sha256: 39cd8610c640b24756378e20ec4bfe0de38b6a0df03db0bb2b568e9b62b96010

Contents?: true

Size: 1.42 KB

Versions: 48

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', 0)
      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

48 entries across 48 versions & 2 rubygems

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