Reputation: 6269
NoMethodError: undefined method `assert_true'
Am getting above error while running tests using test-unit in ruby. test-unit gem and rake versions are below,
test-unit (2.5.5)
rake (10.1.0)
Sample test file:-
require 'test/unit'
class Sample < Test::Unit::TestCase
def setup
# code block
end
def test_sample
assert_true("test"=="test")
end
def teardown
# code block
end
end
How to solve this ?
Upvotes: 1
Views: 5602
Reputation: 6269
I solved the problem by using following way. No need to change assert statements.
require 'rubygems'
gem 'test-unit'
require 'test/unit'
class Sample < Test::Unit::TestCase
def setup
# code block
end
def test_sample
assert_true("test"=="test")
end
def teardown
# code block
end
end
Upvotes: 2
Reputation: 54674
Since 1.9.2, test/unit is a wrapper around minitest, implemented directly in the ruby source code. The assert_true
method does not exist in the new implementation, just use assert
instead, as Simon Brahan already suggested. So the gem source you were looking at is no longer in use. The now relevant documentation is here.
Upvotes: 0
Reputation: 2076
assert_true
does not appear to be in the list of available assertions for test-unit. Try using assert
. Reference: http://ruby-doc.org/stdlib-2.0.0/libdoc/test/unit/rdoc/Test/Unit/Assertions.html
Upvotes: 1