Topic: Why this wierd error when I write test case in unit tests

I have the following code,

require 'test_helper'

class StudentTest < ActiveSupport::TestCase
  fixtures :all
  # Replace this with your real tests.
  test "the truth" do
    assert true
  end

  def test_payment_for_invalid_student

    # Simulate a POST response with the given HTTP parameters.
    post_url = '/payments'
    #get :payments
    get('/students')
    #post(post_url, :payments => { :amount_paid => 200283, :create_on => Time.now, :student_id => 10000 })


    #assert_post_form form_url
    #assert_field form_url, :text, :model_object, :field_name
    #assert_field form_urm, :text, :model_object, :other_field
    #assert_submit form_url, 'Submit'


    # Assert that the controller tried to redirect us to
    # the created book's URI.
    #sassert_response :error

    # Assert that the controller really put the book in the database.
    #assert_not_nil Book.find_by_title("Love Hina")   

  end
end

I get the following error

  1) Error:
test_payment_for_invalid_student(StudentTest):
NoMethodError: undefined method `get' for #<StudentTest:0xb6e38404>
    /test/unit/student_test.rb:15:in `test_payment_for_invalid_student'

3 tests, 2 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ru...]

Any help with this is highly appreciable.

Thank you,
Pcoder

Re: Why this wierd error when I write test case in unit tests

Hi your problem is that you are using controller test and the class is defined as StudentTest not StudentControllerTest so you can make http request, I asume that this file is in units folder, you need to change the class and alocate it in functional folder.