3 # Système de gestion des adhésions de Nos oignons
4 # Copyright © 2013-2014 Nos oignons <contact@nos-oignons.net>
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.
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.
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/>.
22 @mock_mailman_db = "#{current_dir}/mock_mailman.json"
23 init_mailman_mock_db({})
24 ENV['MOCK_MAILMAN_DB'] = @mock_mailman_db
25 @orig_path = ENV['PATH']
26 ENV['PATH'] = "#{File.expand_path('../../support/mock_mailman', __FILE__)}:#{@orig_path}"
30 ENV['PATH'] = @orig_path
31 FileUtils.remove_entry_secure @mock_mailman_db
34 def init_mailman_mock_db(dict)
35 File.open(@mock_mailman_db, 'w') { |f| f.write(JSON.dump(dict)) }
39 JSON.load(File.open(@mock_mailman_db))
42 Given /^une liste ag@ avec comme emails inscrits:$/ do |subscriber_list|
43 emails = subscriber_list.strip.split
44 init_mailman_mock_db('ag' => emails)
47 Then /^la liste ag@ doit avoir comme emails inscrits:$/ do |expected|
48 emails = expected.strip.split.sort
49 expect(mailman_mock_db['ag'].sort).to eql(emails)