Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minitest support

  • Loading branch information...
commit cf94f7f460f38f55058b3ae6d8c63057a3df610f 1 parent 606f1a2
@mattheworiordan mattheworiordan authored
View
2  .gitignore
@@ -0,0 +1,2 @@
+log/*
+tmp/*
View
6 Gemfile
@@ -26,6 +26,6 @@ group :test, :development do
end
group :test do
- gem 'minitest' # At least v2.0.2 if using MiniShoulda.
- gem 'capybara_minitest_spec' # capybara checks for mini test
-end
+ gem 'minitest'
+ gem 'mini_specunit'
+end
View
9 Gemfile.lock
@@ -38,14 +38,11 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- capybara-screenshot (0.1.2)
+ capybara-screenshot (0.1.3)
capybara (>= 1.0)
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)
@@ -75,6 +72,8 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
+ mini_specunit (0.1.1)
+ minitest
minitest (2.8.0)
multi_json (1.0.3)
nokogiri (1.5.0)
@@ -153,9 +152,9 @@ DEPENDENCIES
capybara
capybara-screenshot (~> 0.1)
capybara-webkit
- capybara_minitest_spec
cucumber
cucumber-rails
+ mini_specunit
minitest
rails (~> 3.1)
rspec
View
42 test/integration/basic_test.rb
@@ -1,37 +1,39 @@
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
+class BasicTest < ActionDispatch::IntegrationTest
+
+ before { Capybara.use_default_driver }
-describe 'Mini test with Capybara' do
- it "simply returns the original HTML when viewed with Rack" do
- puts "Running test 1"
+ it "snapshots the HTML when viewed with Rack and there is a failure" do
visit '/rack'
- page.has_content?('Rack').must_be true
+ assert page.has_content?('Rack')
click_link('Does not exist')
end
- it "generates HTML showing that Javascript under Selenium works" do
- puts "Running test 2"
+ it "snapshots HTML whilst showing that Javascript under Selenium works" do
Capybara.current_driver = :selenium
visit '/selenium'
- page.has_content?('Selenium supports Javascript').must_be true
+ assert page.has_content?('Selenium supports Javascript')
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"
+ it "does not snapshot HTML or screen shot as all the tests pass" do
+ Capybara.current_driver = :webkit
+ visit '/webkit'
+ assert page.has_content?('Webkit supports Javascript')
+ end
+
+ it "screenshots when an assertion fails" do
+ Capybara.current_driver = :webkit
+ visit '/webkit'
+ assert page.has_content?('Webkit Does Not Javascript')
+ end
+
+ it "screenshots when a capybara error happens" do
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
16 test/test_helper.rb
@@ -1,14 +1,14 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
-
-require 'minitest/autorun'
+require 'rails/test_help'
require 'capybara/rails'
+require 'minitest/autorun'
-# 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
+module ActionDispatch
+ class IntegrationTest
+ include Capybara::DSL
+ end
end
-MiniTest::Spec.register_spec_type /integration$/i, RequestSpec
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.