From 262318b07c8b2cfbbfa08261269a4cdc287a7845 Mon Sep 17 00:00:00 2001 From: Franck Eyraud Date: Thu, 8 Sep 2016 12:42:51 +0200 Subject: [PATCH] TEST: Refactor test run. --- .rspec | 2 ++ .travis.yml | 3 +-- deploy.sh | 6 ++++++ spec/features/Add_work.rb | 2 -- spec/features/Compare_translations.rb | 2 -- spec/features/Create_translation.rb | 2 -- spec/features/Delete_translation.rb | 3 --- spec/features/Delete_work.rb | 2 -- spec/features/Internationalization.rb | 2 -- spec/features/List_works.rb | 2 -- spec/features/Search_concordance.rb | 2 -- spec/features/Set_license.rb | 2 -- spec/init.sh | 6 ++++-- spec/run-tests.sh | 4 ++++ test.sh | 5 +++++ 15 files changed, 22 insertions(+), 23 deletions(-) create mode 100755 deploy.sh create mode 100755 spec/run-tests.sh create mode 100755 test.sh diff --git a/.rspec b/.rspec index 16f9cdb..4a50ee0 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,4 @@ --color --format documentation +--require spec_helper +--order random diff --git a/.travis.yml b/.travis.yml index b86e579..7cad4f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,5 @@ cache: install: - pip install --user couchapp - gem install poltergeist rspec - - spec/init.sh -script: rspec --order random spec/features/*.rb +script: ./test.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..6a2b50b --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +DATABASE=${1-http://localhost:5984/traduxio} + +echo Deploying on $DATABASE +if ! couchapp push couchdb $DATABASE 2> /dev/null; then echo Failed; exit 1; fi diff --git a/spec/features/Add_work.rb b/spec/features/Add_work.rb index ab92803..4b00825 100644 --- a/spec/features/Add_work.rb +++ b/spec/features/Add_work.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Add a work' do background do diff --git a/spec/features/Compare_translations.rb b/spec/features/Compare_translations.rb index ebd84b9..e16959c 100644 --- a/spec/features/Compare_translations.rb +++ b/spec/features/Compare_translations.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Compare translations' do background 'Open work' do diff --git a/spec/features/Create_translation.rb b/spec/features/Create_translation.rb index 21cfe7f..ac0087a 100644 --- a/spec/features/Create_translation.rb +++ b/spec/features/Create_translation.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Create a translation' do given!(:work_metadata) { create_random_work } diff --git a/spec/features/Delete_translation.rb b/spec/features/Delete_translation.rb index 5073d50..5deb94b 100644 --- a/spec/features/Delete_translation.rb +++ b/spec/features/Delete_translation.rb @@ -1,6 +1,3 @@ -require 'spec_helper' -require "translation_helper" - feature "Delete translations" do given!(:work_metadata) { create_random_work } diff --git a/spec/features/Delete_work.rb b/spec/features/Delete_work.rb index 5680e63..4985e68 100644 --- a/spec/features/Delete_work.rb +++ b/spec/features/Delete_work.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Delete a work' do scenario 'Delete full work' do diff --git a/spec/features/Internationalization.rb b/spec/features/Internationalization.rb index a48142b..6a5c494 100644 --- a/spec/features/Internationalization.rb +++ b/spec/features/Internationalization.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Localization' do scenario 'french' do diff --git a/spec/features/List_works.rb b/spec/features/List_works.rb index c9c4b00..955dd93 100644 --- a/spec/features/List_works.rb +++ b/spec/features/List_works.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'List works' do scenario 'List languages' do visit '/works/' diff --git a/spec/features/Search_concordance.rb b/spec/features/Search_concordance.rb index f4707b2..0875fe0 100644 --- a/spec/features/Search_concordance.rb +++ b/spec/features/Search_concordance.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Search for a concordance' do def submitForm diff --git a/spec/features/Set_license.rb b/spec/features/Set_license.rb index 8a5fa21..b9d883d 100644 --- a/spec/features/Set_license.rb +++ b/spec/features/Set_license.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - feature 'Set License' do background 'Open work' do diff --git a/spec/init.sh b/spec/init.sh index 5170806..d85bf8b 100755 --- a/spec/init.sh +++ b/spec/init.sh @@ -1,7 +1,9 @@ #!/bin/bash +dirname=$(dirname "$0") + DATABASE=${1-http://localhost:5984/traduxio} curl -s -X DELETE $DATABASE -o /dev/null -couchapp push couchdb $DATABASE 2> /dev/null -$(dirname $0)/load_data.sh $DATABASE +"$dirname"/../deploy.sh $DATABASE +"$dirname"/load_data.sh $DATABASE diff --git a/spec/run-tests.sh b/spec/run-tests.sh new file mode 100755 index 0000000..ecbe1b2 --- /dev/null +++ b/spec/run-tests.sh @@ -0,0 +1,4 @@ +#!/bin/bash +dirname=$(dirname "$0") + +rspec $dirname/features/*.rb diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..5e89e76 --- /dev/null +++ b/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash +dirname=$(dirname "$0") +DATABASE=${1-} + +"$dirname"/spec/init.sh $DATABASE && "$dirname"/spec/run-tests.sh $DATABASE