|
71 | 71 | around do |example|
|
72 | 72 | repo do
|
73 | 73 | `echo "Hello World" > tracked-file`
|
74 |
| - `git add tracked-file` |
75 |
| - `git commit -m "Add tracked-file"` |
| 74 | + `echo "Hello Other World" > other-tracked-file` |
| 75 | + `git add tracked-file other-tracked-file` |
| 76 | + `git commit -m "Add tracked-file and other-tracked-file"` |
76 | 77 | `echo "Hello Again" > untracked-file`
|
| 78 | + `echo "Some more text" >> other-tracked-file` |
77 | 79 | example.run
|
78 | 80 | end
|
79 | 81 | end
|
|
83 | 85 | File.open('tracked-file', 'r').read.should == "Hello World\n"
|
84 | 86 | end
|
85 | 87 |
|
| 88 | + it 'does not keep unstaged changes' do |
| 89 | + subject |
| 90 | + File.open('other-tracked-file', 'r').read.should == "Hello Other World\n" |
| 91 | + end |
| 92 | + |
86 | 93 | it 'keeps untracked files' do
|
87 | 94 | subject
|
88 | 95 | File.open('untracked-file', 'r').read.should == "Hello Again\n"
|
89 | 96 | end
|
90 | 97 |
|
91 | 98 | it 'keeps modification times the same' do
|
92 |
| - expect { subject }. |
93 |
| - to_not change { [File.mtime('tracked-file'), File.mtime('untracked-file')] } |
| 99 | + sleep 1 |
| 100 | + expect { subject }.to_not change { |
| 101 | + [ |
| 102 | + File.mtime('tracked-file'), |
| 103 | + File.mtime('other-tracked-file'), |
| 104 | + File.mtime('untracked-file') |
| 105 | + ] |
| 106 | + } |
94 | 107 | end
|
95 | 108 | end
|
96 | 109 |
|
97 | 110 | context 'when there are staged changes' do
|
98 | 111 | around do |example|
|
99 | 112 | repo do
|
100 | 113 | `echo "Hello World" > tracked-file`
|
101 |
| - `git add tracked-file` |
102 |
| - `git commit -m "Add tracked-file"` |
| 114 | + `echo "Hello Other World" > other-tracked-file` |
| 115 | + `git add tracked-file other-tracked-file` |
| 116 | + `git commit -m "Add tracked-file and other-tracked-file"` |
103 | 117 | `echo "Hello Again" > untracked-file`
|
104 | 118 | `echo "Some more text" >> tracked-file`
|
| 119 | + `echo "Some more text" >> other-tracked-file` |
105 | 120 | `git add tracked-file`
|
106 | 121 | `echo "Yet some more text" >> tracked-file`
|
107 | 122 | example.run
|
|
110 | 125 |
|
111 | 126 | it 'keeps staged changes' do
|
112 | 127 | subject
|
113 |
| - `git show :tracked-file`.should == "Hello World\nSome more text\n" |
| 128 | + File.open('tracked-file', 'r').read.should == "Hello World\nSome more text\n" |
| 129 | + end |
| 130 | + |
| 131 | + it 'does not keep unstaged changes' do |
| 132 | + subject |
| 133 | + File.open('other-tracked-file', 'r').read.should == "Hello Other World\n" |
114 | 134 | end
|
115 | 135 |
|
116 | 136 | it 'keeps untracked files' do
|
|
119 | 139 | end
|
120 | 140 |
|
121 | 141 | it 'keeps modification times the same' do
|
122 |
| - expect { subject }. |
123 |
| - to_not change { [File.mtime('tracked-file'), File.mtime('untracked-file')] } |
| 142 | + sleep 1 |
| 143 | + expect { subject }.to_not change { |
| 144 | + [ |
| 145 | + File.mtime('tracked-file'), |
| 146 | + File.mtime('other-tracked-file'), |
| 147 | + File.mtime('untracked-file') |
| 148 | + ] |
| 149 | + } |
124 | 150 | end
|
125 | 151 | end
|
126 | 152 |
|
|
202 | 228 | end
|
203 | 229 |
|
204 | 230 | it 'keeps modification times the same' do
|
205 |
| - expect { subject }. |
206 |
| - to_not change { [File.mtime('tracked-file'), File.mtime('untracked-file')] } |
| 231 | + sleep 1 |
| 232 | + expect { subject }.to_not change { |
| 233 | + [ |
| 234 | + File.mtime('tracked-file'), |
| 235 | + File.mtime('other-tracked-file'), |
| 236 | + File.mtime('untracked-file') |
| 237 | + ] |
| 238 | + } |
207 | 239 | end
|
208 | 240 | end
|
209 | 241 |
|
210 | 242 | context 'when there were staged changes' do
|
211 | 243 | around do |example|
|
212 | 244 | repo do
|
213 | 245 | `echo "Hello World" > tracked-file`
|
214 |
| - `git add tracked-file` |
215 |
| - `git commit -m "Add tracked-file"` |
| 246 | + `echo "Hello Other World" > other-tracked-file` |
| 247 | + `git add tracked-file other-tracked-file` |
| 248 | + `git commit -m "Add tracked-file and other-tracked-file"` |
216 | 249 | `echo "Hello Again" > untracked-file`
|
217 | 250 | `echo "Some more text" >> tracked-file`
|
| 251 | + `echo "Some more text" >> other-tracked-file` |
218 | 252 | `git add tracked-file`
|
219 | 253 | `echo "Yet some more text" >> tracked-file`
|
220 | 254 | example.run
|
|
238 | 272 | end
|
239 | 273 |
|
240 | 274 | it 'keeps modification times the same' do
|
241 |
| - expect { subject }. |
242 |
| - to_not change { [File.mtime('tracked-file'), File.mtime('untracked-file')] } |
| 275 | + sleep 1 |
| 276 | + expect { subject }.to_not change { |
| 277 | + [ |
| 278 | + File.mtime('tracked-file'), |
| 279 | + File.mtime('other-tracked-file'), |
| 280 | + File.mtime('untracked-file') |
| 281 | + ] |
| 282 | + } |
243 | 283 | end
|
244 | 284 | end
|
245 | 285 |
|
|
0 commit comments