Sha256: 61f2baddfb856e994ece684142b5e8e8fd797c05fd0b16aacdaed5535f1207fb

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# This file needs to be in this folder structure otherwise rspec
# will not filter it out of the caller chain, and therefore report
# incorrect file locations for example groups. This especially
# affects turnip mode.

# Monkey patch rspec to block capybara from using feature
class RSpec::Core::Configuration
  alias_method :orig_alias_example_group_to, :alias_example_group_to

  def alias_example_group_to(new_name, *args)
    return if [:feature, :xfeature, :ffeature].include?(new_name)
    orig_alias_example_group_to(new_name, *args)
  end
end

# Monkey patch RSpec to add the feature method in example groups
class RSpec::Core::ExampleGroup
  class << self
    alias_method :orig_subclass, :subclass

    def subclass(parent, description, *all_args, &example_group_block)
      rutabaga = all_args.first.any? { |arg| arg.kind_of?(Hash) && arg[:rutabaga] }

      self.orig_subclass(parent, description, *all_args, &example_group_block).tap do |describe|
        Rutabaga::ExampleGroup::Feature.feature(describe, description, all_args.last) if rutabaga
      end
    end
  end

  define_example_group_method :feature, :rutabaga => true
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rutabaga-3.0.2 lib/rspec/core/example_group_patch.rb
rutabaga-3.0.1 lib/rspec/core/example_group_patch.rb
rutabaga-3.0.0 lib/rspec/core/example_group_patch.rb
rutabaga-2.1.6 lib/rspec/core/example_group_patch.rb
rutabaga-2.1.5 lib/rspec/core/example_group_patch.rb