Skip to content

Commit

Permalink
Add framework for system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Nov 15, 2017
1 parent aa1fb6d commit 9e929de
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ script:
- bundle exec rubocop -f fuubar
- bundle exec rake jshint
- bundle exec rake test:db
- bundle exec rake test:system
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ end

# Needed in development as well so rake can see konacha tasks
group :development, :test do
gem "capybara", "~> 2.13"
gem "coveralls", :require => false
gem "factory_bot_rails"
gem "jshint"
# gem "konacha"
gem "poltergeist"
gem "puma", "~> 3.7"
end
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ GEM
progress (3.4.0)
psych (2.2.4)
public_suffix (3.0.0)
puma (3.10.0)
r2 (0.2.7)
rack (2.0.3)
rack-cors (1.0.2)
Expand Down Expand Up @@ -359,6 +360,7 @@ DEPENDENCIES
autoprefixer-rails
bigdecimal (~> 1.1.0)
canonical-rails
capybara (~> 2.13)
coffee-rails (~> 4.2)
composite_primary_keys (~> 10.0.0)
coveralls
Expand Down Expand Up @@ -393,6 +395,7 @@ DEPENDENCIES
pg
poltergeist
psych
puma (~> 3.7)
r2 (~> 0.2.7)
rack-cors
rack-uri_sanitizer
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/testing.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace :test do
task "lib" => "test:prepare" do
$LOAD_PATH << "test"
Minitest.rake_run(["test/lib"])
Rails::TestUnit::Runner.rake_run(["test/lib"])
end
end
14 changes: 14 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "test_helper"
require "capybara/poltergeist"

WebMock.disable_net_connect!(:allow_localhost => true)

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :poltergeist, :screen_size => [1400, 1400]

def initialize(*args)
stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
.to_return(:status => 404)
super(*args)
end
end
9 changes: 9 additions & 0 deletions test/system/site_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "application_system_test_case"

class SiteTest < ApplicationSystemTestCase
test "visiting the index" do
visit "/"

assert_selector "h1", :text => "OpenStreetMap"
end
end

0 comments on commit 9e929de

Please sign in to comment.