Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Created October 17, 2012 04:54
Show Gist options
  • Save DylanLacey/3903771 to your computer and use it in GitHub Desktop.
Save DylanLacey/3903771 to your computer and use it in GitHub Desktop.
Testing Code, Results
def ==(other_place)
puts "Checking #{self} == #{other_place}"
if (other_place.is_a?(Place))
puts "Responds"
(@id == other_place.id) && (@name == other_place.name)
else
false
end
end
require "test/unit"
require "../test_helper"
require "mt_data_stone/data_models/place"
class PlaceTest < Test::Unit::TestCase
def test_to_gyoku_hash
test_place = Place.new("Brisbane Airport", 54)
expected_hash = {
:place => "",
:attributes! => {"ins0:place" => {:ID => 54, :Name => "Brisbane Airport"}}
}
assert_equal expected_hash, test_place.to_gyoku_hash
end
def test_equality_method_works
test_place_1 = Place.new("Brisbane Airport", 54)
test_place_2 = Place.new("Brisbane Airport", 54)
assert_equal(test_place_1, test_place_2)
end
end
C:\jruby\jruby-1.7.0.preview1\bin\jruby.exe --1.9 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Projects/MTDataStone/test/unit/place_test.rb
Testing started at 2:52 PM ...
Checking #<Place:0x25343815> == #<Place:0x74dfdc8>
Responds
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
Checking #<Place:0x25343815> == ENV
Checking #<Place:0x74dfdc8> == ENV
<#<Place:0x00000000 @id=54, @value="Brisbane Airport">> expected but was
<#<Place:0x00000000 @id=54, @value="Brisbane Airport">>.
C:/Projects/MTDataStone/test/unit/place_test.rb:22:in `test_equality_method_works'
(eval):12:in `run'
C:/Program Files (x86)/JetBrains/RubyMine 4.5/rb/testing/patch/testunit/test/unit/ui/teamcity/testrunner.rb:93:in `start_mediator'
C:/Program Files (x86)/JetBrains/RubyMine 4.5/rb/testing/patch/testunit/test/unit/ui/teamcity/testrunner.rb:81:in `start'
2 tests, 2 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Test suite finished: 0.092 seconds
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Process finished with exit code 1
==========================CODE UNDER TEST=========================
def ==(other_place)
puts "Checking #{self} == #{other_place}"
if (other_place.is_a?(Place))
puts "Responds"
(@id == other_place.id) && (@name == other_place.name)
else
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment