diff --git a/lib/miteru/orchestrator.rb b/lib/miteru/orchestrator.rb index ad887eb..9006ad0 100644 --- a/lib/miteru/orchestrator.rb +++ b/lib/miteru/orchestrator.rb @@ -40,7 +40,14 @@ def websites Miteru.logger.warn("Feed:#{feed.source} failed - #{result.failure}") end end - end.flatten + end.flatten.uniq(&:url) + end + + # + # @return [Array] + # + def feeds + Miteru.feeds.map(&:new) end private @@ -52,12 +59,5 @@ def threads def verbose? Miteru.config.verbose end - - # - # @return [Array] - # - def feeds - Miteru.feeds.map(&:new) - end end end diff --git a/spec/orchestrator_spec.rb b/spec/orchestrator_spec.rb new file mode 100644 index 0000000..3469dad --- /dev/null +++ b/spec/orchestrator_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class DummyFeed < Miteru::Feeds::Base + def initialize(base_url = "http://example.com") + super(base_url) + end + + def urls + ["http://example.com"] * 10 + end +end + +RSpec.describe Miteru::Orchestrator do + subject(:orchestrator) { described_class.new } + + before do + allow(orchestrator).to receive(:feeds).and_return([DummyFeed.new] * 10) + end + + describe "#websites" do + it do + expect(orchestrator.websites.map(&:url)).to eq(["http://example.com"]) + end + end +end