diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2009-09-21 12:41:17 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-30 08:08:14 +0200 | 
| commit | 238f5654b288bc947d4bf56c2e8c166173253ce1 (patch) | |
| tree | a4ba338105a989b56a189ada2e718a935fea982a /spec | |
| parent | ca5e28805ad8ca2c1ee55c20ef3109601dce678f (diff) | |
| download | ayk-238f5654b288bc947d4bf56c2e8c166173253ce1.zip ayk-238f5654b288bc947d4bf56c2e8c166173253ce1.tar.gz  | |
shadowing outer local variable in spec/options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/options.rb | 41 | 
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/options.rb b/spec/options.rb new file mode 100644 index 0000000..b6ce9a4 --- /dev/null +++ b/spec/options.rb @@ -0,0 +1,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 +#  | 
