BigW Consortium Gitlab

tree_helper_spec.rb 737 Bytes
Newer Older
1 2 3 4 5 6
require 'spec_helper'

describe TreeHelper do
  describe 'flatten_tree' do
    let(:project) { create(:project) }

7
    before do
8 9
      @repository = project.repository
      @commit = project.commit("e56497bb")
10
    end
11 12 13 14 15

    context "on a directory containing more than one file/directory" do
      let(:tree_item) { double(name: "files", path: "files") }

      it "should return the directory name" do
16
        expect(flatten_tree(tree_item)).to match('files')
17 18 19 20 21 22 23
      end
    end

    context "on a directory containing only one directory" do
      let(:tree_item) { double(name: "foo", path: "foo") }

      it "should return the flattened path" do
24
        expect(flatten_tree(tree_item)).to match('foo/bar')
25 26 27 28
      end
    end
  end
end