Add a spec and some minor corrections
This commit is contained in:
parent
d555556e54
commit
94f317673f
6 changed files with 46 additions and 29 deletions
28
Rakefile
28
Rakefile
|
@ -1,21 +1,21 @@
|
|||
require "bundler/gem_tasks"
|
||||
require "rake/testtask"
|
||||
require 'rubocop/rake_task'
|
||||
# require 'rubocop/rake_task'
|
||||
|
||||
# Add additional test suite definitions to the default test task here
|
||||
namespace :spec do
|
||||
desc 'Runs RuboCop on specified directories'
|
||||
RuboCop::RakeTask.new(:rubocop) do |task|
|
||||
# Dirs: app, lib, test
|
||||
task.patterns = ['exe/**/*.rb', 'lib/**/*.rb', 'spec/**/*_spec.rb']
|
||||
|
||||
# Make it easier to disable cops.
|
||||
task.options << "--display-cop-names"
|
||||
|
||||
# Abort on failures (fix your code first)
|
||||
task.fail_on_error = true
|
||||
end
|
||||
end
|
||||
# namespace :spec do
|
||||
# desc 'Runs RuboCop on specified directories'
|
||||
# RuboCop::RakeTask.new(:rubocop) do |task|
|
||||
# # Dirs: app, lib, test
|
||||
# task.patterns = ['exe/**/*.rb', 'lib/**/*.rb', 'spec/**/*_spec.rb']
|
||||
#
|
||||
# # Make it easier to disable cops.
|
||||
# task.options << "--display-cop-names"
|
||||
#
|
||||
# # Abort on failures (fix your code first)
|
||||
# task.fail_on_error = true
|
||||
# end
|
||||
# end
|
||||
|
||||
Rake::TestTask.new(:spec) do |t|
|
||||
t.libs << "spec"
|
||||
|
|
|
@ -16,12 +16,14 @@ module Mm2ep
|
|||
def parse(infile, *vars)
|
||||
line = File.read(infile).gsub(/\n/,'')
|
||||
parser = Parser.new(Lexer.new)
|
||||
vartruc = {}
|
||||
tab_vars = {}
|
||||
vars.each do |var|
|
||||
vartruc[var.split('=')[0]] = var.split('=')[1]
|
||||
tab_vars[var.split('=')[0]] = var.split('=')[1]
|
||||
end
|
||||
puts vartruc
|
||||
parser.names(vartruc)
|
||||
|
||||
# Give vars name and value from shell command to parser
|
||||
parser.names(tab_vars)
|
||||
|
||||
token = parser.parse(line.chomp, true)
|
||||
pp token
|
||||
puts "RAW : #{line}"
|
||||
|
|
|
@ -5,6 +5,7 @@ module Mm2epDepend
|
|||
# Your code goes here...
|
||||
end
|
||||
|
||||
require 'rly'
|
||||
|
||||
require 'mm2ep_depend/lexer'
|
||||
require 'mm2ep_depend/parser'
|
||||
|
|
20
spec/mm2ep_depend/parser_spec.rb
Normal file
20
spec/mm2ep_depend/parser_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
require 'mm2ep_depend'
|
||||
|
||||
describe Mm2ep::Depend::Parser do
|
||||
|
||||
it 'has to evaluate expression and give right answer' do
|
||||
line = File.read(testfile('test2.txt')).gsub(/\n/,'')
|
||||
parser = Mm2ep::Depend::Parser.new(Mm2ep::Depend::Lexer.new)
|
||||
parser.names({'truc_bidule' => 'true',
|
||||
'machin' => 'true',
|
||||
'truc' => 'false'
|
||||
})
|
||||
token = parser.parse(line.chomp)
|
||||
assert_equal(false, token.compute)
|
||||
end
|
||||
|
||||
# it 'has to be true' do
|
||||
#
|
||||
# end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
require "test_helper"
|
||||
|
||||
class Mm2epDependTest < Minitest::Test
|
||||
def test_that_it_has_a_version_number
|
||||
refute_nil ::Mm2epDepend::VERSION
|
||||
end
|
||||
|
||||
def test_it_does_something_useful
|
||||
assert false
|
||||
end
|
||||
end
|
|
@ -2,3 +2,8 @@ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
|||
require "mm2ep_depend"
|
||||
|
||||
require "minitest/autorun"
|
||||
require 'pathname'
|
||||
|
||||
def testfile(name)
|
||||
Pathname.new(__FILE__).dirname.join('files', name)
|
||||
end
|
Loading…
Reference in a new issue