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

Fix DataTable's Location to be aware of all of its lines #142

Merged

Conversation

botandrose
Copy link
Contributor

@botandrose botandrose commented Aug 2, 2017

Hi folks! I'm back with another DataTable-related bugfix. When being built, DataTables would build their Ast::Location with only the first line. In the following example feature, this led to commands like cucumber features/test.feature:5 working, but cucumber features/test.feature:6 not running any tests, because no Test::Case reported containing that line.

Scenario: Run scenario with a data table
  Given a file named "features/test.feature" with:
    """
    Feature: 

      Scenario: DataTable
        Given this step is a table step
          | a | b |
          | c | d |
    """
  When I run `cucumber features/test.feature:6 --format pretty --quiet`
  Then it should pass with exactly:
    """
    Feature: 

      Scenario: DataTable
        Given this step is a table step
          | a | b |
          | c | d |

    1 scenario (1 passed)
    1 step (1 passed)
      
    """

How Has This Been Tested?

I'm not quite sure how best to test this. My first inclination is to add a unit test, but there appear to be no unit tests in this project for Cucumber::Core::Gherkin::AstBuilder or any of its internals. The cucumber acceptance test above could be added to the parent cucumber/cucumber-ruby project, but it seems a bit too edge-casey for a full acceptance test, IMO. Thoughts?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mattwynne
Copy link
Member

mattwynne commented Aug 17, 2017

Hello @botandrose!

It looks like the rest of the specs for location matching are here: https://github.com/cucumber/cucumber-ruby-core/blob/master/spec/cucumber/core/test/filters/locations_filter_spec.rb

Maybe just add another example after this one?

@botandrose botandrose force-pushed the fix_data_table_location_lines branch 2 times, most recently from c01a0cd to 09009a0 Compare August 18, 2017 17:57
@botandrose botandrose force-pushed the fix_data_table_location_lines branch from 09009a0 to eca5299 Compare August 18, 2017 17:58
@botandrose
Copy link
Contributor Author

@mattwynne Thanks for the pointer! Indeed, that appears to be exactly the right place to add tests for this. I just rebased, squashed, and force-pushed.

As an aside, I've only recently gotten the commit-bit. What's the etiquette for merging PRs? Can I merge my own PRs in clear-cut situations like this?

@botandrose botandrose requested a review from mattwynne August 18, 2017 19:46
@aslakhellesoy aslakhellesoy self-requested a review August 18, 2017 22:28
Copy link
Contributor

@aslakhellesoy aslakhellesoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @botandrose - I've reviewed this and I approve! Nice fix, good tests and clean code!

Go ahead and merge. I'd like to review a few more pull requests before we offer you a seat by the core team if you don't mind. Then you'll be free to merge your own pull requests (reviews will be at your discretion).

Keep up the good work!

@botandrose
Copy link
Contributor Author

Roger that! Thanks for the review!

@botandrose botandrose merged commit 0855c55 into cucumber:master Aug 18, 2017
@aslakhellesoy
Copy link
Contributor

Hi @botandrose,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

@botandrose botandrose deleted the fix_data_table_location_lines branch August 18, 2017 22:35
@aslakhellesoy
Copy link
Contributor

@botandrose - one more thing. Please update the changelog - you can do it on master. Add an entry to the top.

Thanks
Aslak

@botandrose
Copy link
Contributor Author

Sorry for the delay... just got back into town from the eclipse 🌑! HISTORY.md is updated.

@botandrose botandrose restored the fix_data_table_location_lines branch November 15, 2017 23:20
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 21, 2018
## [3.0.0](cucumber/cucumber-ruby-core@v3.0.0.pre.2...v3.0.0) (2017-09-27)

### Changed

* Step#name renamed to #text ([#137](cucumber/cucumber-ruby-core#137) [@olleolleolle](https://github.com/olleolleolle))
* Use past tense in event names (`xStarting` -> `xStarted`) (see [cucumber/cucumber-ruby#1166](cucumber/cucumber-ruby#1166) @brasmusson).

### Added

* Do not create test cases for scenarios with no steps ([#144](cucumber/cucumber-ruby-core#144) @brasmusson)
* Handle selective strict settings ([#143](cucumber/cucumber-ruby-core#143) @brasmusson)

### Fixed

* Fix DataTable's Location to be aware of all of its lines ([#142](cucumber/cucumber-ruby-core#142) @botandrose)

### Improved

* As per [#251](cucumber/common#251): renamed History.md to CHANGELOG.md, added contributing message at beginning, and misc formatting. ([#145](cucumber/cucumber-ruby-core#145) [jaysonesmith](https://github.com/jaysonesmith))

## [3.0.0.pre.2](cucumber/cucumber-ruby-core@v2.0.0...3.0.0.pre.2) (2017-07-26)

### New Features

* Add a flaky result type to be used for flaky scenarios ([#141](cucumber/cucumber-ruby-core#141), [cucumber/cucumber-ruby#1044](cucumber/cucumber-ruby#1044) @brasmusson)
* Make the Summary report able to say if the total result is ok ([#140](cucumber/cucumber-ruby-core#140) @brasmusson)
* Replay previous events to new subscribers ([#136](cucumber/cucumber-ruby-core#136) @mattwynne)
* Ruby 2.4.0 compatibility ([#120](cucumber/cucumber-ruby-core#120) @junaruga)
* Use tag expressions ([#116](cucumber/cucumber-ruby-core#116) @brasmusson)
* Access example table row data by param name ([#118](cucumber/cucumber-ruby-core#118) @enkessler)

### Bugfixes

N/A

### Removed Features

N/A

### Refactoring

* Travis: jruby-9.1.10.0 ([#130](cucumber/cucumber-ruby-core#130) @olleolleolle)
* Travis: jruby-9.1.12.0 ([#133](cucumber/cucumber-ruby-core#132) @olleolleolle)
@lock
Copy link

lock bot commented Nov 15, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 15, 2018
@botandrose botandrose deleted the fix_data_table_location_lines branch August 20, 2022 12:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants