require_relative "../helper" require_relative "../../lib/fabriq" describe Fabriq do describe '.root' do it "returns an instance of Pathname" do Fabriq.root.must_be_kind_of(Pathname) end it "points to the current running root directory" do Fabriq.root.to_s.must_equal(File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))) end end describe '.config' do it "yields Fabriq::Config to the provided block" do Fabriq.config { |config| config.must_equal(Fabriq::Config) } end end describe '.boot' do before do Fabriq::Config.stubs(:load) Fabriq::Adapter.stubs(:load) Fabriq::Adapter.stubs(:run).yields Fabriq.stubs(:load_environment) end it "loads the Config module" do Fabriq::Config.expects(:load) Fabriq.boot end it "loads the Adapter module" do Fabriq::Adapter.expects(:load) Fabriq.boot end it "loads the runtime environment encapsuled in Adapter#run" do Fabriq::Adapter.expects(:run).yields Fabriq.expects(:load_environment) Fabriq.boot end end describe '.load_environment' do it "initializes the PluginPort" do Fabriq::PluginPort.expects(:initialize_plugins) Fabriq.load_environment end describe 'with command line arguments' do before do Fabriq.stubs(:argv).returns(["args"]) end it "run the CLI module" do Fabriq::CLI.expects(:run).with(["args"]) Fabriq.load_environment end end end end