]> nos-oignons.net Git - gestion-adh.git/blob - features/step_definitions/commands.rb
e0b5ea4a3737ee5483728b508178a45aa564e017
[gestion-adh.git] / features / step_definitions / commands.rb
1 #-*- coding: utf-8 -*-
2 #
3 # Système de gestion des adhésions de Nos oignons
4 # Copyright © 2013-2014 Nos oignons <contact@nos-oignons.net>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19 When /^j'exécute list\-emails$/ do
20   run_simple 'list-emails'
21 end
22
23 When /^j'exécute list-emails le (\d+)\-(\d+)\-(\d+)$/ do |year, month, day|$/
24   Timecop.travel(Time.new(year, month, day)) do
25     stdout_io = StringIO.new
26     begin
27       $stdout = stdout_io
28       NosOignons.list_emails!
29       @stdout = stdout_io.string
30     ensure
31       $stdout = STDOUT
32     end
33   end
34 end
35
36 When /^j'exécute update-ag-subscribers$/ do
37   NosOignons.update_ag_subscribers!
38 end
39
40 When /^(?:que )?j'exécute send-membership-reminders$/ do
41   NosOignons.send_membership_reminders!
42 end
43
44 When /^(?:que )?j'exécute send-membership-reminders le ([0-9]{4})-([0-9]{2})-([0-9]{2})$/ do |year, month, day|
45   Timecop.travel(Date.new(year.to_i, month.to_i, day.to_i)) do
46     NosOignons.send_membership_reminders!
47   end
48 end
49
50 When /^j'exécute send\-member\-emails\-to\-advisors$/ do
51   NosOignons.send_member_emails_to_advisors!
52 end
53
54 When /^j'exécute `(create\-membership\-fee\-receipt.*)`$/ do |cmd|
55   run_simple cmd, :fail_on_error => false
56 end
57
58 Then /^je ne dois pas avoir eu d'erreur$/ do
59   expect(last_command_started).to have_exit_status(0)
60 end
61
62 Then /^je dois voir comme erreur "(.*?)"$/ do |expected|
63   expect(last_command_started).to have_output_on_stderr /#{Regexp.escape(expected)}/
64 end
65
66 Then /^la sortie doit être vide$/ do
67   expect(last_command_started).to have_output_on_stdout('')
68 end
69
70 Then /^la sortie doit être:$/ do |expected|
71   # add an extra line feed for nice scenario
72   expect(last_command_started).to have_output_on_stdout(expected)
73 end
74
75 Then /^la sortie doit être "([^"]*)"$/ do |expected|
76   begin
77     expect(last_command_started).to have_output_on_stdout(expected)
78   rescue Aruba::NoCommandHasBeenStartedError
79     expect(@stdout.rstrip).to eq(expected)
80   end
81 end