summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-07 17:50:37 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-07 17:50:37 +0200
commit6fa3308b9e6955ed12af4e66845b4a7f1af7ca60 (patch)
treec3e46236502f65f9a9f990534dbeef11bbf20155 /tests
parente52e9332df64319b4e892b32e9cfcd4d243e18ef (diff)
added acceptancetest suite
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/Gemfile7
-rw-r--r--tests/acceptance/Gemfile.lock55
-rw-r--r--tests/acceptance/Makefile30
-rw-r--r--tests/acceptance/features/step_definitions/basic_steps.rb25
-rw-r--r--tests/acceptance/features/support/env.rb24
-rw-r--r--tests/acceptance/features/support/headless.rb34
-rw-r--r--tests/acceptance/logs/.gitignore1
-rw-r--r--tests/acceptance/run.sh74
8 files changed, 250 insertions, 0 deletions
diff --git a/tests/acceptance/Gemfile b/tests/acceptance/Gemfile
new file mode 100644
index 000000000..353eb5fe6
--- /dev/null
+++ b/tests/acceptance/Gemfile
@@ -0,0 +1,7 @@
+source 'https://rubygems.org'
+
+gem 'cucumber'
+gem 'capybara'
+gem 'selenium-webdriver'
+gem 'headless'
+gem 'rspec'
diff --git a/tests/acceptance/Gemfile.lock b/tests/acceptance/Gemfile.lock
new file mode 100644
index 000000000..a886a54e9
--- /dev/null
+++ b/tests/acceptance/Gemfile.lock
@@ -0,0 +1,55 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ builder (3.2.0)
+ capybara (2.1.0)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ xpath (~> 2.0)
+ childprocess (0.3.9)
+ ffi (~> 1.0, >= 1.0.11)
+ cucumber (1.3.1)
+ 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)
+ headless (1.0.1)
+ mime-types (1.23)
+ multi_json (1.7.3)
+ nokogiri (1.5.9)
+ rack (1.5.2)
+ rack-test (0.6.2)
+ rack (>= 1.0)
+ rspec (2.13.0)
+ rspec-core (~> 2.13.0)
+ rspec-expectations (~> 2.13.0)
+ rspec-mocks (~> 2.13.0)
+ rspec-core (2.13.1)
+ rspec-expectations (2.13.0)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.13.1)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.32.1)
+ childprocess (>= 0.2.5)
+ multi_json (~> 1.0)
+ rubyzip
+ websocket (~> 1.0.4)
+ websocket (1.0.7)
+ xpath (2.0.0)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara
+ cucumber
+ headless
+ rspec
+ selenium-webdriver
diff --git a/tests/acceptance/Makefile b/tests/acceptance/Makefile
new file mode 100644
index 000000000..cdaf74b8f
--- /dev/null
+++ b/tests/acceptance/Makefile
@@ -0,0 +1,30 @@
+# ownCloud - News
+#
+# @author Bernhard Posselt
+# @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+# This makefile is for general project specific stuff like packaging a new
+# release for the app store and running php unittests which require core
+
+bash=/bin/bash
+
+all: acceptance
+
+acceptance:
+ $(bash) run.sh
+
+headless:
+ export HEADLESS=true && $(bash) run.sh \ No newline at end of file
diff --git a/tests/acceptance/features/step_definitions/basic_steps.rb b/tests/acceptance/features/step_definitions/basic_steps.rb
new file mode 100644
index 000000000..81ae4cae0
--- /dev/null
+++ b/tests/acceptance/features/step_definitions/basic_steps.rb
@@ -0,0 +1,25 @@
+Given (/^I am logged in$/) do
+
+ # be sure to use the right browser session
+ Capybara.session_name = 'test'
+
+ # logout - just to be sure
+ visit '/index.php?logout=true'
+ visit '/'
+ fill_in 'user', with: 'test'
+ fill_in 'password', with: "test"
+ click_button 'submit'
+
+ #save_page
+ page.should have_selector('a#logout')
+end
+
+When (/^I am in the "([^"]*)" app$/) do |app|
+ visit "/index.php/apps/#{app}"
+ page.should have_selector('#logout')
+end
+
+When (/^I go to "([^"]*)"$/) do |path|
+ visit "#{path}"
+ page.should have_selector('#logout')
+end \ No newline at end of file
diff --git a/tests/acceptance/features/support/env.rb b/tests/acceptance/features/support/env.rb
new file mode 100644
index 000000000..ab2d6b3c6
--- /dev/null
+++ b/tests/acceptance/features/support/env.rb
@@ -0,0 +1,24 @@
+require 'bundler/setup'
+require 'capybara/cucumber'
+require 'selenium-webdriver'
+
+Encoding.default_external = Encoding::UTF_8
+Encoding.default_internal = Encoding::UTF_8
+
+Capybara.register_driver :selenium do |app|
+ http_client = Selenium::WebDriver::Remote::Http::Default.new
+ http_client.timeout = 200
+ Capybara::Selenium::Driver.new(app, :browser => :firefox, :http_client => http_client)
+end
+
+#
+# app and app_host are set via command line parameter on cucumber call:
+# cucumber HOST=33.33.33.10
+#
+host = ENV['HOST']
+host ||= '33.33.33.10'
+Capybara.app = host
+Capybara.run_server = false
+Capybara.app_host = "http://#{host}"
+Capybara.default_selector = :css
+Capybara.default_driver = :selenium
diff --git a/tests/acceptance/features/support/headless.rb b/tests/acceptance/features/support/headless.rb
new file mode 100644
index 000000000..a2095205f
--- /dev/null
+++ b/tests/acceptance/features/support/headless.rb
@@ -0,0 +1,34 @@
+# only run when export HEADLESS=true
+if ENV['HEADLESS'] == 'true'
+
+ require 'headless'
+
+ headless = Headless.new
+ headless.start
+
+ at_exit do
+ headless.destroy
+ end
+
+ Before do
+ #headless.video.start_capture
+ end
+
+ After do |scenario|
+ # for demo purpose: always record ;-)
+ #video= video_path(scenario)
+ #puts "Writing video to #{File.expand_path(video)}"
+ #headless.video.stop_and_save(video)
+
+ # if scenario.failed?
+ # headless.video.stop_and_save(video_path(scenario))
+ # else
+ # headless.video.stop_and_discard
+ # end
+ end
+
+ def video_path(scenario)
+ "#{scenario.name.split.join("_")}.mov"
+ end
+
+end \ No newline at end of file
diff --git a/tests/acceptance/logs/.gitignore b/tests/acceptance/logs/.gitignore
new file mode 100644
index 000000000..a6c57f5fb
--- /dev/null
+++ b/tests/acceptance/logs/.gitignore
@@ -0,0 +1 @@
+*.json
diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh
new file mode 100644
index 000000000..f9cb2086f
--- /dev/null
+++ b/tests/acceptance/run.sh
@@ -0,0 +1,74 @@
+# ownCloud - News
+#
+# @author Bernhard Posselt, Thomas Müller, Jakob Sack
+# @copyright 2013 Bernhard Posselt nukeawhale@gmail.com
+# @copyright 2012-2013 Thomas Müller thomas.mueller@tmit.eu
+# @copyright 2012-2013 Jakob Sack
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+# set up rvm and xvfb dependencies
+if [[ ! -e "/usr/bin/xvfb-run" ]]; then
+
+ # archlinux
+ if [[ -e "/usr/bin/pacman" ]]; then
+ echo "installing xvfb, please enter password..."
+ sudo pacman -S xorg-server-xvfb
+
+ # fedora
+ elif [[ -e "/usr/bin/yum" ]]; then
+ echo "installing xvfb, please enter password..."
+ yum install xorg-x11-server-Xvfb
+
+ # debian
+ elif [[ -e "/usr/bin/apt-get" ]]; then
+ echo "installing xvfb, please enter password..."
+ sudo apt-get install xvfb
+
+ else
+ echo "You have to install xvfb in order to run the test suite"
+ exit 1
+ fi
+fi
+
+# dont use --user-install for gems since this breaks rvm. abort setup in case it
+# exists
+if [[ -e "/etc/gemrc" ]]; then
+ if grep -qe "^[^#].*user-install" /etc/gemrc; then
+ echo "Found --user-install in /etc/gemrc"
+ echo "Please remove it, as it will break rubygems in RVM."
+ exit 1
+ fi
+fi
+
+# set up rvm
+if [[ -f "$HOME/.rvm/scripts/rvm" ]]; then
+ source "$HOME/.rvm/scripts/rvm"
+elif [[ -f "/usr/local/rvm/scripts/rvm" ]]; then
+ source "/usr/local/rvm/scripts/rvm"
+else
+ # set up a local rvm installation
+ curl -L get.rvm.io | bash -s stable
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
+fi
+
+
+# Set the gemset and ruby version
+rvm install 2.0.0
+rvm use ruby-2.0.0@oc_acceptance --create
+
+bundle install
+cucumber -f json -o ./logs/owncloud.json -f pretty HOST=localhost/owncloud features \ No newline at end of file