Sha256: e4836a991a39c7f9b2d528d6a0c21780024ba68a83bc93f35d161b7474ba40c7
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' require 'awesome_print' describe SexpInfo do context "methods only" do Given(:methods) { File.read('spec/fixtures/methods.rb') } Given(:rip) { Ripper.sexp(methods) } Given(:sexp) { SexpInfo.new(rip) } Then { sexp.type.should == :def } Then { sexp.defined_methods.should == ["no_args", "one_arg_no_parens", "one_arg_parens" ,"two_args", "optional_args"] } Then { sexp["no_args"].arity.should == 0 } Then { sexp["one_arg_no_parens"].arity.should == 1 } Then { sexp["one_arg_parens"].arity.should == 1 } Then { sexp["two_args"].arity.should == 2 } Then { sexp["two_args"].args[0].should_not be_optional } Then { sexp["optional_args"].args[1].should be_optional } Then { sexp["optional_args"].line_number.should == 19 } end context "classes" do Given(:classes) { File.read('spec/fixtures/classes.rb') } Given(:rip) { Ripper.sexp(classes) } Given(:sexp) { SexpInfo.new(rip) } Then { sexp.defined_classes.should == ["StdClass", "OtherClass"] } Then { sexp["StdClass"].defined_methods.should == ["optional_args"] } end context "classes" do Given(:modules) { File.read('spec/fixtures/modules.rb') } Given(:rip) { Ripper.sexp(modules) } Given(:sexp) { SexpInfo.new(rip) } Then { sexp.type.should == :module } Then { sexp.defined_modules.should == ["StdModule"] } Then { sexp["StdModule"].should be_a SexpThing::Module } Then { sexp["StdModule"].defined_classes.should == ["StdClass"] } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sexp_info-0.0.3 | spec/lib/sexp_info_spec.rb |
sexp_info-0.0.2 | spec/lib/sexp_info_spec.rb |