spec/vacation_spec.rb in reviewlette-0.0.6 vs spec/vacation_spec.rb in reviewlette-0.0.7
- old
+ new
@@ -1,12 +1,34 @@
require 'spec_helper'
-describe Reviewlette::Vacations do
+describe Vacations do
+ subject { Vacations }
- describe '.find_vacation' do
+ describe '.find_vacations' do
it 'parses the vacations dates out of tel' do
- expect(Reviewlette::Vacations.find_vacations('jschmid')).to be_a_kind_of Array
+ expect_any_instance_of(Net::Telnet).to receive(:cmd).with('testuser1').and_return "Absence : Thu 2015-04-02 - Tue 2015-04-07"
+
+ vacations = subject.find_vacations('testuser1')
+ expect(vacations).to be_kind_of(Array)
+ expect(vacations).to eq([Date.parse('2015-04-02')..Date.parse('2015-04-07')])
end
+
end
-end
\ No newline at end of file
+
+
+ describe '.members_on_vacation' do
+
+ it 'finds members on vacation' do
+ MEMBERS_CONFIG['members'] = [{'suse_username' => 'testuser1'}, {'suse_username' =>'testuser2'}, {'suse_username' =>'testuser3'}]
+ allow(subject).to receive(:find_vacations).with('testuser1').and_return [(Date.today - 1)..(Date.today + 2)]
+ allow(subject).to receive(:find_vacations).with('testuser2').and_return [(Date.today - 1)..(Date.today - 1)]
+ allow(subject).to receive(:find_vacations).with('testuser3').and_return []
+
+ expect(subject.members_on_vacation).to be_kind_of(Array)
+ expect(subject.members_on_vacation).to eq(['testuser1'])
+ end
+
+ end
+
+end