Add framework for system tests
authorTom Hughes <tom@compton.nu>
Sun, 29 Oct 2017 20:58:23 +0000 (20:58 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 15 Nov 2017 19:14:31 +0000 (19:14 +0000)
.travis.yml
Gemfile
Gemfile.lock
lib/tasks/testing.rake
test/application_system_test_case.rb [new file with mode: 0644]
test/system/site_test.rb [new file with mode: 0644]

index 48ddb4a1d09d4e3f1ca0b508c123ee39b0a96b31..8c09cc439edbafae4101d57741cdd29f031f351b 100644 (file)
@@ -28,3 +28,4 @@ script:
   - bundle exec rubocop -f fuubar
   - bundle exec rake jshint
   - bundle exec rake test:db
+  - bundle exec rake test:system
diff --git a/Gemfile b/Gemfile
index fee5fa4d106d28e32e56d3821e65822f63135b50..79d95f9d5af3e7bc91376002e0e3574997c28aa8 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -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
index 08e6c60b440e9f039c303bb5152d5d45c0540f94..b65ec4ed9706fc79e552a0b9a4aa859931275967 100644 (file)
@@ -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)
@@ -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
@@ -393,6 +395,7 @@ DEPENDENCIES
   pg
   poltergeist
   psych
+  puma (~> 3.7)
   r2 (~> 0.2.7)
   rack-cors
   rack-uri_sanitizer
index 3d933a3aa3037305ee2232beeba94c9d1280238c..6335adf876da70ca13d8bdc6327c6a6e001337ff 100644 (file)
@@ -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
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
new file mode 100644 (file)
index 0000000..18d5ec2
--- /dev/null
@@ -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
diff --git a/test/system/site_test.rb b/test/system/site_test.rb
new file mode 100644 (file)
index 0000000..2ecc7f5
--- /dev/null
@@ -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