happy-commander 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +18 -0
- data/bin/commander +7 -0
- data/commander.gemspec +24 -0
- data/lib/commander.rb +3 -0
- data/lib/commander/client.rb +90 -0
- data/lib/commander/exceptions.rb +3 -0
- data/lib/commander/helpers.rb +11 -0
- data/lib/commander/runner.rb +156 -0
- data/lib/commander/setup.rb +145 -0
- data/lib/commander/trello.rb +63 -0
- data/lib/commander/vacations.rb +38 -0
- data/lib/commander/version.rb +4 -0
- data/spec/client_spec.rb +121 -0
- data/spec/fixtures/trello.txt +1 -0
- data/spec/fixtures/users.txt +12 -0
- data/spec/fixtures/vacations.txt +1 -0
- data/spec/helpers_spec.rb +13 -0
- data/spec/runner_spec.rb +262 -0
- data/spec/setup_spec.rb +87 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/input_stubbing.rb +3 -0
- data/spec/support/request_stubbing.rb +23 -0
- data/spec/trello_spec.rb +113 -0
- data/spec/vacations_spec.rb +13 -0
- metadata +133 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'trello'
|
2
|
+
|
3
|
+
|
4
|
+
class Trello::Card
|
5
|
+
# Monkeypatching..
|
6
|
+
def assignees
|
7
|
+
@trello = Commander::TrelloConnection.new
|
8
|
+
member_ids.map{|id| @trello.find_member_by_id(id)}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
module Commander
|
14
|
+
# Trello Module
|
15
|
+
class TrelloConnection
|
16
|
+
|
17
|
+
attr_accessor :board
|
18
|
+
|
19
|
+
# Loads the Configuration for Trello Auth
|
20
|
+
def initialize
|
21
|
+
configure_trello
|
22
|
+
end
|
23
|
+
|
24
|
+
# Adds a member to a certain card
|
25
|
+
def add_commander_to_card(commander, card)
|
26
|
+
card.add_member(commander) if commander
|
27
|
+
end
|
28
|
+
|
29
|
+
# Comments on a certain card
|
30
|
+
def comment_on_card(commander, card)
|
31
|
+
card.add_comment(commander) if commander
|
32
|
+
end
|
33
|
+
|
34
|
+
# Finds a member by its username
|
35
|
+
def find_member_by_username(username)
|
36
|
+
@board.members.find { |m| m.username == username }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Lists all members who are assigned on a certain card
|
40
|
+
def list_of_assigned_members(card)
|
41
|
+
card.assignees.map(&:username)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Finds a member by its id
|
45
|
+
def find_member_by_id(id)
|
46
|
+
@board.members.find { |m| m.id == id }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Finds a card by its id
|
50
|
+
def find_card_by_id(id)
|
51
|
+
@board.cards.find{|c| c.short_id == id.to_i}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Configures Trello
|
55
|
+
def configure_trello
|
56
|
+
Trello.configure do |config|
|
57
|
+
config.developer_public_key = Commander::CONFIG['consumerkey']
|
58
|
+
config.member_token = Commander::CONFIG['oauthtoken']
|
59
|
+
end
|
60
|
+
@board = Trello::Board.find(Commander::CONFIG['board_id'])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'net/telnet'
|
2
|
+
module Commander
|
3
|
+
|
4
|
+
class Vacations
|
5
|
+
|
6
|
+
def self.find_vacations(username)
|
7
|
+
vacations = []
|
8
|
+
tn = Net::Telnet.new('Host' => 'present.suse.de', 'Port' => 9874, 'Binmode' => false)
|
9
|
+
collect = false
|
10
|
+
tn.cmd(username) do |data|
|
11
|
+
data.split("\n").each do |l|
|
12
|
+
collect = true if l =~ /^Absence/
|
13
|
+
next unless collect
|
14
|
+
if l[0,1] == "-"
|
15
|
+
collect = false
|
16
|
+
next
|
17
|
+
end
|
18
|
+
dates = []
|
19
|
+
l.split(" ").each do |date|
|
20
|
+
unless date =~ /#{Time.now.year}/
|
21
|
+
next
|
22
|
+
end
|
23
|
+
dates.push(date)
|
24
|
+
end
|
25
|
+
case dates.size
|
26
|
+
when 1
|
27
|
+
vacations.push("#{dates[0]}")
|
28
|
+
when 2
|
29
|
+
vacations.push("#{dates[0]} - #{dates[1]}")
|
30
|
+
else
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
tn.close
|
35
|
+
vacations
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Commander::Client do
|
4
|
+
|
5
|
+
subject { Commander::Client }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow_any_instance_of(Commander::Runner).to receive(:set_commander) { true }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#execute' do
|
12
|
+
context 'with auto options' do
|
13
|
+
let(:cli) { subject.new(%w{-a}) }
|
14
|
+
|
15
|
+
it 'should run with default settings' do
|
16
|
+
expect(Commander::Runner).to receive(:new).with(cli.options).and_return Commander::Runner.new(cli.options)
|
17
|
+
expect_any_instance_of(Commander::Runner).to receive(:set_commander)
|
18
|
+
cli.execute!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with force options' do
|
23
|
+
let(:cli) { subject.new(%w{-f, name}) }
|
24
|
+
|
25
|
+
it 'should run with force settings' do
|
26
|
+
expect(Commander::Runner).to receive(:new).with(cli.options).and_return Commander::Runner.new(cli.options)
|
27
|
+
expect_any_instance_of(Commander::Runner).to receive(:set_commander)
|
28
|
+
cli.execute!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with list options' do
|
33
|
+
let(:cli) { subject.new(%w{-l}) }
|
34
|
+
|
35
|
+
it 'should run with list settings' do
|
36
|
+
expect(Commander::Runner).to receive(:new).with(cli.options).and_return Commander::Runner.new(cli.options)
|
37
|
+
expect_any_instance_of(Commander::Runner).to receive(:list_all_members)
|
38
|
+
cli.execute!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with status options' do
|
43
|
+
let(:cli) { subject.new(%w{-s, name}) }
|
44
|
+
|
45
|
+
it 'should run with force settings' do
|
46
|
+
expect(Commander::Runner).to receive(:new).with(cli.options).and_return Commander::Runner.new(cli.options)
|
47
|
+
expect_any_instance_of(Commander::Runner).to receive(:show_status)
|
48
|
+
cli.execute!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'with vacation options' do
|
53
|
+
let(:cli) { subject.new(%w{-v, name, true}) }
|
54
|
+
|
55
|
+
it 'should run with vacation settings' do
|
56
|
+
expect(Commander::Runner).to receive(:new).with(cli.options).and_return Commander::Runner.new(cli.options)
|
57
|
+
expect_any_instance_of(Commander::Runner).to receive(:set_vacation_flag)
|
58
|
+
cli.execute!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'with setup options' do
|
63
|
+
let(:cli) { subject.new(%w{-x}) }
|
64
|
+
|
65
|
+
it 'should run with setup settings' do
|
66
|
+
expect(Commander::Setup).to receive(:configure)
|
67
|
+
cli.execute!
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with no options' do
|
72
|
+
let(:cli) { subject.new(%w{}) }
|
73
|
+
|
74
|
+
it 'should exit cleanly when no arg is given' do
|
75
|
+
expect_any_instance_of(subject).to receive(:exit)
|
76
|
+
cli.execute!
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '?extract_options' do
|
82
|
+
it 'sets status options' do
|
83
|
+
cli = subject.new(%w{-s Joshua})
|
84
|
+
expect(cli.options[:status]).to eq 'Joshua'
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'sets force options' do
|
88
|
+
cli = subject.new(%w{-f Joshua})
|
89
|
+
expect(cli.options[:force]).to eq 'Joshua'
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'sets vacation options' do
|
93
|
+
cli = subject.new(%w{-v Joshua,true})
|
94
|
+
expect(cli.options[:vacation]).to eq ['Joshua', 'true']
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'sets list options' do
|
98
|
+
cli = subject.new(['-l'])
|
99
|
+
expect(cli.options[:list]).to eq true
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'sets auto options' do
|
103
|
+
cli = subject.new(['-a'])
|
104
|
+
expect(cli.options[:auto]).to eq true
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'sets help options' do
|
108
|
+
argv = %w{-h}
|
109
|
+
expect_any_instance_of(subject).to receive(:puts)
|
110
|
+
expect_any_instance_of(subject).to receive(:exit)
|
111
|
+
subject.new(argv)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'gets version options' do
|
115
|
+
argv = %w{-u}
|
116
|
+
expect_any_instance_of(subject).to receive(:puts).with(Commander::VERSION)
|
117
|
+
expect_any_instance_of(subject).to receive(:exit)
|
118
|
+
subject.new(argv)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
card_id: 15
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{"Thomas"=>
|
2
|
+
{:times_commander=>3, :trello_name=>"thomasschmidt", :date=>2014-07-11 11:23:21 +0200, :vacation=>false, :tel_name=>"Thomas Schmidt", :vacations=>["2014-07-25 - 2014-07-27", "2014-08-01 - 2014-08-03", "2014-08-16 - 2014-08-31", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]},
|
3
|
+
"Vlad"=>
|
4
|
+
{:times_commander=>3, :trello_name=>"vlewin", :date=>2014-07-11 11:12:08 +0200, :vacation=>false, :tel_name=>"Vladislav Lewin", :vacations=>["2014-08-23 - 2014-09-14", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]},
|
5
|
+
"Dominik"=>
|
6
|
+
{:times_commander=>0, :trello_name=>"b4mboo", :date=>2014-07-10 13:23:19 +0200, :vacation=>true, :tel_name=>"Dominik Bamberger", :vacations=>["2014-07-04 - 2014-07-06", "2014-07-08 - 2014-07-13", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]},
|
7
|
+
"Joshua"=>
|
8
|
+
{:times_commander=>4, :trello_name=>"jschmid", :date=>2014-07-11 11:24:46 +0200, :vacation=>false, :tel_name=>"Joshua Schmid", :vacations=>["2014-07-19 - 2014-07-23", "2014-07-26 - 2014-07-28", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]},
|
9
|
+
"Artem"=>
|
10
|
+
{:times_commander=>3, :trello_name=>"artemchernikov", :date=>2014-07-11 11:09:16 +0200, :vacation=>false, :tel_name=>"Artem Chernikov", :vacations=>["2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]},
|
11
|
+
"Will"=>
|
12
|
+
{:times_commander=>3, :trello_name=>"wstephenson", :date=>2014-07-11 11:08:59 +0200, :vacation=>false, :tel_name=>"Will Stephenson", :vacations=>["2014-07-05 - 2014-07-07", "2014-10-03 - 2014-10-05", "2014-12-24 - 2014-12-28"]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
[['2014-08-08','2014-08-09'],['2014-08-18','2014-08-20'],['2014-09-08','2014-10-08'],['2014-11-08','2014-12-08']]
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,262 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe Commander::Runner do
|
5
|
+
|
6
|
+
let( :vacations) { File.read(File.join(File.dirname(__FILE__), 'fixtures/vacations.txt')) }
|
7
|
+
let( :config) { File.read(File.join(File.dirname(__FILE__), 'fixtures/trello.txt')) }
|
8
|
+
let( :users) { File.read(File.join(File.dirname(__FILE__), 'fixtures/users.txt')) }
|
9
|
+
subject { Commander::Runner }
|
10
|
+
|
11
|
+
describe '.new' do
|
12
|
+
context 'without options' do
|
13
|
+
it 'initializes new instance of Commander::Runner' do
|
14
|
+
instance = subject.new({})
|
15
|
+
expect(instance.users).not_to be nil
|
16
|
+
expect(instance.options[:force]).to be_nil
|
17
|
+
expect(instance.selected_commander).to be nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with options' do
|
22
|
+
it 'initializes new instance of Commander::Runner' do
|
23
|
+
instance = subject.new({:vacation=>false, :force=>'a_user', :status=>false, :auto=>true, :list=>false})
|
24
|
+
expect(instance.options[:force]).to be_a_kind_of String
|
25
|
+
expect(instance.users).not_to be nil
|
26
|
+
expect(instance.options[:auto]).to be true
|
27
|
+
expect(instance.selected_commander).to eq 'a_user'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#set_commander' do
|
33
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>false, :status=>false, :auto=>true, :list=>false}) }
|
34
|
+
|
35
|
+
it 'sets the commander with help of methods' do
|
36
|
+
expect(subject).to receive(:import)
|
37
|
+
expect(subject).to receive(:find_card)
|
38
|
+
expect(subject).to receive(:update_vacations)
|
39
|
+
expect(subject).to receive(:select_commander)
|
40
|
+
expect(subject).to receive(:manipulate_trello)
|
41
|
+
expect(subject).not_to receive(:write_attributes)
|
42
|
+
subject.set_commander
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#manipulate_trello' do
|
47
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>false, :status=>false, :auto=>true, :list=>false}) }
|
48
|
+
|
49
|
+
it 'holds trello manipulation methods' do
|
50
|
+
expect(subject).to receive(:comment_on_card)
|
51
|
+
expect(subject).to receive(:delete_assigned_members)
|
52
|
+
expect(subject).to receive(:add_member_to_card)
|
53
|
+
subject.manipulate_trello
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#set_commander' do
|
58
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>false}) }
|
59
|
+
|
60
|
+
it 'sets the commander with help of methods' do
|
61
|
+
expect(subject).to receive(:import)
|
62
|
+
expect(subject).to receive(:find_card)
|
63
|
+
expect(subject).to receive(:update_vacations)
|
64
|
+
expect(subject).not_to receive(:select_commander)
|
65
|
+
expect(subject).to receive(:write_attributes)
|
66
|
+
expect(subject).to receive(:manipulate_trello)
|
67
|
+
subject.set_commander
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#update_vacations' do
|
72
|
+
|
73
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>false}) }
|
74
|
+
|
75
|
+
let( :vacations) { File.read(File.join(File.dirname(__FILE__), 'fixtures/vacations.txt')) }
|
76
|
+
|
77
|
+
it 'updates vacations from tel' do
|
78
|
+
instance_variable_set(:@vacations, vacations)
|
79
|
+
allow(Commander::Vacations).to receive(:find_vacations).with(any_args).and_return vacations
|
80
|
+
expect(subject).to receive_message_chain(:users, :keys, :each)
|
81
|
+
# expect(subject).to receive(:evaluate_vacations)
|
82
|
+
subject.update_vacations
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'can write to file' do
|
86
|
+
expect(subject).to receive(:write_to_file)
|
87
|
+
subject.update_vacations
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#set_vacation_flag' do
|
92
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>false}) }
|
93
|
+
|
94
|
+
it 'sets a vacation flag if on vacation' do
|
95
|
+
allow(Commander::Helpers).to receive(:to_boolean).and_return 'true'
|
96
|
+
subject.set_vacation_flag(subject.users.first.first, 'true')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#evaulate_vacations' do
|
101
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>false}) }
|
102
|
+
|
103
|
+
it 'evaluates vacation times' do
|
104
|
+
allow(subject).to receive(:parse_vacations).and_return [1,2,3,4]
|
105
|
+
subject.evaluate_vacations(subject.users.first.first)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#show_status' do
|
111
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>false, :status=>'Joshua', :auto=>false, :list=>false}) }
|
112
|
+
|
113
|
+
it 'prints out the status' do
|
114
|
+
expect(STDOUT).to receive(:puts).with("#{subject.options[:status]} was #{subject.users['Joshua'][:times_commander]} times Commanding officer of the week.")
|
115
|
+
expect(STDOUT).to_not receive(:puts).with("#{subject.options[:status]} is currently on vacation.")
|
116
|
+
subject.show_status(subject.options[:status])
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#wirte_attributes' do
|
122
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
123
|
+
|
124
|
+
it 'writes standard attributes' do
|
125
|
+
instance_variable_set(:@selected_commander, 'test')
|
126
|
+
instance_variable_set(:@users, 'test')
|
127
|
+
expect(subject.users.first.last[:vacation]).to eq false
|
128
|
+
expect(subject.users.first.last[:times_commander]).to be_a_kind_of Integer
|
129
|
+
expect(subject.users.first.last[:date]).to be_a_kind_of Time
|
130
|
+
expect(subject).to receive(:write_to_file).and_return true
|
131
|
+
subject.write_attributes
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
describe '#delete_assigned_members' do
|
137
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
138
|
+
|
139
|
+
it 'delete all remaining members on the trello card' do
|
140
|
+
card = Trello::Card.new
|
141
|
+
members = Trello::Member.new
|
142
|
+
subject.instance_variable_set(:@card, card)
|
143
|
+
expect(card).to receive_message_chain(:members, :each) { members }
|
144
|
+
subject.delete_assigned_members
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
describe '#list_all_members' do
|
151
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
152
|
+
|
153
|
+
it 'lists all available members' do
|
154
|
+
# user = subject.users.first.first
|
155
|
+
expect(STDOUT).to receive(:puts).with(String)
|
156
|
+
expect(STDOUT).to receive(:puts).with(String)
|
157
|
+
expect(STDOUT).to receive(:puts).with(String)
|
158
|
+
expect(STDOUT).to receive(:puts).with(String)
|
159
|
+
expect(STDOUT).to receive(:puts).with(String)
|
160
|
+
expect(STDOUT).to receive(:puts).with(String)
|
161
|
+
# how to test 6 times?
|
162
|
+
subject.list_all_members
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#find_card' do
|
167
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
168
|
+
|
169
|
+
it 'find the card from trello board' do
|
170
|
+
card = double('card')
|
171
|
+
trello = double('trello')
|
172
|
+
subject.instance_variable_set(:@trello, trello)
|
173
|
+
allow(subject).to receive(:find_card_by_id).with(Commander::CONFIG[:card_id])
|
174
|
+
expect(trello).to receive(:find_card_by_id).with('card')
|
175
|
+
subject.find_card
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '#count_up' do
|
180
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
181
|
+
|
182
|
+
it 'increments the user counter' do
|
183
|
+
instance_variable_set(:@selected_commander, 'Joshua')
|
184
|
+
count = subject.users[@selected_commander][:times_commander]
|
185
|
+
expect(subject.count_up).to eq (count + 1)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
describe '#add_member_to_card' do
|
190
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
191
|
+
|
192
|
+
it 'adds a member to the specified trello card ' do
|
193
|
+
trello = double('trello')
|
194
|
+
card = double('card')
|
195
|
+
member = double('member')
|
196
|
+
subject.instance_variable_set(:@trello, trello)
|
197
|
+
subject.instance_variable_set(:@card, card)
|
198
|
+
expect(subject).to receive(:find_member).and_return member
|
199
|
+
expect(trello).to receive(:add_commander_to_card).with(member, card)
|
200
|
+
subject.add_member_to_card
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#find_member' do
|
205
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
206
|
+
|
207
|
+
it 'finds the member based on its trello username' do
|
208
|
+
trello = double('trello')
|
209
|
+
subject.instance_variable_set(:@trello, trello)
|
210
|
+
expect(trello).to receive(:find_member_by_username)
|
211
|
+
subject.find_member
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe '#wirte_to_file' do
|
216
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
217
|
+
|
218
|
+
it 'writes all the stuff to the yaml file' do
|
219
|
+
expect(File).to receive(:open).and_return true
|
220
|
+
File.open
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe '#comment_on_card' do
|
225
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
226
|
+
|
227
|
+
it 'comments on the card' do
|
228
|
+
trello = double('trello')
|
229
|
+
card = double('card')
|
230
|
+
comment_string = '@jschmid is your commanding officer for the next 7 Days.'
|
231
|
+
subject.instance_variable_set(:@trello, trello)
|
232
|
+
subject.instance_variable_set(:@comment_string, comment_string)
|
233
|
+
subject.instance_variable_set(:@card, card)
|
234
|
+
expect(trello).to receive(:comment_on_card).with(comment_string, card)
|
235
|
+
subject.comment_on_card
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
describe '#select_commander' do
|
240
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
241
|
+
|
242
|
+
it 'selects a commander based on date, count and presence' do
|
243
|
+
subject.instance_variable_get(:@selected_commander)
|
244
|
+
subject.select_commander
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe '#import' do
|
249
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>'Joshua', :status=>false, :auto=>false, :list=>true}) }
|
250
|
+
|
251
|
+
it 'imports trello config' do
|
252
|
+
stub_boards_call
|
253
|
+
expect(subject.import).to be_a_kind_of Commander::TrelloConnection
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe '#select_commander' do
|
258
|
+
subject { Commander::Runner.new({:vacation=>false, :force=>false, :status=>false, :auto=>true, :list=>true}) }
|
259
|
+
it 'selects the commander based on yamldata' do
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|