Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Build a Simple Ruby on Rails Application Testing the Whole App Before Filters

Testing the Whole App - tests are hanging/not running

ruby -Itest/integration/custom_routes_test.rb and ruby -Itest/functional/statuses_controller_test.rb are hanging. When I ctrl-c out of them, (after several minutes) i get: ruby: Interrupt. Any suggestions?

3 Answers

The tests are posted below

custom_routes.rb:

require 'test_helper'

class CustomTest < ActionDispatch::IntegrationTest
    test "that /login route opens the login page" do
     get "/login"
     assert_response :success
    end

    test "that /logout route opens the logout page" do
     get "/logout"
     assert_response :redirect
     assert_redirected_to '/'
    end
end

statuses_controller_test.rb:

require 'test_helper'

class StatusesControllerTest < ActionController::TestCase
  setup do
    @status = statuses(:one)
  end

  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:statuses)
  end

  test "should get new" do
    get :new
    assert_response :redirect
    assert_redirected_to login_path
  end


  test "should create status" do
    assert_difference('Status.count') do
      post :create, status: { content: @status.content, name: @status.name }
    end

    assert_redirected_to status_path(assigns(:status))
  end

  test "should show status" do
    get :show, id: @status
    assert_response :success
  end

  test "should get edit" do
    get :edit, id: @status
    assert_response :success
  end

  test "should update status" do
    put :update, id: @status, status: { content: @status.content}
    assert_redirected_to status_path(assigns(:status))
  end

  test "should destroy status" do
    assert_difference('Status.count', -1) do
      delete :destroy, id: @status
    end

    assert_redirected_to statuses_path
  end
end

for ruby -Itest/integration/custom_routes_test.rb I realized I was trying to call it by the wrong name. So I recreated the test with the correct name and same content, tried to run it, but it's still hanging.