Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Test-a-function/Ruby/test-a-function-2.rb
Normal file
28
Task/Test-a-function/Ruby/test-a-function-2.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# palindrome.rb
|
||||
def palindrome?(s)
|
||||
s == s.reverse
|
||||
end
|
||||
|
||||
require 'minitest/spec'
|
||||
require 'minitest/autorun'
|
||||
describe "palindrome? function" do
|
||||
it "returns true if arg is a palindrome" do
|
||||
(palindrome? "aba").must_equal true
|
||||
end
|
||||
|
||||
it "returns false if arg is not a palindrome" do
|
||||
palindrome?("ab").must_equal false
|
||||
end
|
||||
|
||||
it "raises NoMethodError if arg is without #reverse" do
|
||||
proc { palindrome? 42 }.must_raise NoMethodError
|
||||
end
|
||||
|
||||
it "raises ArgumentError if wrong number of args" do
|
||||
proc { palindrome? "a", "b" }.must_raise ArgumentError
|
||||
end
|
||||
|
||||
it "passes a failing test" do
|
||||
palindrome?("ab").must_equal true, "this test case fails on purpose"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue