Skip to content

Conversation

@Steffan153
Copy link
Contributor

@Steffan153 Steffan153 commented Jan 24, 2021

@Steffan153 Steffan153 requested review from a team, Blind4Basics, hobovsky and kazk January 24, 2021 00:18
@Steffan153 Steffan153 linked an issue Jan 24, 2021 that may be closed by this pull request
To avoid the above problems, calls to assertion functions should respect the following rules:
- The expected value should be calculated _before_ invoking an assertion. The `expected` parameter passed to the assertion should not be a lambda/`Proc`/block, but a value calculated directly beforehand.
- Appropriate assertion functions should be used for each given test. `Test.assert_equals` is not suitable in all situations. Use `Test.expect` for tests on boolean values, and `Test.expect_error` to test error handling.
<!-- Use `Test.assert_approx_equals` for floating-point comparisons -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would explicitly mention that there's no assertion for approx equality, because it's somewhat unexpected IMO. Every sane assertions library has it. Snippet is a great idea, just mention it here and link to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add the snippet to the test framework (https://github.com/codewars/ruby-test-framework) that will be used for Ruby 3.0 support. I'm also considering to use RSpec under the hood somehow, then eventually switch to it completely like JS.

@Steffan153 Steffan153 requested a review from error256 January 25, 2021 17:39
- Avoid returning different data types depending on the situation (_"Return the result, or the string 'Error' if no result can be found..."_). Ruby is dynamically typed, which is not the case for some other languages. Returning `nil` might be appropriate in some situations, but throwing an error might be better in others.

Some kata just should not be translated into Ruby because it can be difficult to keep their initial idea:
- Some kata might be meant for another language specifically. For example, a kata about `Python: Learning Classes` should probably not be translated to Ruby, even though Ruby has `class` syntax.
Copy link
Contributor

@Blind4Basics Blind4Basics Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like it's evident. I practice both (well, not much ruby, yeah, but still) and I honestly don't see why this should be avoided in ruby => ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably could, but you'd want to change the kata title at least, right?

Copy link
Contributor

@Blind4Basics Blind4Basics Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... But if it's only about the title, I feel the reason is out of place, then (but maybe it's just me being oriented by what I knew will follow...?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I just need a better example of something that shouldn't... any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something what does not translate well into hashes, or duck typing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can technically do duck typing in Ruby...
Maybe like something about JS coercion? Ruby doesn't have coercion (yay).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn I am so noob in Ruby I have no idea what could apply here.

Maybe dudner methods? Coercion sounds good too.

Maybe just leave this out?

I KNOW! Performance kata do not translate well into Ruby! :D

Copy link
Contributor Author

@Steffan153 Steffan153 Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunder methods sounds right.

Suggested change
- Some kata might be meant for another language specifically. For example, a kata about `Python: Learning Classes` should probably not be translated to Ruby, even though Ruby has `class` syntax.
- Some kata might be meant for another language specifically. For example, a kata about `Python: Dunder Methods` should probably not be translated to Ruby, as Ruby doesn't have dunder methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't ruby classes have def coerce(self,other) mehtods? x)

even dunder methods are a bit edgy because some exist in ruby =, +, ...

maybe step out of python, for this? like "learn the difference int/long" in java/C/... doesn't translate to ruby.

?

Co-authored-by: hobovsky <hobson@wp.pl>
Copy link
Contributor

@hobovsky hobovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but I am no Ruby expert so maybe someone else could also take a look.

Copy link
Member

@kazk kazk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for writing this.

By the way, I'm considering to replace the custom test framework with the built-in minitest from Ruby 3.0. I'm still experimenting, but it should work the same way except for assertions, so this will be still relevant.

@Steffan153 Steffan153 merged commit 087bca6 into master Feb 28, 2021
@Steffan153 Steffan153 deleted the ruby-authoring branch February 28, 2021 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a guide for authoring in Ruby

7 participants