Advertisement
urbanslug

method_error

Oct 24th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. This is cars.rb:
  2.  
  3.  
  4. class CarImport
  5. attr_reader :car_type
  6. def initialize (type)
  7. @car_type = type
  8. end
  9. end
  10.  
  11. This is tests.rb:
  12.  
  13.  
  14. require 'test/unit'
  15. require_relative 'asserts'
  16.  
  17. class TestAsserts < Test::Unit::TestCase
  18. def test_initialize
  19. car1 = CarImport.new("Toyota")
  20. assert_equal "Toyota", car1.initialize
  21. end
  22. end
  23.  
  24. However I get the following error when I run ruby tests.rb:
  25. `NoMethodError: private method `initialize' called for #<CarImport:0x00000000cbb1a0 @car_type="Toyota">
  26. `
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement