Skip to content
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

Use --example STRING rather than :linenumber to future-proof #31

Closed
armandofox opened this issue Oct 24, 2018 · 2 comments · Fixed by #33
Closed

Use --example STRING rather than :linenumber to future-proof #31

armandofox opened this issue Oct 24, 2018 · 2 comments · Fixed by #33

Comments

@armandofox
Copy link
Contributor

The current instructions ask the student to run individual specs with something like rspec file_spec.rb:6 to run the example group starting at line 6, but this is fragile if the specs change slightly. A better way may be to say rspec --example "part of spec docstring" file_spec.rb, where the string is an unambiguous match to the docstring of either a particular example or example group.

@tansaku
Copy link
Contributor

tansaku commented Dec 14, 2018

great idea - one immediate issue we have is that it's difficult to unambiguously match the first example group, e.g.

rspec spec/part1_spec.rb --example "#sum"
Run options: include {:full_description=>/\#sum/}

Ruby intro part 1
  #sum
    should be defined
    returns correct sum [20 points] (FAILED - 1)
    works on the empty array [10 points] (FAILED - 2)
  #sum_to_n
    should be defined
    returns true when any two elements sum to the second argument [30 points] (FAILED - 3)
    returns false for any single element array [5 points] (FAILED - 4)
    returns false for an empty array [5 points] (FAILED - 5)

the current "#sum" matches more than one example ... we can't easily use regex - appending a space does work - I guess we hope students will copy and paste:

rspec spec/part1_spec.rb --example '#sum '

@tansaku
Copy link
Contributor

tansaku commented Dec 21, 2018

we've put in a PR for rspec to allow for rspec matching in examples

rspec/rspec-core#2586

If that gets merged in we can tidy up that "#sum " match with the trailing space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants