Skip to content

Commit

Permalink
Mini-test attempt (not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheworiordan committed Nov 16, 2011
1 parent 4a0c893 commit 606f1a2
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 17 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Expand Up @@ -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
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions 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
37 changes: 37 additions & 0 deletions 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
9 changes: 0 additions & 9 deletions test/performance/browsing_test.rb

This file was deleted.

17 changes: 9 additions & 8 deletions 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.