Adding rspec to command line Ruby program -


i'm doing coding challenge , have simple 1 file ruby program (e.g. processor.rb) accepts arguments via file passed on command line, so:

$ ruby processor.rb < inputs.txt

i'm lost how implement tests (i'm used having ready go in rails app). add them same file (processor.rb)? create separate test file , run separate command?

any appreciated. on surface might seem similar this question none of answers i'm looking for.

there few ways of doing it, do. run rspec --init in top level directory of project, create spec directory containing spec_helper.rb file. creates .rspec hidden file in top level directory, automatically require helper when running rspec.

you can start creating spec files in spec directory. convention, files named <subject>_spec.rb. example, if have class called filetree (and therefore file named file_tree.rb), corresponding spec file file_tree_spec.rb.

you can organise specs in directories - makes no difference. however, tend mimic structure of code i'm testing.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -