Sha256: 5a23dc439a8a0118321c0af85ba72ed37d6f42c7bdbb903cc9470bbc1cd527ab
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true require 'rspec' require 'rspec/its' require 'dry-plugins' require 'dry/core/class_builder' RSpec.shared_context 'a plug-ins host' do subject(:host) { described_class } it { is_expected.to respond_to :use } it { is_expected.to respond_to :used_plugins } it { is_expected.to respond_to :plugins } it { is_expected.to respond_to Dry::Plugins.config.registry_method } describe ".const_get #{Dry::Plugins.config.plugins_module_name.inspect}" do subject(:plugins) { host.const_get(Dry::Plugins.config.plugins_module_name) } it { is_expected.to be_a Module } it { is_expected.to respond_to Dry::Plugins.config.registry_method } end end module Dry module Plugins # RSpec helpers for plug-ins module RSpec def an_example_class(name: :Example, parent: nil, &block) class_builder = Dry::Core::ClassBuilder.new( name: name, namespace: ::Object, parent: parent ) host = class_builder.call host.module_eval(&block) if block_given? host end def a_plugins_host(name: :ExamplePluginsHost, parent: nil, &block) an_example_class(name: name, parent: parent) do extend Dry::Plugins instance_exec(&block) end end end end end RSpec.configure do |config| config.include Dry::Plugins::RSpec end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-plugins-0.2.0 | lib/rspec/dry-plugins.rb |