blob: b6ce9a444fb2361b199426adcd6003992ea27f3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
require 'ayk/options'
#
describe AYK::Options do
#
describe 'simple usage' do
before(:all) do
@opt = AYK::Options.new 'Spec tests'
end
it "set option key1" do
@opt.o("key 1 doc", :key1, 666) { puts 'trigger' }
end
it "Options.get is private" do
lambda{ @opt.get(:key1) }.should raise_error NoMethodError
end
it "get option key1 through method missing" do
@opt.key1.should eql 666
end
it "get option key1 through []" do
@opt[:key1].should eql 666
end
it "get option nokey through method missing" do
@opt.nokey.should eql nil
end
it "get option nokey through []" do
@opt[:nokey].should eql nil
end
it "nice init" do
opts = AYK::Options.new('Spec nice') do |opt|
opt.dsl do
o 'var doc', :var, 666
end
end
opts.var.should eql 666
end
end
#
end
#
|