Sha256: 4826ce199d8843442e2aca84538806b8bc92f7377eb771c84c70c777bd77c5f3

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Railsless::ActiveRecord::Root do
  let(:root) { described_class }

  describe ".calculate" do
    it "uses config.ru and the current working dir to find the app root" do
      dir = fixture('find_root_with_flag')
      expect(Dir).to receive(:pwd).and_return(dir)
      expect(root.calculate).to eq dir
    end
  end

  describe ".to eq dir.find_root_with_flag" do
    it "finds a flag file in the starting directory (eg. current working dir)" do
      starting = fixture('find_root_with_flag')
      expect(root.find_root_with_flag('config.ru', starting)).to eq starting
    end

    it "looks up the tree until it finds the flag file" do
      dir      = fixture('find_root_with_flag')
      starting = File.join(dir, 'bin') # find_root_with_flag/bin
      expect(root.find_root_with_flag('config.ru', starting)).to eq dir
    end

    # If this test explodes on your machine, it probably means you have a
    # config.ru hanging around in a parent directory. :)
    it "explodes when it can't find the flag file" do
      starting = File.dirname(__FILE__)
      expect {
        root.find_root_with_flag('config.ru', starting)
      }.to raise_error(StandardError, "Could not find root path for hosting application")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railsless-active_record-0.0.2 spec/active_record/root_spec.rb
railsless-active_record-0.0.1 spec/active_record/root_spec.rb