File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Facter ::Util ::Fact do
4+ before {
5+ Facter . clear
6+ }
7+
8+ let ( :pip_version_output ) { <<-EOS
9+ pip 6.0.6 from /opt/boxen/homebrew/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg (python 2.7)
10+ EOS
11+ }
12+
13+ describe "pip_version" do
14+ context 'returns pip version when pip present' do
15+ it do
16+ Facter ::Util ::Resolution . stubs ( :exec )
17+ Facter ::Util ::Resolution . expects ( :which ) . with ( "pip" ) . returns ( true )
18+ Facter ::Util ::Resolution . expects ( :exec ) . with ( "pip --version 2>&1" ) . returns ( pip_version_output )
19+ Facter . value ( :pip_version ) . should == "6.0.6"
20+ end
21+ end
22+
23+ context 'returns nil when pip not present' do
24+ it do
25+ Facter ::Util ::Resolution . stubs ( :exec )
26+ Facter ::Util ::Resolution . expects ( :which ) . with ( "pip" ) . returns ( false )
27+ Facter . value ( :pip_version ) . should == nil
28+ end
29+ end
30+
31+ end
32+ end
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Facter ::Util ::Fact do
4+ before {
5+ Facter . clear
6+ }
7+
8+ let ( :python_version_output ) { <<-EOS
9+ Python 2.7.9
10+ EOS
11+ }
12+
13+ describe "python_version" do
14+ context 'returns python version when python present' do
15+ it do
16+ Facter ::Util ::Resolution . stubs ( :exec )
17+ Facter ::Util ::Resolution . expects ( :which ) . with ( "python" ) . returns ( true )
18+ Facter ::Util ::Resolution . expects ( :exec ) . with ( "python -V 2>&1" ) . returns ( python_version_output )
19+ Facter . value ( :python_version ) . should == "2.7.9"
20+ end
21+ end
22+
23+ context 'returns nil when python not present' do
24+ it do
25+ Facter ::Util ::Resolution . stubs ( :exec )
26+ Facter ::Util ::Resolution . expects ( :which ) . with ( "python" ) . returns ( false )
27+ Facter . value ( :python_version ) . should == nil
28+ end
29+ end
30+
31+ end
32+ end
Original file line number Diff line number Diff line change 1+ require "spec_helper"
2+
3+ describe Facter ::Util ::Fact do
4+ before {
5+ Facter . clear
6+ }
7+
8+ let ( :virtualenv_version_output ) { <<-EOS
9+ 12.0.7
10+ EOS
11+ }
12+
13+ describe "virtualenv_version" do
14+ context 'returns virtualenv version when virtualenv present' do
15+ it do
16+ Facter ::Util ::Resolution . stubs ( :exec )
17+ Facter ::Util ::Resolution . expects ( :which ) . with ( "virtualenv" ) . returns ( true )
18+ Facter ::Util ::Resolution . expects ( :exec ) . with ( "virtualenv --version 2>&1" ) . returns ( virtualenv_version_output )
19+ Facter . value ( :virtualenv_version ) . should == "12.0.7"
20+ end
21+ end
22+
23+ context 'returns nil when virtualenv not present' do
24+ it do
25+ Facter ::Util ::Resolution . stubs ( :exec )
26+ Facter ::Util ::Resolution . expects ( :which ) . with ( "virtualenv" ) . returns ( false )
27+ Facter . value ( :virtualenv_version ) . should == nil
28+ end
29+ end
30+
31+ end
32+ end
You can’t perform that action at this time.
0 commit comments