Class: Transpec::Project
- Inherits:
-
Object
- Object
- Transpec::Project
- Defined in:
- lib/transpec/project.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #basename ⇒ Object
- #depend_on_rspec_rails? ⇒ Boolean
-
#initialize(path = Dir.pwd) ⇒ Project
constructor
A new instance of Project.
- #rspec_version ⇒ Object
- #using_bundler? ⇒ Boolean
- #with_bundler_clean_env ⇒ Object
Constructor Details
#initialize(path = Dir.pwd) ⇒ Project
Returns a new instance of Project.
10 11 12 |
# File 'lib/transpec/project.rb', line 10 def initialize(path = Dir.pwd) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/transpec/project.rb', line 8 def path @path end |
Instance Method Details
#basename ⇒ Object
14 15 16 |
# File 'lib/transpec/project.rb', line 14 def basename File.basename(path) end |
#depend_on_rspec_rails? ⇒ Boolean
22 23 24 25 26 27 28 29 30 |
# File 'lib/transpec/project.rb', line 22 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? require 'bundler' gemfile_lock_content = File.read(gemfile_lock_path) lockfile = Bundler::LockfileParser.new(gemfile_lock_content) @depend_on_rspec_rails = lockfile.specs.any? { |gem| gem.name == 'rspec-rails' } end |
#rspec_version ⇒ Object
32 33 34 |
# File 'lib/transpec/project.rb', line 32 def rspec_version @rspec_version ||= RSpecVersion.new(fetch_rspec_version) end |
#using_bundler? ⇒ Boolean
18 19 20 |
# File 'lib/transpec/project.rb', line 18 def using_bundler? File.exist?(gemfile_lock_path) end |
#with_bundler_clean_env ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/transpec/project.rb', line 36 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 |