crypto-square: tests are now generated#739
Conversation
| class CryptoSquareCase < Generator::ExerciseCase | ||
|
|
||
| # TODO: remove guard clause when #encoded method | ||
| # is added to crypto_square.rb |
There was a problem hiding this comment.
So the canonical data is a bit off for this exercise. There are several tests in the canonical data that are expecting a method named encode or possibly encoded to be defined on the Crypto class. However, this method is missing from crypto_square.rb
| end | ||
| end | ||
|
|
||
| # TODO: remove when canonical data is fixed |
There was a problem hiding this comment.
The canonical data for one test also has an extra space, which causes the assertion to fail.
| end | ||
|
|
||
| def plaintext_segments | ||
| return [] if normalize_plaintext == '' |
There was a problem hiding this comment.
The canonical data had a test which asserts that an empty array passed into Crypto.plaintext_segments will return an empty array. However, the current Crypto class just blows up when it tries to call each_slice with a size of 0.
| end | ||
|
|
||
| def ciphertext | ||
| return '' if normalize_plaintext == '' |
There was a problem hiding this comment.
The canonical data also had a test which asserts that an empty array passed into Crypto.ciphertext will return an empty string. However, the current Crypto class still just blows up when it tries to call each_slice with a size of 0.
| crypto = Crypto.new('123456789') | ||
| assert_equal 3, crypto.size | ||
| crypto = Crypto.new('Ab Cd') | ||
| assert_equal ["ab", "cd"], crypto.plaintext_segments |
There was a problem hiding this comment.
So these tests seemed to have assertion that differed from what the canonical data wanted.
I went with the canonical data's choice of assertions, because I figured it was more up-to-date.
|
@nholden I should have though to pull from master in my x-common repo! Oh well, nice work with the PR. |
Why?
All tests should be generated as per #396
What?
This PR contains a generator for the crypto-square exercise.
How Has This Been Tested?
bin/generate crypto-squarerake test:crypto-squareTypes of changes
References and Closures
#396
Checklist: