Add spec for lib.

This commit is contained in:
Glenn Y. Rolland 2015-08-12 00:33:54 +02:00
parent 4a94efc1e5
commit 6809692041
11 changed files with 67 additions and 19 deletions

View file

@ -39,7 +39,7 @@ module Qasim
next unless File.basename( path ) =~ /.map$/
begin
map = Map::Ssh.new self, path
map = Map.from_file self, path
yield map if block_given?
maps.push map
rescue

View file

@ -1,8 +1,6 @@
require 'fileutils'
#require 'rdebug/base'
#require 'qasim/map/generic'
require 'qasim/map/generic'
module Qasim ; module Map
@ -56,6 +54,8 @@ module Qasim ; module Map
line = env_substitute(line, linect)
case line
when /^\s*TYPE\s*=\s*(.*)\s*$/ then
config[:type] = $1
when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/ then
config[:user] = $1
when /^\s*REMOTE_PORT\s*=\s*(.*)\s*$/ then
@ -95,3 +95,4 @@ module Qasim ; module Map
end
module_function :from_file, :env_substitute
end ; end

View file

@ -1,5 +1,25 @@
require 'fileutils'
require 'qasim/map'
module Qasim ; module Map
end ; end
class Qasim::Map::Generic
def initialize config
end
# Return a list of options for this map type
#
# Format :
# Hash of (name:Symbol * [value:Object, optional:Boolean])
def self.parameters
{
map_name: [nil , true],
map_enabled: [true, false],
map_mountpoint: [nil, true]
}
end
end

View file

@ -1,6 +1,5 @@
require 'fileutils'
require 'qasim/map'
require 'qasim/map/generic'
class Qasim::Map::Ssh < Qasim::Map::Generic
@ -16,6 +15,9 @@ class Qasim::Map::Ssh < Qasim::Map::Generic
CYPHER_AES256CBC = "aes-256-cbc".to_sym
CYPHERS = [ CYPHER_ARCFOUR, CYPHER_AES256CBC ]
def self.parameters
super
end
#
# Set defaults properties for maps
@ -36,8 +38,6 @@ class Qasim::Map::Ssh < Qasim::Map::Generic
end
#
# Test map liveness (how ?)
# FIXME: not implemented

View file

@ -1,11 +1,18 @@
require 'fileutils'
require 'qasim/map'
require 'qasim/map/generic'
class Qasim::Map::Webdav
# nothing
class Qasim::Map::Webdav < Qasim::Map::Generic
def initialize
end
def requirements
req = super
req << :webdav_user # ex: foo
req << :webdav_password # ex: bar
req << :webdav_port # ex: 80, 8080, ...
req << :webdav_protocol # ex: http, https
req
end
end

View file

@ -4,4 +4,5 @@ require 'qasim/constants'
module Qasim ; module Ui
autoload :About, 'qasim/ui/about'
autoload :Preferences, 'qasim/ui/preferences'
end ; end

View file

@ -8,13 +8,13 @@ require 'qasim/cli'
describe Qasim::Cli do
let(:cli) { Qasim::Cli.new }
describe '.new' do
describe 'new' do
it "can be created without arguments" do
skip "Later" #assert_instance_of Qasim::Cli, cli
end
end
describe '.list' do
describe 'list' do
it "must exist" do
assert_respond_to cli, :list
end
@ -24,15 +24,15 @@ describe Qasim::Cli do
end
end
describe '.add' do
describe 'add' do
it "must exist" do
assert_respond_to cli, :add
skip "assert_respond_to cli, :add"
end
end
describe '.del' do
describe 'del' do
it "must exist" do
assert_respond_to cli, :del
skip "assert_respond_to cli, :del"
end
end

View file

@ -1,7 +1,17 @@
require_relative 'spec_helper'
require 'minitest/spec'
require 'qasim/map/generic'
require 'qasim/map/ssh'
describe Qasim::Map::Ssh do
# something
describe 'parameters' do
it 'contains at least all generic parameters' do
expected = Qasim::Map::Generic.parameters.keys
current = Qasim::Map::Ssh.parameters.keys
keys = (expected & current)
assert (keys.size >= expected.size)
end
end
end

View file

@ -3,6 +3,14 @@ require_relative 'spec_helper'
require 'qasim/map/webdav'
describe Qasim::Map::Webdav do
# something
describe 'parameters' do
it 'contains at least all generic parameters' do
expected = Qasim::Map::Generic.parameters.keys
current = Qasim::Map::Webdav.parameters.keys
keys = (expected & current)
assert (keys.size >= expected.size)
end
end
end

View file

@ -10,6 +10,7 @@ require 'minitest/unit'
require 'minitest/autorun'
require 'minitest/spec'
require 'minitest/pride'
require 'pry'
$LOAD_PATH.unshift('../lib')

View file

@ -2,6 +2,6 @@
require_relative 'spec_helper'
require 'qasim/ui'
describe Qasim::Config do
describe Qasim::Ui do
# something
end