Skip to content

Commit

Permalink
test set_staged_files
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Oct 7, 2014
1 parent 3be3a5c commit 84f6d26
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions test/unit/pre-commit/utils/staged_files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
subject.staged_files.must_equal([])
end

it "sets staged files" do
subject.staged_files.must_equal([])
subject.set_staged_files("some_file", "another_file")
subject.staged_files.must_equal(["some_file", "another_file"])
end

it "does not include links to nowhere" do
write("something.rb", "class Something; end")
write("nowhere.rb", "")
Expand Down Expand Up @@ -94,4 +88,43 @@

end # :staged_files_git_all

describe :set_staged_files do

it "sets staged files from list" do
subject.staged_files.must_equal([])
subject.set_staged_files("some_file", "another_file")
subject.staged_files.must_equal(["some_file", "another_file"])
end

it "sets staged files - all" do
subject.staged_files.must_equal([])
write("something.rb", "")
write("file.rb", "")
subject.set_staged_files(:all)
subject.staged_files.must_equal(["file.rb", "something.rb"])
end

it "sets staged files - git" do
subject.staged_files.must_equal([])
write("something.rb", "")
write("file.rb", "")
system("git", "add", "-A")
subject.staged_files = nil
subject.set_staged_files()
write("not_git.rb", "")
subject.staged_files.must_equal(["file.rb", "something.rb"])
end

it "sets staged files - git all" do
subject.staged_files.must_equal([])
write("something.rb", "")
write("file.rb", "")
system("git", "add", "-A")
subject.set_staged_files(:git)
write("not_git.rb", "")
subject.staged_files.must_equal(["file.rb", "something.rb"])
end

end

end

0 comments on commit 84f6d26

Please sign in to comment.