diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/.travis.yml b/.travis.yml index 9158c0d..268dd5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ services: couchdb -language: node_js +language: +- node_js +- ruby node_js: "0.12" addons: hosts: @@ -16,6 +18,8 @@ install: - node app/proxy.js >/dev/null & # Install CouchApp - sudo pip install couchapp +# Install Capybara +- gem install capybara-webkit rspec # Install Cassandre - curl -X PUT -d '"false"' localhost:5984/_config/httpd/secure_rewrites - curl -X PUT localhost:5984/cassandre @@ -29,4 +33,6 @@ install: - curl -X PUT localhost:5984/cassandre/iamlate -d '{"corpus":"Wonderland", "name":"I am late"}' - curl -X PUT localhost:5984/_users/org.couchdb.user:hatter -H 'Accept:application/json' -H 'Content-Type:application/json' -d '{"name":"hatter", "password":"teaparty", "roles":[], "type":"user"}' - curl -X PUT localhost:5984/_config/admins/carroll -d '"curiouser"' -script: jasmine-node spec/api/ +script: +- jasmine-node spec/api/ +- xvfb-run rspec spec/features/* diff --git a/spec/features/register.rb b/spec/features/register.rb new file mode 100644 index 0000000..185530e --- /dev/null +++ b/spec/features/register.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +feature 'Register' do + + scenario 'as a new user' do + visit '/register.html#http://couchdb.local:1337/_session' + fill_in 'Username', :with => a_string() + fill_in 'Password', :with => 'secret' + fill_in 'Confirm password', :with => 'secret' + click_on 'submit' + expect(page).to have_content "Your account has been created" + end + + scenario 'not as an existing user' do + visit '/register.html#http://couchdb.local:1337/_session' + fill_in 'Username', :with => 'hatter' + fill_in 'Password', :with => 'secret' + fill_in 'Confirm password', :with => 'secret' + click_on 'submit' + expect(page).to have_content 'username already exists' + end + +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..4c343e1 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,17 @@ +require 'capybara/rspec' +require 'capybara/webkit' + +Capybara.run_server = false +Capybara.default_driver = :webkit +Capybara.app_host = 'http://auth.local:1337' + +RSpec.configure do |config| + config.before(:each) do + page.driver.allow_url 'auth.local' + page.driver.allow_url 'couchdb.local' + end +end + +def a_string() + s = ('a'..'z').to_a.shuffle[0,8].join +end