Sha256: c7570c60ae943097fb91ef9806f0f76a203664ddc7c01b6814273ef723f734fb
Contents?: true
Size: 1.92 KB
Versions: 3
Compression:
Stored size: 1.92 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') require 'boson/more_method_inspector' describe "MethodInspector" do describe "commands module with" do before_all { eval "module ::Boson::Commands::Zzz; end" } before_all { MethodInspector.instance = nil } def method_inspector MethodInspector.instance end def parse(string) Inspector.enable ::Boson::Commands::Zzz.module_eval(string) Inspector.disable method_inspector.store end it "not all method attributes set causes method_locations to be set" do method_inspector.stubs(:find_method_locations).returns(["/some/path", 10]) parsed = parse "desc 'yo'; def yo; end; options :yep=>1; def yep; end; " + "option :b, :boolean; config :a=>1; desc 'z'; options :a=>1; def az; end" parsed[:method_locations].key?('yo').should == true parsed[:method_locations].key?('yep').should == true parsed[:method_locations].key?('az').should == false end it "no find_method_locations doesn't set method_locations" do method_inspector.stubs(:find_method_locations).returns(nil) parse("def bluh; end")[:method_locations].key?('bluh').should == false end end describe "scrape_arguments" do def args_from(file_string) MethodInspector.scrape_arguments(file_string, "blah") end it "parses arguments of class method" do args_from(" def YAML.blah( filepath )\n").should == [['filepath']] end it "parses arguments with no spacing" do args_from("def bong; end\ndef blah(arg1,arg2='val2')\nend").should == [["arg1"], ['arg2', "'val2'"]] end it "parses arguments with spacing" do args_from("\t def blah( arg1=val1, arg2 = val2)").should == [["arg1","val1"], ["arg2", "val2"]] end it "parses arguments without parenthesis" do args_from(" def blah arg1, arg2, arg3={}").should == [['arg1'], ['arg2'], ['arg3','{}']] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
boson-more-0.3.1 | test/more_method_inspector_test.rb |
boson-more-0.3.0 | test/more_method_inspector_test.rb |
boson-more-0.2.2 | test/more_method_inspector_test.rb |