From 200dc06ded602915fb73e34ea45408f99b80063d Mon Sep 17 00:00:00 2001 From: Mark Wise Date: Tue, 17 Feb 2015 22:18:04 -0600 Subject: [PATCH] make rmq.device.simulator? spec work when run on the device --- spec/device.rb | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/spec/device.rb b/spec/device.rb index 85df621..94dec1e 100644 --- a/spec/device.rb +++ b/spec/device.rb @@ -89,15 +89,32 @@ describe 'device' do @rmq.device.iphone?.should == false end - it 'should return the right value for simulator?' do - @rmq.device.simulator?.should == true + if !(UIDevice.currentDevice.model =~ /simulator/i).nil? + context "when run on simulator" do + it 'should return the right value for simulator?' do + @rmq.device.simulator?.should == true - class RubyMotionQuery::Device - def self.fake_simulator_value; @_simulator = false; end + class RubyMotionQuery::Device + def self.fake_simulator_value; @_simulator = false; end + end + + @rmq.device.fake_simulator_value + @rmq.device.simulator?.should == false + end end + else + context "when run on the device" do + it 'should return the right value for simulator?' do + @rmq.device.simulator?.should == false - @rmq.device.fake_simulator_value - @rmq.device.simulator?.should == false + class RubyMotionQuery::Device + def self.fake_simulator_value; @_simulator = true; end + end + + @rmq.device.fake_simulator_value + @rmq.device.simulator?.should == true + end + end end it 'should return the right value for three_point_five_inch?' do