[#1] Fail if all files are reset to committed version.
This commit is contained in:
parent
d00760732d
commit
ba54c407cb
4 changed files with 40 additions and 9 deletions
|
@ -19,8 +19,9 @@ describe FormatStaged do
|
|||
it 'updates staged file and working copy' do
|
||||
repo.set_content 'test.test', 'a=b'
|
||||
repo.stage 'test.test'
|
||||
repo.run_formatter
|
||||
success = repo.run_formatter
|
||||
|
||||
expect(success).to be_truthy
|
||||
expect(repo.get_staged('test.test')).to eq('a = b')
|
||||
expect(repo.get_content('test.test')).to eq('a = b')
|
||||
end
|
||||
|
@ -29,8 +30,9 @@ describe FormatStaged do
|
|||
repo.set_content 'test.test', "x=y\na=b\n"
|
||||
repo.stage 'test.test'
|
||||
repo.set_content 'test.test', 'abc'
|
||||
repo.run_formatter
|
||||
success = repo.run_formatter
|
||||
|
||||
expect(success).to be_truthy
|
||||
expect(repo.get_content('test.test')).to eq('abc')
|
||||
expect(repo.get_staged('test.test')).to eq("x = y\na = b")
|
||||
end
|
||||
|
@ -39,8 +41,9 @@ describe FormatStaged do
|
|||
repo.set_content 'test.test', "x=y\n#stuff\n"
|
||||
repo.stage 'test.test'
|
||||
repo.set_content 'test.test', "x=y\n#stuff\nmore stuff\n"
|
||||
repo.run_formatter
|
||||
success = repo.run_formatter
|
||||
|
||||
expect(success).to be_truthy
|
||||
expect(repo.get_content('test.test')).to eq("x = y\n#stuff\nmore stuff")
|
||||
expect(repo.get_staged('test.test')).to eq("x = y\n#stuff")
|
||||
end
|
||||
|
@ -48,8 +51,24 @@ describe FormatStaged do
|
|||
it 'only touches files matching the given pattern' do
|
||||
repo.set_content 'test.other', 'x=y'
|
||||
repo.stage 'test.other'
|
||||
repo.run_formatter
|
||||
success = repo.run_formatter
|
||||
|
||||
expect(success).to be_truthy
|
||||
expect(repo.get_content('test.other')).to eq('x=y')
|
||||
end
|
||||
|
||||
it 'fails if files are changed to already comitted version' do
|
||||
repo.file_in_tree 'test.test', 'x = y'
|
||||
repo.set_content 'test.test', 'x=y'
|
||||
repo.stage 'test.test'
|
||||
|
||||
success = repo.run_formatter
|
||||
|
||||
expect(success).to be_falsy
|
||||
expect(repo.get_content('test.test')).to eq('x = y')
|
||||
end
|
||||
|
||||
it 'succeeds if there are no staged files' do
|
||||
expect(repo.run_formatter).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue