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

gherkin: Cucumber-Ruby integration #444

Merged
merged 6 commits into from
Aug 5, 2018

Conversation

brasmusson
Copy link
Contributor

@brasmusson brasmusson commented Jul 31, 2018

Summary

Changes for the Cucumber-Ruby integration.

Details

  • Provide an interface for passing the feature file content as a string. The testing of Cucumber-Ruby should not require that the test feature files are written to the file system. In version 5.x.x there is an interface for passing the feature file content as a string.
  • Provide the possibility to set the default dialect for the gherkin parser (needed for the parsing of nested steps in Cucumber-Ruby).
  • Implement the --dialects options correctly in the go binary Use the --dialects option (that only works in the binaries built for dist), so that gherkin/ruby/lib/gherkin/gherkin-languages.json can be removed.

Motivation and Context

See Details.

How Has This Been Tested?

The automated test are updated to cover this functionality

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.

The testing of Cucumber-Ruby should not require that test features are
written to the file system, therefor gherkin needs to provide an
interface for passing the feature file content as a string - as it does
v5.x.x.
Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Review comments in-passing: Solid, tiny change, which opens up that related PR - while being self-contained.

args = args.concat(@paths)
stdin, stdout, stderr, wait_thr = Open3.popen3(*args)
stdin.close
messages = ProtobufCucumberMessages.new(stdout, stderr).messages
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this assignment (and the same one in the next method) do anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it could/should be removed.

stdin.binmode
stdin.write(encode_source_message(uri, data))
stdin.close
messages = ProtobufCucumberMessages.new(stdout, stderr).messages
Copy link
Contributor

Choose a reason for hiding this comment

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

(This assignment, does it do anything?)

ProtobufCucumberMessages.new(stdout).messages
args.push("--default-dialect=#{@default_dialect}") unless @default_dialect.nil?
args
end
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 These extracted method are mega-helpful.

aslakhellesoy referenced this pull request Jul 31, 2018
dialect.rb provides a public interface to Cucumber-Ruby.
wrapper_obj = Cucumber::Messages::Wrapper.new
wrapper_obj.source = source_obj
buf = Cucumber::Messages::Wrapper.encode(wrapper_obj)
buf[1..-1] # A leading "\n" needs to be removed
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there an extra \n at the beginning?

Copy link
Contributor Author

@brasmusson brasmusson Aug 1, 2018

Choose a reason for hiding this comment

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

I have absolutely know idea, but without this line the the gherkin-go binary will print

failed to parse Gherkin: parse message: proto: Source: wiretype end group for non-group

to stderr.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found the problem. Protobuf messages written to gherkin-go's STDIN should not be wrapped in a Wrapper object. The Wrapper object is only necessary when the reader expects different kinds of messages.

@brasmusson
Copy link
Contributor Author

brasmusson commented Aug 1, 2018

Now only the proper implementation of the --dialects option in the go binary is needed. (see 1e4c92d#commitcomment-29923196)

@aslakhellesoy aslakhellesoy merged commit c988aa6 into master Aug 5, 2018
@aslakhellesoy
Copy link
Contributor

I updated the API a little to conform with the API in Java/JavaScript. Use this instead:

messages = Gherkin.from_paths(paths)

@brasmusson brasmusson deleted the gherkin-ruby-cucumber-ruby-integration branch August 5, 2018 11:22
@lock
Copy link

lock bot commented Aug 5, 2019

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 Aug 5, 2019
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.

3 participants