0

The link that you provided as the answer doesn't exact the same and it doesn't help me to get rid from the error. it said that need to use /index, so I've used in my case /new - and I've got even more error.... So, getting the answer that clarify issue was pretty helpful because this question even it was similar was not duplicate - and I could not use the link that you provide to solve this issue. Once again finding the solution is the most important criteria even for some not understandable reason I've got (-) for asking the question. thanks. I would like to clarify issue as below and don't want to receive (-) for just asking question.

My instructor said that "there are no stupid questions but rather no answered ones.."

I've recently asked 2 questions. One of them was answered immediately, second one was not answered yet. Regardless of this, I've got -2 for both questions...

The question below is regarding ch7, Michael Hartl "Ruby on Rails tutorial": I have error and related file as below. How to fix it?

ERROR["test_should_get_new", UsersControllerTest, 1.258815998211503]
 test_should_get_new#UsersControllerTest (1.26s)
URI::InvalidURIError:         URI::InvalidURIError: bad URI(is not URI?): http://www.example.com:80new
            test/controllers/users_controller_test.rb:4:in `block in <class:UsersControllerTest>'

test/controllers/users_controller_test.rb

require 'test_helper'
class UsersControllerTest < ActionDispatch::IntegrationTest
  test "should get new" do
    get :new
    assert_response :success
  end
end
  • JFYI, the last letter in "Hartl" is "L", not "i" – Sergio Tulentsev Jun 07 '17 at 17:01
  • I find that the tutorial is really well done. Must be you made minor mistakes in configuration a few steps back. I suggest you backtrack and recheck. – Sergio Tulentsev Jun 07 '17 at 17:03
  • I fix the name's error. thanks. Yes, his tutorial is fine. I actually completed it with Rails4, but I think the new one for Rails5 have the new features, like extra picture with a cat, using some deployment features(ch7) - and i have some issue with those. –  Jun 07 '17 at 17:15
  • No, I fixed the name, you un-fixed it. – Sergio Tulentsev Jun 07 '17 at 17:15
  • anyway, the name is correct; thought I could not say the same about the code provided; It has one error. Is it important to get green or it cold be ignored, since the output is fine? –  Jun 07 '17 at 17:18

1 Answers1

0

For testing controllers refer your routes as the full path, instead :new use /users/new, or whatever is the route for the method new in the UsersController:

test 'should get new' do
  get '/users/new'
  assert_response :success
end

Or also you can use the prefix for such route "new_user_path".

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59