+#-*- 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)