diff options
| author | Robert Speicher <rspeicher@gmail.com> | 2012-09-17 13:33:04 -0400 |
|---|---|---|
| committer | Robert Speicher <rspeicher@gmail.com> | 2012-09-26 16:32:22 -0400 |
| commit | 37f0b600bc9a994136791e6838b3228c56f909b2 (patch) | |
| tree | 5711e387e407b076a8e6f6bd28f11033a6cd1f68 /spec/lib | |
| parent | 94af622c879681683c84b6537c2adea52c78b2a2 (diff) | |
| download | gitlab-ce-37f0b600bc9a994136791e6838b3228c56f909b2.tar.gz | |
Another RefExtractor refactor
Diffstat (limited to 'spec/lib')
| -rw-r--r-- | spec/lib/ref_extractor_spec.rb | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/spec/lib/ref_extractor_spec.rb b/spec/lib/ref_extractor_spec.rb index 84347977bc4..1e3d178fbba 100644 --- a/spec/lib/ref_extractor_spec.rb +++ b/spec/lib/ref_extractor_spec.rb @@ -11,29 +11,48 @@ describe RefExtractor do project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) end - it "extracts a ref without a path" do - extract_ref('master').should == ['master', '/'] - end - - it "extracts a valid branch ref" do - extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', '/CHANGELOG'] - end - - it "extracts a valid tag ref" do - extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', '/CHANGELOG'] - end - - it "extracts a valid commit ref" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == - ['f4b14494ef6abf3d144c28e4af0c20143383e062', '/CHANGELOG'] - end - - it "falls back to a primitive split for an invalid ref" do - extract_ref('stable/CHANGELOG').should == ['stable', '/CHANGELOG'] - end - - it "returns an empty pair when no @project is set" do - @project = nil - extract_ref('master/CHANGELOG').should == ['', ''] + describe '#extract_ref' do + it "returns an empty pair when no @project is set" do + @project = nil + extract_ref('master/CHANGELOG').should == ['', ''] + end + + context "without a path" do + it "extracts a valid branch" do + extract_ref('master').should == ['master', ''] + end + + it "extracts a valid tag" do + extract_ref('v2.0.0').should == ['v2.0.0', ''] + end + + it "extracts a valid commit ref without a path" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', ''] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable').should == ['stable', ''] + end + end + + context "with a path" do + it "extracts a valid branch" do + extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] + end + + it "extracts a valid tag" do + extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] + end + + it "extracts a valid commit SHA" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG'] + end + end end end |
