Skip to content
Browse files

Mini-test attempt (not working)

  • Loading branch information...
1 parent 4a0c893 commit 606f1a26100354eebd32b1a7bd6d05d7a0151d0c @mattheworiordan mattheworiordan committed
Showing with 64 additions and 17 deletions.
  1. +5 −0 Gemfile
  2. +6 −0 Gemfile.lock
  3. +7 −0 lib/tasks/test.rake
  4. +37 −0 test/integration/basic_test.rb
  5. +0 −9 test/performance/browsing_test.rb
  6. +9 −8 test/test_helper.rb
View
5 Gemfile
@@ -23,4 +23,9 @@ end
group :test, :development do
gem "rspec-rails"
+end
+
+group :test do
+ gem 'minitest' # At least v2.0.2 if using MiniShoulda.
+ gem 'capybara_minitest_spec' # capybara checks for mini test
end
View
6 Gemfile.lock
@@ -43,6 +43,9 @@ GEM
cucumber (>= 1.0)
capybara-webkit (0.7.2)
capybara (>= 1.0.0, < 1.2)
+ capybara_minitest_spec (0.2.1)
+ capybara
+ minitest (~> 2.0)
childprocess (0.2.2)
ffi (~> 1.0.6)
columnize (0.3.4)
@@ -72,6 +75,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
+ minitest (2.8.0)
multi_json (1.0.3)
nokogiri (1.5.0)
polyglot (0.3.3)
@@ -149,8 +153,10 @@ DEPENDENCIES
capybara
capybara-screenshot (~> 0.1)
capybara-webkit
+ capybara_minitest_spec
cucumber
cucumber-rails
+ minitest
rails (~> 3.1)
rspec
rspec-rails
View
7 lib/tasks/test.rake
@@ -0,0 +1,7 @@
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs.push "lib"
+ t.test_files = FileList['test/**/*_test.rb']
+ t.verbose = true
+end
View
37 test/integration/basic_test.rb
@@ -0,0 +1,37 @@
+require 'test_helper'
+
+describe 'Mini test without Capybara' do
+ it "should pass" do
+ true.should == true
+ end
+ it "should fail and not invoke Capybara" do
+ true.should == false
+ end
+end
+
+describe 'Mini test with Capybara' do
+ it "simply returns the original HTML when viewed with Rack" do
+ puts "Running test 1"
+ visit '/rack'
+ page.has_content?('Rack').must_be true
+ click_link('Does not exist')
+ end
+
+ it "generates HTML showing that Javascript under Selenium works" do
+ puts "Running test 2"
+ Capybara.current_driver = :selenium
+ visit '/selenium'
+ page.has_content?('Selenium supports Javascript').must_be true
+ click_link('Does not exist')
+ Capybara.use_default_driver
+ end
+
+ it "generates HTML showing that Javascript under Capybara-webkit works" do
+ puts "Running test 3"
+ Capybara.current_driver = :webkit
+ visit '/webkit'
+ page.has_content?('Webkit supports Javascript').must_be true
+ click_link('Does not exist')
+ Capybara.use_default_driver
+ end
+end
View
9 test/performance/browsing_test.rb
@@ -1,9 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-# Profiling results for each test method are written to tmp/performance.
-class BrowsingTest < ActionDispatch::PerformanceTest
- def test_homepage
- get '/'
- end
-end
View
17 test/test_helper.rb
@@ -1,13 +1,14 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
+require 'minitest/autorun'
+require 'capybara/rails'
- # Add more helper methods to be used by all tests here...
+# If description name ends with 'integration', use this RequestSpec class.
+# It has all the integration test goodies.
+class RequestSpec < MiniTest::Spec
+ include Rails.application.routes.url_helpers
+ include Capybara::DSL
end
+MiniTest::Spec.register_spec_type /integration$/i, RequestSpec
+

0 comments on commit 606f1a2

Please sign in to comment.
Something went wrong with that request. Please try again.