aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2015-12-07 23:36:30 -0500
committerTeddy Wing2015-12-07 23:36:30 -0500
commit67d985ed3047fe9e73b2038a81d96876ab54b63a (patch)
tree752b4773bc542c28abdae9c5930b4577db4b7c5b
parent4e5534b3e29dad49632ae8d2c4f661057fddbe55 (diff)
downloadRuby-Web-Sessions-Exercise-67d985ed3047fe9e73b2038a81d96876ab54b63a.tar.bz2
Add a simple Capybara test
* Add Rakefile to run tests with `rake` * Add a `test_helper` to take care of the setup that Capybara requires in order to run * Add a super basic test to see if Capybara works * Put app in a `Sinatra::Base` subclass so that we can tell Capybara where to find it
-rw-r--r--Rakefile9
-rw-r--r--app.rb8
-rw-r--r--test/integration/auth_test.rb9
-rw-r--r--test/integration_test_helper.rb16
4 files changed, 39 insertions, 3 deletions
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..4308fd1
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,9 @@
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << '.'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+end
+
+task :default => :test
diff --git a/app.rb b/app.rb
index baa9640..6f61f5b 100644
--- a/app.rb
+++ b/app.rb
@@ -1,6 +1,8 @@
-require 'sinatra'
+require 'sinatra/base'
-get '/' do
- 'Hello World'
+class App < Sinatra::Base
+ get '/' do
+ 'Hello World'
+ end
end
diff --git a/test/integration/auth_test.rb b/test/integration/auth_test.rb
new file mode 100644
index 0000000..df60187
--- /dev/null
+++ b/test/integration/auth_test.rb
@@ -0,0 +1,9 @@
+require 'integration_test_helper'
+
+
+class TestAuth < CapybaraTestCase
+ def test_index_has_login_form
+ visit '/'
+ assert_equal 200, page.status_code
+ end
+end
diff --git a/test/integration_test_helper.rb b/test/integration_test_helper.rb
new file mode 100644
index 0000000..4cc35a7
--- /dev/null
+++ b/test/integration_test_helper.rb
@@ -0,0 +1,16 @@
+require 'minitest/autorun'
+require 'capybara'
+
+require 'app'
+
+
+class CapybaraTestCase < Minitest::Unit::TestCase
+ include Capybara::DSL
+
+ def teardown
+ Capybara.reset_sessions!
+ Capybara.use_default_driver
+ end
+end
+
+Capybara.app = App