I'm trying to use minitest with sintara and my issue is that running the test (ruby test_login.rb) is unable to find the login page and when I print out the document html I get the sinatra 404 page. I have no idea how to connect my web app with this test program and all documentation and previous questions I have scoured have nothing that helps me.
Here is my code:
require 'sinatra/base'
require 'minitest/autorun'
require 'rack/test'
require 'minitest/spec'
require 'nokogiri'
require 'rack/test'
require_relative 'login'
class Test < MiniTest::Test`
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_login
response = get ('/home')
doc = Nokogiri::HTML(response.body)
puts last_response
puts doc
#response = post '/login', username: 'test_user', password: 'password'
#get '/home'
#follow_redirect!()
#puts doc
#assert_equal "Admin", doc.at_css("#admin-block div h1")
end
end
Please do not comment asking me to use a different testing gem.
Thank you
Aucun commentaire:
Enregistrer un commentaire