Sha256: 4927b064ebc33bc8ca75c4bae9d0124e39ef9998c81c0b85ecf0fec8e63ed1c7

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require '_helper'
require 'unindent'

class RedSnowParseResultTest < Test::Unit::TestCase

  context "Simple API" do
    setup do
      @result = RedSnow.parse("# My API")
    end

    should "have name" do
      assert_equal "My API", @result.ast.name
    end

    should "don't have error" do
      assert_equal 0, @result.error[:ok]
    end
  end

  context "Simple API with warning" do
    setup do
      @source = <<-STR
        FORMAT: 1A
        # My API
        ## GET /
      STR
      @result = RedSnow.parse(@source.unindent)
    end

    should "have name" do
      assert_equal "My API", @result.ast.name
    end

    should "don't have error" do
      assert_equal 0, @result.error[:code]
    end

    should "have some warning" do
      assert_equal RedSnow::WarningCodes::EmptyDefinitionWarning, @result.warnings[0][:code]
      assert_equal "no response defined for 'GET /'", @result.warnings[0][:message]

      assert_equal 20, @result.warnings[0][:location][0].index
      assert_equal 9, @result.warnings[0][:location][0].length

      assert_equal "## GET /\n", @source.unindent[20..@source.unindent.length]
      # Line in blueprint
      assert_equal 3, @source.unindent[0..20].lines.count
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redsnow-0.1.6 test/redsnow_parseresult_test.rb
redsnow-0.1.5 test/redsnow_parseresult_test.rb
redsnow-0.1.4 test/redsnow_parseresult_test.rb
redsnow-0.1.3 test/redsnow_parseresult_test.rb
redsnow-0.1.2 test/redsnow_parseresult_test.rb
redsnow-0.1.1 test/redsnow_parseresult_test.rb
redsnow-0.1.0 test/redsnow_parseresult_test.rb
redsnow-0.0.8 test/redsnow_parseresult_test.rb