Skip to content

require vs. require_relative - hello exercise #8

@ianalexh

Description

@ianalexh

https://github.com/alexch/learn_ruby/tree/master/00_hello

This is for everyone's benefit:

I think this is partially because I'm running Ruby 2.0.0, not 1.8.7

When I try "rspec hello_spec.rb" from the Terminal, I get that it can't load the "hello" file, with a listing of directories that it tried to load it from.

I did not define those directories, nor do I know if I can change them.

However, a little research shows me that I can use the "require_relative" method instead of simply "require." Then, if I put "hello.rb" in the same folder as "hello_spec.rb", I can run the test and everything works out.

That took me an hour, so I hope this post saves somebody some time!

  • ianalexh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions