Sha256: 31d5d039d06546c6d1c1b38468f88c3b3acf7388bd965bc4c9482f53a2b72721

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true
#
RSpec.shared_examples 'Specialized Class Finder' do
  let(:builder) { Formtastic::FormBuilder.allocate }
  subject(:finder) { described_class.new(builder) }

  context 'by default' do
    it 'includes Object and the default namespaces' do
      expect(finder.namespaces).to eq([Object, default])
    end
  end

  context 'with namespace configuration set to a custom list of modules' do
    before do
      stub_const('CustomModule', Module.new)
      stub_const('AnotherModule', Module.new)

      allow(Formtastic::FormBuilder).to receive(namespaces_setting)
                                          .and_return([ CustomModule, AnotherModule ])
    end

    it 'includes just the custom namespaces' do
      expect(finder.namespaces).to eq([CustomModule, AnotherModule])
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
formtastic-5.0.0 spec/support/specialized_class_finder_shared_example.rb