More tests and better routes
This commit is contained in:
parent
514108bfc9
commit
d442d083ed
9
app.rb
9
app.rb
|
|
@ -1,10 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
require "roda"
|
||||
|
||||
class App < Roda
|
||||
route do |r|
|
||||
|
||||
r.on do
|
||||
"Hello World!"
|
||||
r.root do
|
||||
"My Homepage"
|
||||
end
|
||||
|
||||
r.get 'about' do
|
||||
"About This Site"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
19
test_app.rb
19
test_app.rb
|
|
@ -19,8 +19,27 @@ class AppTest < Minitest::Test
|
|||
assert true
|
||||
end
|
||||
|
||||
# Make sure not just responding to every path
|
||||
def test_random_page_does_not__exist
|
||||
visit '/skdjflksjdflkzxbjslkdjqweooiumnbvjslkdjflk'
|
||||
refute_equal 200, page.status_code
|
||||
end
|
||||
|
||||
def test_home_page_exists
|
||||
visit '/'
|
||||
assert_equal 200, page.status_code
|
||||
end
|
||||
|
||||
# Can change the checked content as your site evolves:
|
||||
def test_home_page_has_content
|
||||
visit '/'
|
||||
assert_content "My Homepage"
|
||||
end
|
||||
|
||||
def test_about_page_exists_and_has_content
|
||||
visit '/about'
|
||||
assert_equal 200, page.status_code
|
||||
assert_content "About This Site"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue