Sha256: 2d88a65c6a43385187f8e2af6b331e00ca600b7cc717e01e6928aa8809199c8a

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

module Zapata
  module Core
    class Loader
      class << self
        def rails_helper_path
          File.expand_path("#{Dir.pwd}/spec/rails_helper",  __FILE__)
        end

        def spec_helper_path
          File.expand_path("#{Dir.pwd}/spec/spec_helper",  __FILE__)
        end

        def helper_name
          if File.exist?("#{rails_helper_path}.rb")
            'rails_helper'
          elsif File.exist?("#{spec_helper_path}.rb")
            'spec_helper'
          else
            raise 'Was not able to load nor rails_helper, nor spec_helper'
          end
        end

        def full_helper_path
          paths = {
            rails_helper: rails_helper_path,
            spec_helper: spec_helper_path,
          }.freeze

          paths[helper_name.to_sym]
        end

        def load_spec_helper
          require "#{full_helper_path}.rb"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zapata-0.0.1 lib/zapata/core/loader.rb