Test being skipped. Don't know why

I am learning Ruby from Zed A. Shaw’s Learn Ruby The Hard Way.

I have come to this exercise and I am kinda stuck here.

[email protected]:/media/shakib/projects/ex49$ rake test
/home/shakib/.rvm/rubies/ruby-2.2.3/bin/ruby -I"lib:tests"

“/home/shakib/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/rake/rake_test_loader.rb”
“tests/test_parse.rb”
Run options:

# Running tests:

[2/3] ParseTest#test_parse_verb = 0.00 s
1) Skipped:
ParseTest#test_parse_verb [stop]:
[["noun", "I"], ["verb", "go"], ["direction", "inside"]]

Finished tests in 0.005502s, 545.2443 tests/s, 908.7405

assertions/s.
3 tests, 5 assertions, 0 failures, 0 errors, 1 skips

ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

So that’s the terminal that shows 1 test being skipped.
Can any of you pros direct me to the correct direction here.

ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

What testing framework do you have? Since Ruby 2.2.3 testing frameworks
are not bundled, but are available as gems.
Do you have any of these gems?

  • test-unit
  • minitest

Földes László wrote in post #1179048:

ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

What testing framework do you have? Since Ruby 2.2.3 testing frameworks
are not bundled, but are available as gems.
Do you have any of these gems?

  • test-unit
  • minitest

minitest gem is installed… test-unit isn’t.

If ‘minitest’ is installed I don’t even know why the entire test runs at
all :slight_smile:

If you’d install Ruby 2.2.3 from scratch (and not upgrading from earlier
versions) test-unit wouldn’t get installed so “require ‘test/unit’”
should fail.

BUT: you are calling methods from the test that doesn’t exist in
‘lexicon.rb’:

def test_peek()
word_list = [[‘noun’, ‘I’],[‘verb’, ‘go’],[‘direction’, ‘inside’]]
assert_equal(peek(word_list), ‘noun’)
end

The #peek method doesn’t exist (only #initialize, #scan and
#convert_number)

Rewrite the test: 1. to use minitest (minitest has different testing
paradigms, choose the one that resembles most to the test/unit
TestCase), 2. call the proper methods

=========
Hint: You are using nested method definition here:

def scan(input)
input = input.split
out = []

def convert_number(inp)
  begin
    Integer inp

Ruby has NO nested methods. Up until the point #scan is not invoked,
#convert_number won’t exist.

MUHAHAHA :slight_smile:

You defined you own ‘skip’ method, but this is also a special keyword to
the Unit testing gem, and it instructs the test to skip.

I renamed the method (and all of its invocations) to some neutral word
(‘skipm’), and the problem is solved.

Thanks a lot!!

Finally the test is working!!
Renamed the skip function in parse.rb to skipper and voila! :slight_smile:

A side note: give your class and method names something more
descriptive, do not be afraid of them being 20-30 characters long, like
“use_readable_variables”.

Thanks for your help.
I have attached the parse.rb file where I have declared the peek and
other methods.

And it seems like I have another gem installed named
“test-unit-minitest”
I forgot to notify that to you before because I was using 1.9.3.
When I switched to 2.2.3 I noticed this gem.

Thanks for the advice. Really appreciate it.

I’m just learning ruby from this book.
I will try to be more descriptive when declaring functions and variables
from now on.
:slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs