Sha256: 6d9cace0432aad5e26a2ee547c9e4d19e80590513f797c6a4d1b2596c14bf78e
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require 'spec_helper' require 'rails/railtie' describe MultiConfig::Railtie do describe "railtie initialization" do before do # Stub the initializer method and store the block to run later Rails::Railtie.stub(:initializer) { |initializer_name, &block| @railtie_initializer_block = block } # Stub onload to yield directly ActiveSupport.stub(:on_load).and_yield # Remove the class definition MultiConfig.send(:remove_const, :Railtie) end it "inserts the module when railtie hook executes" do # Reload class definition so that class in instantiated and Railitie.initializer is called load 'multi_config.rb' MultiConfig::Railtie.should_receive(:insert).once() # Call the initializer block we stored earlier. We wait so that the file is completely loaded and method Railitie.insert # to be defined first. If we do not wait and yield directly from initializer, it would raise method not found exception # for Railtie.insert since we removed the constant @railtie_initializer_block.call end end describe '#insert' do it "calls included the module in ActiveRecord" do ActiveRecord::Base.should_receive(:send).with(:include, MultiConfig::ORMs::ActiveRecord).once() MultiConfig::Railtie.insert end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
multi_config-1.0.0 | spec/multi_config_spec.rb |
multi_config-0.2.2 | spec/multi_config_spec.rb |
multi_config-0.2.0 | spec/multi_config_spec.rb |