Tuesday 15 February 2011

ruby - Rails - Why can't I use a method I created in a module in my tests? -


I have created a module in the Linux directory and I can freely call different methods involved in my tracks app ( ModuleName after adding) is no problem.

However, when it comes to testing, they complain that there are no such methods present. Anyone can try to include the module with any luck in my test assistant.

  4) Error: test_valid_signup_redirects_user_to_spreedly (UsersControllerTest): NoMethodError: Undefined method for spreedlyTools `spreedly_signup_url ': module /test/functional/user_controller_test.rb: 119: in` test_valid_signup_redirects_user_to_spreedly' / code> < / Pre> 
  Module spreadlitles protected def spreedly_signup_url (user) Returns "Blblahah" and End  

  class ApplicationController & lt; ActionController :: Base Assistant: All #All Helpers are included, all time protect_from_forgery # ActionController :: RequestForgery View spreedlyTools for details .... end  

  ENV ["RAILS_ENV"] = "Test" requires File.expand_path (File.dirname (__ FILE__) + "/../config/environment") 'test_help' class ActiveSupport :: TestCase includes SpreedlyTools. .. end  

  requires File.dirname (__ FILE__) + '/../test_helper' requires 'users_controller' # caught by the controller Extend errors again. Classroom UsersController; Def defending_action (e) boost end; Last category UsersControllerTest & lt; ActionController :: Test Sez .... def test_valid_signup_redirects_user_to_spreedly find: new assert_response: success post: create, user = & gt; {: Firstname = & gt; "Bobby" ,: Last_name = & gt; "Brown" ,: email = & gt; "Bobby.brown@gmail.com" ,: email_confirmation = & gt; "Bobby.brown@gmail.com" ,: Password => "Bobby1" ,: password_confirmation = & gt; "Bobby1"} assert_response: User = redirect (redirect) (user) assert_redirected_to spreedlyTools.spreedly_signup_url (user) end and  

Here are some different errors. First, when you create a module and you combine the contents of the module in a class, then the class becomes a square of methods within the module.

He said, the following line does not mean <

Assume that you compose modules in a user category, you must use the method

< Pre> should call.

assert_redirected_to user.new.spreedly_signup_url (user)

Also note the new statement. Because you have the include module in the class and you do not have extension class, the method is not an example method, a class method

  assert_redirected_to user.new .spreedly_signup_url (user) # valid assert_redirected_to user.spreedly_signup_url (user) # invalid  

For this reason, the following line doesn '

  class ActiveSupport :: test Season includes predi ... 

No comments:

Post a Comment