Sha256: 910d4259d2c322a57cc7aecfd0af40533c9e63e7e9de403f5905aba8026085fa
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require File.dirname(__FILE__) + '/../../spec_helper' include Parser::Ruby::Legacy 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) 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 NotIgnoredHandler < Handlers::Ruby::Legacy::Base handles "hello" end Handlers::Base.stub!(:subclasses).and_return [IgnoredHandler, NotIgnoredHandler] @processor.find_handlers(stmt("hello world")).should == [NotIgnoredHandler] end it "should handle a string input" do class TestStringHandler < Handlers::Ruby::Legacy::Base handles "hello" end TestStringHandler.handles?(stmt("hello world")).should be_true TestStringHandler.handles?(stmt("nothello world")).should be_false end it "should handle regex input" do class TestRegexHandler < Handlers::Ruby::Legacy::Base handles /^nothello$/ end TestRegexHandler.handles?(stmt("nothello")).should be_true TestRegexHandler.handles?(stmt("not hello hello")).should be_false end it "should handle token input" do class TestTokenHandler < Handlers::Ruby::Legacy::Base handles TkMODULE end TestTokenHandler.handles?(stmt("module")).should be_true TestTokenHandler.handles?(stmt("if")).should be_false end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yard-0.2.3 | spec/handlers/ruby/legacy/base_spec.rb |