File: plugin.rb

package info (click to toggle)
ruby-cucumber-wire 0.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 754; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'cucumber/wire/connections'
require 'cucumber/wire/add_hooks_filter'
require 'cucumber/step_match_search'

module Cucumber
  module Wire
    class Plugin
      attr_reader :config
      private :config

      def initialize(config)
        @config = config
      end

      def install
        connections = Connections.new(wire_files.map { |f| create_connection(f) }, @config)
        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)
      end

      def create_connection(wire_file)
        Connection.new(Configuration.from_file(wire_file))
      end

      def wire_files
        # TODO: change Cucumber's config object to allow us to get this information
        config.send(:require_dirs).map { |dir| Dir.glob("#{dir}/**/*.wire") }.flatten
      end
    end
  end
end