Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
when 1.6 != 1.6? -- newbie
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mel Bohince, post: 4466636"] Really enjoying Ruby so far, but now I'm confused. To help learn Ruby, I've been translating the Java code in the "Head First Design Patterns" book into Ruby, aware that many are built-in with Ruby. While mimicking the Decorator pattern I'm getting a strange failure to an assert_equal. The unit test excerpts: @e = Expresso.new @e.setSize('grande') @e = Mocha.new(@e) assert_equal(1.40, @e.cost(),"price check") --> pass @e = Mocha.new(@e) assert_equal("Expresso, Mocha, Mocha", @e.getDescription()) --> pass #puts @e.cost() --> 1.6 ##sanity check, should be 1.00 + 0.20 + 0.20 + 0.20 = 1.6 ##### assert_equal(1.6, @e.cost(),"price check2") --> fail with: 1) Failure: testConcreteCondiment(TestBeverages) [/Users/mel/Documents/Ruby_files/patterns/decorator/test/ testbeverages.rb:70]: price check2. <1.6> expected but was <1.6>. 5 tests, 21 assertions, 1 failures, 0 errors Recreated in irb, the instance looks like: => #<Mocha:0x7a884 @beverage=#<Mocha:0x21c94 @beverage=#<Expresso:0x58310 @description="Expresso", @size=0.2>>> Any clues to what I'm doing wrong? Is there a strategy to debug this kind of thing? The debugger is not like I'm use too. Thanks for any help you can offer. Ruby 1.8.2 on OSX 10.3.8 -: -: -: -: -: -: -: -: \|/ -: -: -: -: -: -: -: -: cU Mel Bohince Project Manager, Arkay Packaging Corporation [email]feet@att.net[/email] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
when 1.6 != 1.6? -- newbie
Top