Sha256: 25cd6591a0866a6935582edcc808091b955888716ec30e8fd0e600988d9deaae

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

require 'spec_helper.rb'

def read_file(dir, filename)
  data = File.read dir.join("#{filename}.json")
  JSON.parse(data)
end

RSpec.describe "test_suite " do

  %w[ positive negative ].each do |spec_dir|
    context spec_dir do
      dirs = Pathname.new("#{SPEC_ROOT}/test_suite/#{spec_dir}").children.select(&:directory?)
      dirs.each do |dir|
        it dir.basename do
          rules = read_file(dir, "rules")
          input = read_file(dir, "input")

          validator = LIVR::Validator.new(rules)
          result = validator.validate(input)
          errors = validator.get_errors

          if spec_dir == 'positive'
            expected_result = read_file(dir, "output")
            expect(result).to eq(expected_result)
          else
            expected_errors = read_file(dir, "errors")
            expect(errors).to eq(expected_errors)
          end
        end
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ruby-livr-2.0.0 spec/01-test_suite_spec.rb
livr2-2.0.0 spec/01-test_suite_spec.rb