require 'spec_helper' describe Lita::Handlers::Youtrack, lita_handler: true do before :each do Lita.config.handlers.youtrack.hosturl = "www.sampleyoutrackhost.com" end let(:bugs_input) { File.read("spec/fixtures/bugs_input.xml") } let(:bugs_output) { [File.read("spec/fixtures/bugs_output.txt")] } let(:bugs_parking_input) { File.read("spec/fixtures/bugs_parking_input.xml") } let(:bugs_parking_output) { [File.read("spec/fixtures/bugs_parking_output.txt")] } let(:no_bugs_input) { File.read("spec/fixtures/no_bugs_input.xml") } let(:no_bugs_output) { [File.read("spec/fixtures/no_bugs_output.txt")] } let(:projects_input) { File.read("spec/fixtures/projects_input.xml") } let(:projects_output) { [File.read("spec/fixtures/projects_output.txt")] } let(:project_rsa_input) { File.read("spec/fixtures/project_RSA_input.xml") } let(:project_rsa_output) { [File.read("spec/fixtures/project_RSA_output.txt")] } let(:project_rsa_all_input) { File.read("spec/fixtures/RSA_all_input.xml") } let(:project_rsa_all_output) { [File.read("spec/fixtures/RSA_all_output.txt")] } let(:cookie) { [File.read("spec/fixtures/cookie.txt")] } it 'tells lita to display the important bug list' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { bugs_input } send_command("bugs") expect(replies).to eq(bugs_output) end it 'tells lita to display the important bug list plus parking lot' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { bugs_parking_input } send_command("bugs parking") expect(replies).to eq(bugs_parking_output) end it 'lita finds no bugs' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { no_bugs_input } send_command("bugs") expect(replies).to eq(no_bugs_output) end it 'tells lita to display all projects' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { projects_input } send_command("projects") expect(replies).to eq(projects_output) end it 'tells lita to display incomplete issues in specific project (RSA)' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { project_rsa_input } send_command("project RSA") expect(replies).to eq(project_rsa_output) end it 'tells lita to display all issues in specific project (RSA)' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { project_rsa_all_input } send_command("project RSA all") expect(replies).to eq(project_rsa_all_output) end it 'tells lita to display warning for non-existant project (asdf)' do allow_any_instance_of(Lita::Handlers::Youtrack).to receive(:call_http) { "" } send_command("project ASDF") expect(replies).to include("Either project doesn't exist, or it has no issues - type 'lita projects' for list\nShowing only incomplete issues, add an 'all' to see all issues\n") end end