|
215 | 215 | expect(simctl.send(:string_for_sim_state, 1)).to be == "Shutdown"
|
216 | 216 | expect(simctl.send(:string_for_sim_state, 2)).to be == "Shutting Down"
|
217 | 217 | expect(simctl.send(:string_for_sim_state, 3)).to be == "Booted"
|
218 |
| - expect(simctl.send(:string_for_sim_state, -1)).to be == "Plist Missing" |
| 218 | + expect(simctl.send(:string_for_sim_state, -1)).to be == "Plist Missing Key" |
219 | 219 | end
|
220 | 220 |
|
221 | 221 | it "raises an error for invalid states" do
|
|
228 | 228 | context "#simulator_state_as_int" do
|
229 | 229 | it "returns the numeric state of the simulator by asking the sim plist" do
|
230 | 230 | plist = device.simulator_device_plist
|
231 |
| - expect(File).to receive(:exist?).with(plist).and_return(true) |
232 |
| - |
233 | 231 | pbuddy = RunLoop::PlistBuddy.new
|
234 |
| - expect(simctl).to receive(:pbuddy).and_return(pbuddy) |
| 232 | + |
| 233 | + expect(simctl).to receive(:pbuddy).at_least(:once).and_return(pbuddy) |
| 234 | + expect(pbuddy).to( |
| 235 | + receive(:plist_key_exists?).with("state", plist).and_return(true) |
| 236 | + ) |
235 | 237 | expect(pbuddy).to receive(:plist_read).and_return("10")
|
236 | 238 |
|
237 | 239 | expect(simctl.simulator_state_as_int(device)).to be == 10
|
238 | 240 | end
|
239 | 241 |
|
240 |
| - it "returns the Plist Missing state (-1) if the plist is missing" do |
| 242 | + it "returns the Plist Missing Key state (-1) state key is missing" do |
241 | 243 | plist = device.simulator_device_plist
|
242 |
| - expect(File).to receive(:exist?).with(plist).and_return(false) |
| 244 | + pbuddy = RunLoop::PlistBuddy.new |
243 | 245 |
|
244 |
| - expected = RunLoop::Simctl::SIM_STATES["Plist Missing"] |
| 246 | + expect(simctl).to receive(:pbuddy).and_return(pbuddy) |
| 247 | + expect(pbuddy).to( |
| 248 | + receive(:plist_key_exists?).with("state", plist).and_return(false) |
| 249 | + ) |
245 | 250 |
|
| 251 | + expected = RunLoop::Simctl::SIM_STATES["Plist Missing Key"] |
246 | 252 | expect(simctl.simulator_state_as_int(device)).to be == expected
|
247 | 253 | end
|
248 | 254 | end
|
|
0 commit comments