gem 'cucumber'
gem 'aruba'
+gem 'safe_yaml'
--- /dev/null
+GEM
+ remote: https://rubygems.org/
+ specs:
+ aruba (0.5.3)
+ childprocess (>= 0.3.6)
+ cucumber (>= 1.1.1)
+ rspec-expectations (>= 2.7.0)
+ builder (3.2.1)
+ childprocess (0.3.9)
+ ffi (~> 1.0, >= 1.0.11)
+ cucumber (1.3.2)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.12.0)
+ multi_json (~> 1.3)
+ diff-lcs (1.2.4)
+ ffi (1.8.1)
+ gherkin (2.12.0)
+ multi_json (~> 1.3)
+ multi_json (1.7.4)
+ rspec-expectations (2.13.0)
+ diff-lcs (>= 1.1.3, < 2.0)
+ safe_yaml (0.9.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ aruba
+ cucumber
+ safe_yaml
Soit un clone du Git contenant les adhésions
Lorsque j'ajoute une fiche correcte pour une nouvelle adhésion
Et que je fait un `commit` du nouveau fichier
- Alors je ne dois pas voir d'erreur
+ Alors je ne dois pas avoir eu d'erreur
--- /dev/null
+Then /^je ne dois pas avoir eu d'erreur$/ do
+ assert_exit_status(0)
+end
--- /dev/null
+require 'fileutils'
+
+Given /^un clone du Git contenant les adhésions$/ do
+ # Create main repository
+ create_dir 'main'
+ cd 'main'
+ run_simple 'git init'
+ create_dir 'Membres'
+ BASE_SUBSCRIPTIONS.each_pair do |number, data|
+ file = subscription_filename_for_id(number)
+ write_file file, render_subscription_file(data)
+ run_simple "git add #{file}"
+ end
+ run_simple 'git commit -m "Initial data set from fixtures"'
+ cd '..'
+
+ # Clone it now
+ run_simple 'git clone main clone'
+ cd 'clone'
+end
+
+When /je fait un `commit` du nouveau fichier$/ do
+ run_simple "git add #{@file}"
+ run_simple "git commit #{@file} -m 'new file'"
+end
--- /dev/null
+When /^j'ajoute une fiche correcte pour une nouvelle adhésion$/ do
+ new_id = Dir.glob("#{current_dir}/Membres/*.mdwn").
+ collect { |f| File.basename(f).gsub(/\.mdwn$/, '').to_i }.max + 1
+ @file = subscription_filename_for_id(new_id)
+ write_file @file, render_subscription_file(EXTRA_SUBSCRIPTION)
+end
--- /dev/null
+require 'rubygems'
+require 'bundler'
+Bundler.setup
+
+require 'tmpdir'
+require 'aruba/cucumber'
+require 'safe_yaml'
+
+SafeYAML::OPTIONS[:default_mode] = :safe
+
+Before do
+ @tmpdir = Dir.mktmpdir('gestion-adh')
+ @dirs = [@tmpdir]
+end
+
+After do
+ FileUtils.remove_entry_secure @tmpdir
+end
--- /dev/null
+#-*- coding: utf-8 -*-
+
+require 'erb'
+require 'ostruct'
+require 'yaml'
+
+BASE_SUBSCRIPTIONS = YAML.load(<<END_OF_YAML)
+000001:
+ name: Matthieu Simon-Blavier
+ address:
+ Domain Network Sas
+ 17, square Edouard VII
+ 75009 Paris
+ FR
+ email: registry@domainnetwork.fr
+ membership_fee_paid_on: 2013-02-21
+ notes:
+ Il vient de `whois cogent.fr`.
+000002:
+ name: Sylvain Dufier
+ address:
+ ORANGE FRANCE
+ 13, rue de Javel
+ 75015 Paris
+ email: sylvain.dufier@orange-ftgroup.com
+ membership_fee_paid_on: 2013-05-29
+ Il vient de `whois orange.fr`.
+000003:
+ name: Salim Gasmi
+ SDV PLURIMEDIA
+ 15, rue de la Nuee Bleue
+ 67000 Strasbourg
+ email: domaines@sdv.fr
+ membership_fee_paid_on: 2010-01-21
+ Il vient de `whois numericable.fr`.
+ Et il n'est pas à jour de cotisation.
+END_OF_YAML
+
+EXTRA_SUBSCRIPTION = YAML.load(<<END_OF_YAML)
+name: Franck Rohard
+address:
+ SOCIETE FRANCAISE DU RADIOTELEPHONE - SFR
+ 42, avenue de Friedland
+ 75008 Paris
+email: domains@sfr.com
+membership_fee_paid_on: 2013-04-04
+notes:
+ Il vient de `whois sfr.fr`.
+END_OF_YAML
+
+SUBSCRIPTION_FILE_TEMPLATE = <<'END_OF_TEMPLATE'
+---
+name: <%= name %>
+address:
+ <%= address %>
+email: <%= email %>
+mumbership_fee_paid_on: <%= membership_fee_paid_on %>
+---
+
+<%= notes %>
+END_OF_TEMPLATE
+
+def subscription_filename_for_id(id)
+ "Membres/%06d.mdwn" % id
+end
+
+def render_subscription_file(locals)
+ ERB.new(SUBSCRIPTION_FILE_TEMPLATE).result(OpenStruct.new(locals).instance_eval { binding })
+end