File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
module GitVersion
4
4
def git_version ( args = nil )
5
- Parser . new ( args )
5
+ parsers . fetch ( args ) { |a | parsers [ a ] = Parser . new ( a ) }
6
+ end
7
+
8
+ private
9
+ def parsers
10
+ @parsers ||= { }
6
11
end
7
12
end
Original file line number Diff line number Diff line change 6
6
it 'should create a ' + GitVersion ::Parser . to_s do
7
7
expect ( git_version ) . to be_an_instance_of ( GitVersion ::Parser )
8
8
end
9
+
10
+ it 'should create a singleton ' + GitVersion ::Parser . to_s do
11
+ expect ( git_version ) . to equal ( git_version )
12
+ end
13
+
14
+ describe 'passing arguments' do
15
+ it 'should yield the same instance per argument' do
16
+ expect ( git_version ( 'foo' ) ) . to equal ( git_version ( 'foo' ) )
17
+ end
18
+
19
+ it 'should yield different instances for different arguments' do
20
+ expect ( git_version ( 'foo' ) ) . not_to equal_no_diff ( git_version ( 'bar' ) )
21
+ end
22
+
23
+ def equal_no_diff ( expected )
24
+ expected = equal ( expected )
25
+
26
+ # Turn off diffing for this matcher as it calls GitVersion::Parser#to_ary which will fail because GitVersion.exe
27
+ # cannot be found.
28
+ def expected . diffable?
29
+ false
30
+ end
31
+
32
+ expected
33
+ end
34
+ end
9
35
end
You can’t perform that action at this time.
0 commit comments