+#-*- coding: utf-8 -*-
+
+Given /une base de membres vide$/ do
+ create_dir 'Membres'
+end
+
+Given /^(?:une base )?avec (\w+)(, à jour de cotisation| qui n'a pas payé sa cotisation cette année)$/ do |name, uptodate|
+ case uptodate
+ when ', à jour de cotisation'
+ # ± 1 month ago
+ paid_on = (Time.now - 3600*24*30).strftime('%Y-%m-%d')
+ else
+ # ± 15 months ago
+ paid_on = (Time.now - 3600*24*30*15).strftime('%Y-%m-%d')
+ end
+ data = { 'name' => name,
+ 'address' => "At #{name}",
+ 'email' => "#{name.downcase}@example.org",
+ 'membership_fee_paid_on' => paid_on
+ }
+ create_dir 'Membres'
+ file = subscription_filename_for_id(new_id)
+ write_file file, render_subscription_file(data)
+end
+
+Given /^une nouvelle adhésion de (\w+)$/ do |name|
+ data = { 'name' => name,
+ 'address' => "At #{name}",
+ 'email' => "#{name.downcase}@example.org",
+ 'membership_fee_paid_on' => Time.now.strftime('%Y-%m-%d')
+ }
+ create_dir 'Membres'
+ file = subscription_filename_for_id(new_id)
+ write_file file, render_subscription_file(data)
+end
+
When /^j'ajoute une fiche correcte pour une nouvelle adhésion$/ do
@file = subscription_filename_for_id(new_id)
write_file @file, render_subscription_file(EXTRA_SUBSCRIPTION)
EOF
end
+When /^j'ajoute une fiche avec comme date de cotisation "([^"]*)"$/ do |date|
+ @file = subscription_filename_for_id(new_id)
+ write_file @file, <<-EOF.gsub(/^ /, '')
+ ---
+ name: J. Example
+ email: joe@example.org
+ address: |
+ 21 Jump Street
+ 42000 Synthé
+ membership_fee_paid_on: #{date}
+ ---
+ EOF
+end
+
When /^je supprime le nom sur une fiche existante$/ do
@file = subscription_filename_for_id(1)
run_simple "sed -e '/^name:/d' -i #{@file}"