lundi 22 février 2016

How to run integration tests against through Nginx server + Thin on Rails

I have a Rails 4 integration test which is running and passing as I speak. It runs on Ruby Thin server. Now, I have configured Nginx server which is proxying all the requests and I want my integration test to point to Nginx server and run as they would run directly on Thin server.

How to configure my integration tests so that they can run and pass with Nginx acting as the request handler proxy?

Old: Integration Test -> Thin Server                 (TESTS PASSING FINE !!!!)
New: Integration Test -> Nginx Server -> Thin Server (HOW TO CONFIGURE TESTS ????)

My Nginx server is already up and running with name: www-mynginx-server.com

login_test.rb

require 'test_helper'

class LoginTest < ActionDispatch::IntegrationTest

  setup do
    @user = users(:admin)
  end

  test "login page is displayed on root path" do
    delete '/signout'
    get root_path
    assert redirect?
    assert_redirected_to '/signin'
    follow_redirect!
    assert_template :new
    assert_template %r{\Adevise/sessions/new\Z}
    assert_select "a[href=?]", users_path, count: 0
    assert_select "input[id=?]", 'user_email', count: 1
    assert_select "input[id=?]", 'user_password', count: 1
    assert_select "input[value=?]", 'Log in', count: 1
  end

end

Aucun commentaire:

Enregistrer un commentaire