Skip to content

Tests for Word Count pass locally with Ruby 2.6 but fail on Exercism website because test runner is using Ruby 2.5.9  #40

@kcomandich

Description

@kcomandich

In the Word Count exercise, I'm using to_h with a block, which only becomes available in Ruby 2.6.
https://rubyreferences.github.io/rubychanges/2.6.html#to_h-with-a-block

The error shows for this line in my code:
words.to_h {|word| [word, words.count(word)] }

TypeError: wrong element type String at 0 (expected array)

Traceback (most recent call first):
Line 10:in 'to_h'
Line 10:in 'word_count'

I found the Ruby version by adding this in the code editor:
"ruby #{ RUBY_VERSION }p#{ RUBY_PATCHLEVEL }".frog

NoMethodError: undefined method `frog' for "ruby 2.5.9p229":String

[After that, I discovered there's debug method! 😄 ]

I came here from: https://exercism.org/docs/using/solving-exercises/tests-pass-locally
although I see that the code in this repo already has a .ruby-version of ruby-2.6.6.

I also see that https://github.com/exercism/ruby says

You'll need a recent (2.6+) version of Ruby

So I assume at some point the test runner on the website will be updated to 2.6?
Not sure if this is the right place to report this. Thanks! 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions