Skip to content

Commit

Permalink
Fix test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed May 9, 2024
1 parent 04c6118 commit 93804d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ module Rayo
module Command
module TwilioStream
RSpec.describe Start do
def parse_stanza(xml)
Nokogiri::XML.parse(xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
end

describe "#to_xml" do
it "serializes to Rayo XML" do
metadata = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ module Rayo
module Command
module TwilioStream
RSpec.describe Stop do
def parse_stanza(xml)
Nokogiri::XML.parse(xml, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
end

describe "#to_xml" do
it "serializes to Rayo XML" do
command = Stop.new(uuid: "call-id")
Expand Down
20 changes: 11 additions & 9 deletions components/app/spec/support/fake_redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,16 @@ def unsubscribe!(*channel_names)
if Array(channel_names).empty?
subscribed_channels.each do |channel|
channel.subscribed = false
next unless callbacks.key?(:unsubscribe)

callbacks.fetch(:unsubscribe).call(channel.name, subscribed_channels.size)
on_unsubscribe
end
else
Array(channel_names).each do |channel_name|
channel = find_channel(channel_name)
if channel.present?
next unless channel.subscribed?
channel.subscribed = false
next unless callbacks.key?(:unsubscribe)
next if channel.blank?
next unless channel.subscribed?

callbacks.fetch(:unsubscribe).call(channel.name, subscribed_channels.size)
end
channel.subscribed = false
on_unsubscribe
end
end
end
Expand Down Expand Up @@ -89,9 +85,15 @@ def poll_for_messages
end
end

private

def subscribed_channels
channels.find_all(&:subscribed?)
end

def on_unsubscribe
callbacks.fetch(:unsubscribe).call(channel.name, subscribed_channels.size) if callbacks.key?(:unsubscribe)
end
end

attr_reader :subscription_options, :future_messages, :subscriptions
Expand Down

0 comments on commit 93804d6

Please sign in to comment.