class Transpec::Project
Attributes
path[R]
Public Class Methods
new(path = Dir.pwd)
click to toggle source
# File lib/transpec/project.rb, line 11 def initialize(path = Dir.pwd) @path = path end
Public Instance Methods
basename()
click to toggle source
# File lib/transpec/project.rb, line 15 def basename File.basename(path) end
depend_on_rspec_rails?()
click to toggle source
# File lib/transpec/project.rb, line 24 def depend_on_rspec_rails? return @depend_on_rspec_rails if instance_variable_defined?(:@depend_on_rspec_rails) return @depend_on_rspec_rails = false unless using_bundler? @depend_on_rspec_rails = dependency_gems.any? { |gem| gem.name == 'rspec-rails' } end
rspec_version()
click to toggle source
# File lib/transpec/project.rb, line 30 def rspec_version @rspec_version ||= RSpecVersion.new(fetch_rspec_version) end
using_bundler?()
click to toggle source
# File lib/transpec/project.rb, line 19 def using_bundler? gemfile_path = File.join(path, 'Gemfile') File.exist?(gemfile_path) end
with_bundler_clean_env() { || ... }
click to toggle source
# File lib/transpec/project.rb, line 34 def with_bundler_clean_env if defined?(Bundler) && using_bundler? Bundler.with_clean_env do # Bundler.with_clean_env cleans environment variables # which are set after bundler is loaded. yield end else yield end end
Private Instance Methods
dependency_gems()
click to toggle source
# File lib/transpec/project.rb, line 48 def dependency_gems return @dependency_gems if @dependency_gems lockfile = Bundler::LockfileParser.new(gemfile_lock_content) @dependency_gems = lockfile.specs end
fetch_rspec_version()
click to toggle source
# File lib/transpec/project.rb, line 64 def fetch_rspec_version if using_bundler? rspec_core_gem = dependency_gems.find { |gem| gem.name == 'rspec-core' } rspec_core_gem.version else require 'rspec/core/version' RSpec::Core::Version::STRING end end
gemfile_lock_content()
click to toggle source
# File lib/transpec/project.rb, line 54 def gemfile_lock_content gemfile_lock_path = File.join(path, 'Gemfile.lock') if File.exist?(gemfile_lock_path) File.read(gemfile_lock_path) else fail GemfileLockNotFoundError, 'Gemfile.lock is missing. Please run `bundle install`.' end end