diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1861c6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.rake_tasks~ +/temp.db +/vendor/ +/bin/ diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a4aaea9 --- /dev/null +++ b/Gemfile @@ -0,0 +1,15 @@ +source "https://rubygems.org" + +gem "roda" + +# change to gunicorn or passenger if you prefer: +gem "puma" + +group :development, :test do + gem "rerun" +end + +group :test do + gem 'capybara' + gem 'minitest' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..733b9a3 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,65 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + ffi (1.17.2) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + matrix (0.4.3) + mini_mime (1.1.5) + mini_portile2 (2.8.9) + minitest (5.25.5) + nio4r (2.7.4) + nokogiri (1.18.8) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + nokogiri (1.18.8-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.8-x86_64-darwin) + racc (~> 1.4) + public_suffix (6.0.2) + puma (6.6.0) + nio4r (~> 2.0) + racc (1.8.1) + rack (3.1.16) + rack-test (2.2.0) + rack (>= 1.3) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + regexp_parser (2.10.0) + rerun (0.14.0) + listen (~> 3.0) + roda (3.93.0) + rack + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + arm64-darwin + ruby + x86_64-darwin + x86_64-linux + +DEPENDENCIES + capybara + minitest + puma + rerun + roda + +BUNDLED WITH + 2.6.9 diff --git a/README.md b/README.md index daa2679..909dc2c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# roda-step1-single-file-ish +# Roda step 1 - Single File app (sort of) -Example single file Roda web app. There are extra files for launching the server, running tests, the license, etc, but the app itself is all in app.rb. \ No newline at end of file +Example single file Roda web app. There are extra files for launching the server, running tests, the license, etc, but the app itself is all in app.rb. diff --git a/app.rb b/app.rb new file mode 100644 index 0000000..dd2caf7 --- /dev/null +++ b/app.rb @@ -0,0 +1,11 @@ +require "roda" + +class App < Roda + route do |r| + + r.on do + "Hello World!" + end + + end +end diff --git a/config.ru b/config.ru new file mode 100644 index 0000000..c9fa468 --- /dev/null +++ b/config.ru @@ -0,0 +1,3 @@ +require "./app" + +run App.freeze.app diff --git a/myapp.service b/myapp.service new file mode 100644 index 0000000..ff766c0 --- /dev/null +++ b/myapp.service @@ -0,0 +1,17 @@ +[Unit] +Description=My roda template +After=network.target + +[Service] +User=myapp +Group=myapp +WorkingDirectory=/opt/myapp +Environment=RACK_ENV=production + +ExecStart=/usr/bin/puma +TimeoutStopSec=300 +KillMode=mixed +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/test_app.rb b/test_app.rb new file mode 100644 index 0000000..d06a959 --- /dev/null +++ b/test_app.rb @@ -0,0 +1,26 @@ +require 'minitest/autorun' +require 'capybara/minitest' + +require_relative 'app' + +Capybara.app = App + +class AppTest < Minitest::Test + include Capybara::DSL + include Capybara::Minitest::Assertions + + def teardown + Capybara.reset_sessions! + Capybara.use_default_driver + end + + # always passes, just to make sure tests are running + def test_the_truth + assert true + end + + def test_home_page_exists + visit '/' + assert_equal 200, page.status_code + end +end