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
-
#initialize(path = Dir.pwd) ⇒ Project
constructor
A new instance of Project.
- #require_bundler? ⇒ Boolean
- #rspec_version ⇒ Object
- #with_bundler_clean_env ⇒ Object
Constructor Details
#initialize(path = Dir.pwd) ⇒ Project
Returns a new instance of Project.
9 10 11 |
# File 'lib/transpec/project.rb', line 9 def initialize(path = Dir.pwd) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/transpec/project.rb', line 7 def path @path end |
Instance Method Details
#basename ⇒ Object
13 14 15 |
# File 'lib/transpec/project.rb', line 13 def basename File.basename(@path) end |
#require_bundler? ⇒ Boolean
17 18 19 20 |
# File 'lib/transpec/project.rb', line 17 def require_bundler? gemfile_path = File.join(@path, 'Gemfile') File.exist?(gemfile_path) end |
#rspec_version ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/transpec/project.rb', line 22 def rspec_version @rspec_version ||= begin command = 'rspec --version' command = 'bundle exec ' + command if require_bundler? version_string = nil Dir.chdir(@path) do with_bundler_clean_env { version_string = `#{command}`.chomp } end RSpecVersion.new(version_string) end end |
#with_bundler_clean_env ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/transpec/project.rb', line 37 def with_bundler_clean_env if defined?(Bundler) && require_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 |