Skip to content

pig-latin: generate tests using canonical data #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 21, 2017

Conversation

hilary
Copy link
Contributor

@hilary hilary commented Apr 21, 2017

Description

  • lib/pig_latin_cases.rb
  • exercises/pig-latin/example.tt
  • added bookkeeping module to exercises/pig-latin/example.rb

Motivation and Context

How Has This Been Tested?

rake test

Copy link
Contributor

@Insti Insti 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.
My nitpicks are pretty minor things.

require_relative 'pig_latin'

# Common test data version: <%= abbreviated_commit_hash %>
class PigLatinTest < Minitest::Test<% test_cases.each do |test_case| %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a newline here to split the class definition from the template code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Blech. ERB. Adding a newline here causes formatting problems in the generated test file.

Copy link
Member

Choose a reason for hiding this comment

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

I believe you can use a backslash to avoid that? There is also something in ERB itself that lets you ignore the new line.

Minor thing though though.

The generated file being exemplar is more important.

JSON.parse(data)['cases'].
flat_map {|section| section['cases'] }.
each_with_index.
reduce([]) {|cases, (test, i)| cases << PigLatinCase.new(test.merge('index' => i)) }
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit of a mega code pipeline.
I wonder is it possible to add some intention revealing variable names into the mix.

@kotp kotp merged commit 55f7b91 into exercism:master Apr 21, 2017
@kotp
Copy link
Member

kotp commented Apr 21, 2017

Thank you @hilary !

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.

3 participants