Upgrade tests to minispec 6 syntax

This commit is contained in:
Glenn Y. Rolland 2019-12-21 20:31:16 +01:00
parent f9c3d01625
commit 5af8b84770
4 changed files with 26 additions and 8 deletions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
require 'namarara'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
require 'namarara'
@ -13,8 +15,8 @@ describe Namarara::Parser do
errors = token.errors.select do |el|
el.is_a? Namarara::Errors::VarNotDefined
end
errors.size.must_equal 1
errors[0].var.must_equal 'character'
_(errors.size).must_equal 1
_(errors[0].var).must_equal 'character'
end
it 'has to report vars which are not defined' do
@ -24,9 +26,9 @@ describe Namarara::Parser do
errors = token.errors.select do |el|
el.is_a? Namarara::Errors::VarNotDefined
end
errors.size.must_equal 2
errors[0].var.must_equal 'a_girl_has_no_name'
errors[1].var.must_equal 'character'
_(errors.size).must_equal 2
_(errors[0].var).must_equal 'a_girl_has_no_name'
_(errors[1].var).must_equal 'character'
end
it 'has to report invalid_grammar' do
@ -35,13 +37,13 @@ describe Namarara::Parser do
parser.names = { 'a_girl_has_no_name' => true, 'character' => 'Arya Stark' }
token = parser.parse(line)
parser.check_grammar line, token
token.errors.select do |elem|
_(token.errors.select do |elem|
elem.is_a? Namarara::Errors::InvalidGrammar
end.size.must_equal 1
end.size).must_equal 1
end
it 'has to be nil when grammar is completely invalid' do
line = 'false = "Arya"'
line = 'false / "Arya"'
parser.names = {}
token = parser.parse(line)
parser.check_grammar line, token

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
require 'namarara'

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'spec_helper'
require 'namarara'
@ -158,4 +160,14 @@ describe Namarara::Parser do
token = parser.parse(line)
assert_equal(false, token.compute)
end
it 'has to convert to true AND true and return true' do
line = 'a_girl_has_no_name AND character'
parser.names = {
'a_girl_has_no_name' => 3,
'character' => 1
}
token = parser.parse(line)
assert_equal(true, token.compute)
end
end