spec/fluq/handler/base_spec.rb in fluq-0.7.5 vs spec/fluq/handler/base_spec.rb in fluq-0.8.0

- old
+ new

@@ -1,70 +1,25 @@ require 'spec_helper' describe FluQ::Handler::Base do - subject { described_class.new reactor } + let(:event) { FluQ::Event.new({}) } it { should respond_to(:on_events) } it { should be_a(FluQ::Mixins::Loggable) } - its(:reactor) { should be(reactor) } - its(:config) { should == { pattern: /./, timeout: 60 } } - its(:pattern) { should == /./ } - its(:name) { should == "base-AxPGxv" } + its(:config) { should == { timeout: 60 } } + its(:name) { should == "base" } + its(:timers) { should be_instance_of(Timers) } - def events(*tags) - tags.map {|tag| event(tag) } - end - - def event(tag) - FluQ::Event.new(tag, 1313131313, {}) - end - it 'should have a type' do described_class.type.should == "base" end it 'can have custom names' do - described_class.new(reactor, name: "visitors").name.should == "visitors" + described_class.new(name: "visitors").name.should == "visitors" end - it 'should match tags via patters' do - subject = described_class.new(reactor, pattern: "visits.????.*") - subject.match?(event("visits.site.1")).should be(true) - subject.match?(event("visits.page.2")).should be(true) - subject.match?(event("visits.other.1")).should be(false) - subject.match?(event("visits.site")).should be(false) - subject.match?(event("visits.site.")).should be(true) - subject.match?(event("prefix.visits.site.1")).should be(false) - subject.match?(event("visits.site.1.suffix")).should be(true) - end - - it 'should support "or" patterns' do - subject = described_class.new(reactor, pattern: "visits.{site,page}.*") - subject.match?(event("visits.site.1")).should be(true) - subject.match?(event("visits.page.2")).should be(true) - subject.match?(event("visits.other.1")).should be(false) - subject.match?(event("visits.site")).should be(false) - subject.match?(event("visits.site.")).should be(true) - subject.match?(event("prefix.visits.site.1")).should be(false) - subject.match?(event("visits.site.1.suffix")).should be(true) - end - - it 'should support regular expression patterns' do - subject = described_class.new(reactor, pattern: /^visits\.(?:s|p)\w{3}\..*/) - subject.match?(event("visits.site.1")).should be(true) - subject.match?(event("visits.page.2")).should be(true) - subject.match?(event("visits.other.1")).should be(false) - subject.match?(event("visits.site")).should be(false) - subject.match?(event("visits.site.")).should be(true) - subject.match?(event("prefix.visits.site.1")).should be(false) - subject.match?(event("visits.site.1.suffix")).should be(true) - end - - it 'should select events' do - stream = events("visits.site.1", "visits.page.2", "visits.other.1", "visits.site.2") - described_class.new(reactor, pattern: "visits.????.*").select(stream).map(&:tag).should == [ - "visits.site.1", "visits.page.2", "visits.site.2" - ] + it 'should not filter events by default' do + subject.filter([event, event]).should have(2).items end end