spec/handlers/ruby/legacy/base_spec.rb in yard-0.7.5 vs spec/handlers/ruby/legacy/base_spec.rb in yard-0.8.0

- old
+ new

@@ -4,17 +4,21 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do before do Handlers::Ruby::Legacy::Base.stub!(:inherited) Handlers::Ruby::Legacy::MixinHandler.stub!(:inherited) # fixes a Ruby1.9 issue - @processor = Handlers::Processor.new(nil, false, :ruby18) + @processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby18)) end - + + after(:all) do + Handlers::Base.clear_subclasses + end + def stmt(string) Statement.new(TokenList.new(string)) end - + it "should only handle Handlers inherited from Ruby::Legacy::Base class" do class IgnoredHandler < Handlers::Base handles "hello" end class NotIgnoredHandlerLegacy < Handlers::Ruby::Legacy::Base @@ -48,31 +52,31 @@ end TestTokenHandler.handles?(stmt("module")).should be_true TestTokenHandler.handles?(stmt("if")).should be_false end - + it "should parse a do/end or { } block with #parse_block" do class MyBlockHandler < Handlers::Ruby::Legacy::Base handles /\AmyMethod\b/ def process parse_block(:owner => "test") end end - + class MyBlockInnerHandler < Handlers::Ruby::Legacy::Base handles "inner" def self.reset; @@reached = false end def self.reached?; @@reached ||= false end def process; @@reached = true end end - + Handlers::Base.stub!(:subclasses).and_return [MyBlockHandler, MyBlockInnerHandler] Parser::SourceParser.parser_type = :ruby18 Parser::SourceParser.parse_string "myMethod do inner end" MyBlockInnerHandler.should be_reached MyBlockInnerHandler.reset Parser::SourceParser.parse_string "myMethod { inner }" MyBlockInnerHandler.should be_reached Parser::SourceParser.parser_type = :ruby end -end \ No newline at end of file +end