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

Remove cucumber dependency to wire #46

Merged
merged 11 commits into from
Jul 29, 2021
Merged
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo

### Added

- The possibility to verify if the plugin has already been installed or not. To
do so, use `Cucumber::Wire::Plugin.installed?`.
([46](https://github.com/cucumber/cucumber-ruby-wire/pull/46))

### Changed

- `cucumber-wire` is now able to install itself as a plugin into `cucumber-ruby`.
([46](https://github.com/cucumber/cucumber-ruby-wire/pull/46))

### Deprecated

### Removed
Expand Down
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ end
if ENV['CUCUMBER_RUBY']
gem 'cucumber', path: ENV['CUCUMBER_RUBY']
elsif !ENV['CUCUMBER_USE_RELEASED_GEMS']
gem 'cucumber', github: 'cucumber/cucumber-ruby', branch: 'main'
gem 'cucumber', github: 'cucumber/cucumber-ruby', branch: 'deprecate-builtin-wire'
end

gem 'aruba', github: 'cucumber/aruba', branch: 'main' # Waiting for a new release of aruba
53 changes: 53 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Upgrading from 6.0.1 to 6.1.0

Usage of built-in wire protocol with `cucumber-ruby` will be deprecated in cucumber
7.1.0, and removed in cucumber 8.0.0.

The wire protocol will still be available by explicitely using the `cucumber-wire`
gem.

### Before cucumber 7.1.0

Before cucumber 7.1.0, the wire protocol was automatically installed with cucumber,
and automatically activated when it had detected a `.wire` file.

### With cucumber 7.1.0

The wire protocol will work as before, but you will notice a deprecation message.

To prevent the deprecation message to be shown, add the gem `cucumber-wire` to your
Gemfile alongside the `cucumber` one:

```ruby
# Gemfile

# ...

gem "cucumber"
gem "cucumber-wire"

# ...

```

Then install it:

```shell
bundle install
```

And add `require 'cucumber/wire'` in your support code. If you do not have support
code yet, create a new one. For example `features/support/wire.rb`.

```ruby
# features/support/wire.rb
require 'cucumber/wire'
```

The wire protocol will be installed, and no deprecation message will be shown anymore.

### With cucumber 8.0.0

The usage of the built-in wire protocol will be removed. You will have to install
`cucumber-wire` and add `require 'cucumber/wire'` in your support code in order
to continue using it, as explained [above](#with-cucumber-710).
4 changes: 4 additions & 0 deletions features/docstring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Feature: Wire protocol docstrings
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: Run a scenario
Given a file named "features/wired.feature" with:
Expand Down
4 changes: 4 additions & 0 deletions features/erb_configuration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Feature: ERB configuration
Given we're all wired

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: ERB is used in the wire file which references an environment variable that is not set
Given a file named "features/step_definitions/server.wire" with:
Expand Down
4 changes: 4 additions & 0 deletions features/handle_unexpected_response.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Feature: Handle unexpected response
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: Unexpected response
Given there is a wire server running on port 54321 which understands the following protocol:
Expand Down
5 changes: 4 additions & 1 deletion features/invoke_message.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ Feature: Invoke message
port: 54321

"""

And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

@spawn
Scenario: Invoke a step definition which is pending
Expand Down
4 changes: 4 additions & 0 deletions features/snippets_message.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Feature: Snippets message
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

@spawn
Scenario: Wire server returns snippets for a step that didn't match
Expand Down
4 changes: 4 additions & 0 deletions features/step_matches_message.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Feature: Step matches message
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: Dry run finds no step match
Given there is a wire server running on port 54321 which understands the following protocol:
Expand Down
4 changes: 4 additions & 0 deletions features/table_diffing.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Feature: Wire protocol table diffing
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

@spawn
Scenario: Invoke a step definition tries to diff the table and fails
Expand Down
4 changes: 4 additions & 0 deletions features/tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Feature: Wire protocol tags
port: 54321

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: Run a scenario
Given a file named "features/wired.feature" with:
Expand Down
4 changes: 4 additions & 0 deletions features/timeouts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Feature: Wire protocol timeouts
Given we're all wired

"""
And a file named "features/step_definitions/require_wire.rb" with:
"""
require 'cucumber/wire'
"""

Scenario: Try to talk to a server that's not there
Given a file named "features/step_definitions/some_remote_place.wire" with:
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/wire.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'cucumber/wire/plugin'

AfterConfiguration do |config|
Cucumber::Wire::Plugin.new(config).install
AfterConfiguration do |config, registry|
Cucumber::Wire::Plugin.new(config, registry).install
end
6 changes: 6 additions & 0 deletions lib/cucumber/wire/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Plugin
attr_reader :config, :registry
private :config, :registry

def self.installed?
@@installed ||= false
end

def initialize(config, registry)
@config = config
@registry = registry
Expand All @@ -18,6 +22,8 @@ def install
config.filters << Filters::ActivateSteps.new(StepMatchSearch.new(connections.method(:step_matches), @config), @config)
config.filters << AddHooksFilter.new(connections) unless @config.dry_run?
config.register_snippet_generator Snippet::Generator.new(connections)

@@installed = true
end

def create_connection(wire_file)
Expand Down