Skip to content

Commit

Permalink
Updated tests #142
Browse files Browse the repository at this point in the history
  • Loading branch information
Beniamin Sarkisyan committed Sep 3, 2016
1 parent 6541fc3 commit 8202296
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions spec/gen_command_table_parameters_formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
require_relative 'spec_helper'
require 'json'
require 'generamba/code_generation/code_module.rb'
require 'generamba/constants/rambafile_constants.rb'

describe 'GenCommandTableParametersFormatter' do

describe 'method prepare_parameters_for_displaying' do
it 'should convert array of hash to array of strings' do
expected_string = "name1\nname2"
expected_params = {}

parameters = {
'templates' => [
{'name' => 'name1', 'path' => 'path1'},
{'name' => 'name2', 'path' => 'path2'}
]
}
expected_params['Targets'] = 'Target'
expected_params['Module path'] = Pathname.new('Project/name')
expected_params['Module group path'] = Pathname.new('Project/Modules/name')
expected_params['Test targets'] = 'TargetTests'
expected_params['Test file path'] = Pathname.new('ProjectTests/name')
expected_params['Test group path'] = Pathname.new('ProjectTests/Modules/name')
expected_params['Template'] = 'Template'
expected_params['Custom parameters'] = {:key => 'value'}.to_json

params = Generamba::GenCommandTableParametersFormatter.prepare_parameters_for_displaying(parameters)
rambafile = {}
rambafile[Generamba::PROJECT_NAME_KEY] = 'project'
rambafile[Generamba::PROJECT_FILE_PATH_KEY] = 'file_path'
rambafile[Generamba::PROJECT_GROUP_PATH_KEY] = 'group_path'
rambafile[Generamba::PROJECT_TARGET_KEY] = 'Target'
rambafile[Generamba::PROJECT_FILE_PATH_KEY] = 'Project'
rambafile[Generamba::PROJECT_GROUP_PATH_KEY] = 'Project/Modules'
rambafile[Generamba::TEST_TARGET_KEY] = 'TargetTests'
rambafile[Generamba::TEST_FILE_PATH_KEY] = 'ProjectTests'
rambafile[Generamba::TEST_GROUP_PATH_KEY] = 'ProjectTests/Modules'

expect(params['templates']).to eq(expected_string)
options = {}
options[:custom_parameters] = {:key => 'value'}

code_module = Generamba::CodeModule.new('name', 'description', rambafile, options)
template_name = 'Template'

params = Generamba::GenCommandTableParametersFormatter.prepare_parameters_for_displaying(code_module, template_name)

expect(params).to eq(expected_params)
end
end

Expand Down

0 comments on commit 8202296

Please sign in to comment.