spec/trello_connection_spec.rb in reviewlette-0.0.9 vs spec/trello_connection_spec.rb in reviewlette-1.0.0
- old
+ new
@@ -1,70 +1,71 @@
require 'spec_helper'
-describe TrelloConnection do
- subject { TrelloConnection }
-
- let(:trello) { subject.new }
+describe Reviewlette::TrelloConnection do
+ subject { described_class.new }
let(:card) { Trello::Card.new }
let(:trello_config) { { 'consumerkey' => consumerkey, 'oauthtoken' => oauthtoken } }
let(:consumerkey) { '4a6' }
let(:oauthtoken) { 'a8e' }
-
before do
allow(Trello::Board).to receive(:find).and_return(Trello::Board.new)
allow(YAML).to receive(:load_file).and_return(trello_config)
end
-
describe '.new' do
it 'sets up trello' do
expect_any_instance_of(Trello::Configuration).to receive(:developer_public_key=).with(consumerkey)
expect_any_instance_of(Trello::Configuration).to receive(:member_token=).with(oauthtoken)
- subject.new
+ described_class.new
end
end
describe '#add_reviewer_to_card' do
it 'adds the valid member to the trello card and comments it' do
- expect(trello).to receive(:find_member_by_username).with('testuser1').and_return 'testuser1'
+ expect(subject).to receive(:find_member_by_username).with('testuser1').and_return 'testuser1'
expect_any_instance_of(Trello::Card).to receive(:add_member).with('testuser1')
- trello.add_reviewer_to_card('testuser1', card)
+ subject.add_reviewer_to_card('testuser1', card)
end
end
- describe '#comment_on_card' do
+ describe '#comment_reviewers' do
it 'comments on the assigned trello card ' do
- allow(card).to receive(:add_comment).with('comment').and_return true
- expect(trello.comment_on_card('comment', card)).to eq true
+ repo_name = 'testrepo'
+ issue_id = 1
+ reviewers = [double(trello_handle: 'test1'), double(trello_handle: 'test2')]
+ comment = "@test1 and @test2 will review https://github.com/#{repo_name}/issues/#{issue_id}"
+
+ allow(card).to receive(:add_comment).with(comment).and_return true
+ expect(subject.comment_reviewers(card, repo_name, issue_id, reviewers)).to eq true
end
end
describe '#move_card_to_list' do
it 'move cards to its certain column' do
- expect(trello).to receive(:find_column).with('Done').and_return 'column'
+ expect(subject).to receive(:find_column).with('Done').and_return 'column'
expect(card).to receive(:move_to_list).with('column').and_return true
- expect(trello.move_card_to_list(card, 'Done')).to be true
+ expect(subject.move_card_to_list(card, 'Done')).to be true
end
end
describe '#find_column' do
it 'detects columns' do
expect_any_instance_of(Trello::Board).to receive_message_chain(:lists, :find)
- trello.find_column('Done')
+ subject.find_column('Done')
end
end
describe '#find_member_by_username' do
it 'finds a member based on a username and returns a trello member object' do
expect_any_instance_of(Trello::Board).to receive_message_chain(:members, :find)
- trello.find_member_by_username('testuser')
+ subject.find_member_by_username('testuser')
end
end
describe '#find_card_by_id(id)' do
it 'finds the right card based on the trello id' do
expect_any_instance_of(Trello::Board).to receive_message_chain(:cards, :find)
- trello.find_card_by_id(123)
+ subject.find_card_by_id(123)
end
end
end