Codewars handles the "no example tests present" in a strange way, I've seen it on a couple of test suites when updating C# and JS kata. It looks like it's possible to have the example test snippets totally empty, but then strange things happen in the trainer and in the fork editor. Sometimes, the template is inserted, but it disappears when clicking RESET. Sometimes, the template is inserted and then shows up in the diff after publishing as added. So generally it's difficult to say if the template tests you see are there in the DB, and whether they will end up saved to the DB.
# From Ruby 3.0, RSpec is used under the hood.# See https://rspec.info/# Defaults to the global `describe` for backwards compatibility, but `RSpec.desribe` works as well.describe"Example"doit"should return the sum"doexpect(add(1, 1)).toeq(2)
# The following is still supported, but new tests should now use them.# Test.assert_equals(add(1, 1), 2)endend
Hitting the reset button empties the tests, but they were there upon opening it and they're there when pressing fork. Is it fully empty like the reset functionality suggests and is using a default?
Defaults to the global describe for backwards compatibility, but RSpec.desribe works as well.
describe "Example" do
it "should return the sum" do
expect(add(1, 1)).to eq(2)
# The following is still supported, but new tests should now use them.
# Test.assert_equals(add(1, 1), 2)
end
end
should return the sum
#<NoMethodError: undefined method add' for main:Object> main.rb:11:in block (2 levels) in '
/runner/frameworks/ruby/cw-2.rb:180:in wrap_error' /runner/frameworks/ruby/cw-2.rb:72:in it'
/runner/frameworks/ruby/cw-2.rb:206:in it' main.rb:10:in block in '
/runner/frameworks/ruby/cw-2.rb:55:in block in describe' /runner/frameworks/ruby/cw-2.rb:46:in measure'
/runner/frameworks/ruby/cw-2.rb:51:in describe' /runner/frameworks/ruby/cw-2.rb:202:in describe'
main.rb:9:in `'
Sorry, did not notice that you already prepared a fix so I fixed it also.
Awesome job, thanks trashy_incel!
First comment, I solved.
added sample and random tests to Ruby. currently only Java is missing random tests and this is reported there
done
this would be contrary to the Codewars policy that advises against trivial input validation
this would be contrary to the Codewars policy that advises against trivial input validation
added
the lack of sample tests for Ruby has already been reported there
here is a fork that adds them, along with random tests, Ruby 3.0 + RSpec, language-agnostic description
Codewars handles the "no example tests present" in a strange way, I've seen it on a couple of test suites when updating C# and JS kata. It looks like it's possible to have the example test snippets totally empty, but then strange things happen in the trainer and in the fork editor. Sometimes, the template is inserted, but it disappears when clicking RESET. Sometimes, the template is inserted and then shows up in the diff after publishing as added. So generally it's difficult to say if the template tests you see are there in the DB, and whether they will end up saved to the DB.
holy sh...
This comment is hidden because it contains spoiler information about the solution
This is the current sample test code for ruby:
Hitting the
reset
button empties the tests, but they were there upon opening it and they're there when pressingfork
. Is it fully empty like thereset
functionality suggests and is using a default?copy your code then reset the trainer. You probably got an outdated version. If that's enough, don't forget to close the issue.
Ruby: The test is broken. It is only possible to complete the kata when submitting without prior testing. The test seems to be unrelated to the kata.
From Ruby 3.0, RSpec is used under the hood.
See https://rspec.info/
Defaults to the global
describe
for backwards compatibility, butRSpec.desribe
works as well.describe "Example" do
it "should return the sum" do
expect(add(1, 1)).to eq(2)
# The following is still supported, but new tests should now use them.
# Test.assert_equals(add(1, 1), 2)
end
end
should return the sum
#<NoMethodError: undefined method
add' for main:Object> main.rb:11:in
block (2 levels) in '/runner/frameworks/ruby/cw-2.rb:180:in
wrap_error' /runner/frameworks/ruby/cw-2.rb:72:in
it'/runner/frameworks/ruby/cw-2.rb:206:in
it' main.rb:10:in
block in '/runner/frameworks/ruby/cw-2.rb:55:in
block in describe' /runner/frameworks/ruby/cw-2.rb:46:in
measure'/runner/frameworks/ruby/cw-2.rb:51:in
describe' /runner/frameworks/ruby/cw-2.rb:202:in
describe'main.rb:9:in `'
Loading more items...