require_relative "../../helper" require_relative "../../../lib/fabriq/cli" require 'ostruct' describe Fabriq::CLI do before do @cli = Fabriq::CLI @cli.stubs(:exit) @cli.skype = @skype = mock('Skype') end describe '#run' do it "lists available rooms if 'rooms' is passed as first argument" do @cli.expects(:list_available_rooms) @cli.run(['rooms']) end it "exists the process with success(0)" do @cli.expects(:exit).with(0) @cli.run([]) end end describe '#list_available_rooms' do before do @cli.stubs(:cli_out) end it "collects all Skype Rooms" do @skype.expects(:rooms).returns([]) @cli.list_available_rooms end it "prints information about each collected room" do room = OpenStruct.new({ topic: "Test", id: 99 }) @skype.stubs(:rooms).returns([room]) @cli.expects(:cli_out).with() { |out| out =~ /99(.*)Test/ } @cli.list_available_rooms end end end