spec/lita/adapters/campfire_spec.rb in lita-campfire-0.1.3 vs spec/lita/adapters/campfire_spec.rb in lita-campfire-0.1.4
- old
+ new
@@ -11,12 +11,12 @@
allow(described_class::Connector).to receive(:new).and_return(connector)
end
subject { described_class.new(robot) }
- let(:robot) { double("Lita::Robot") }
- let(:connector) { double("Lita::Adapters::Campfire::Connector") }
+ let(:robot) { instance_double(Lita::Robot) }
+ let(:connector) { instance_double(Lita::Adapters::Campfire::Connector) }
it "registers with Lita" do
expect(Lita.adapters[:campfire]).to eql(described_class)
end
@@ -24,10 +24,30 @@
Lita.clear_config
expect(Lita.logger).to receive(:fatal).with(/subdomain, apikey, rooms/)
expect { subject }.to raise_error(SystemExit)
end
+ context 'passing optional variables' do
+ optional_config = described_class::OPTIONAL_CONFIG_OPTIONS
+ optional_config.each do |option|
+ it "does not set #{option} hash value if option is not set" do
+ expect(described_class::Connector).not_to receive(:new).with(robot, hash_including(option.to_sym))
+ subject
+ end
+ end
+
+ it 'can receive hash with tinder options' do
+ tinder_options = { timeout: 30, auto_reconnect: false }
+ Lita.configure do |config|
+ config.adapter.tinder_options = tinder_options
+ end
+
+ expect(described_class::Connector).to receive(:new).with(robot, hash_including(:tinder_options => tinder_options))
+ subject
+ end
+ end
+
describe '#run' do
before do
allow(subject.connector).to receive(:connect)
allow(subject.connector).to receive(:join_rooms)
allow(subject).to receive(:sleep)
@@ -57,21 +77,21 @@
end
end
describe '#send_messages' do
it 'sends messages to rooms' do
- source = double("Lita::Source", room: "room_id")
+ source = instance_double(Lita::Source, room: "room_id")
expect(subject.connector).to receive(:send_messages).with(
'room_id',
["Hello!"]
)
subject.send_messages(source, ["Hello!"])
end
end
describe "#set_topic" do
it "sets a new topic for a room" do
- source = double("Lita::Source", room: "room_id")
+ source = instance_double(Lita::Source, room: "room_id")
expect(subject.connector).to receive(:set_topic).with(
"room_id",
"Topic"
)
subject.set_topic(source, "Topic")
\ No newline at end of file