ruby - Getting Implicit Converstion Error -


i have created item class , trying rake test it. when running code outside test no errors thrown. because of assume testing wrong.

    class item         attr_accessor :name, :description, :item            def initialize (item, description, name)                 @name = item[:name]                 @description = item[description]            end     end 

and code using test

    require "asheron's_call/item.rb"     require "test/unit"        class testgame < test::unit::testcase        def test_item       1 = item.new ("potion","red")       assert_equal("potion", one.name)     end   end      =>93: 1 = item.new ("potion","red")      94:  assert_equal("potion", one.name 

when running test getting new error syntax error. expecting ')' after potion. when changed see happen , came saying expected me place 'end' me feels wrong.

the test fine. item’s constructor not:

class item     attr_accessor :name, :description     def initialize (name, description)       @name = name       @description = description     end end 

there no item there. also, in test 1 should assert instance, not class:

# wrong: assert_equal("potion", item.name) assert_equal("potion", one.name) 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -