Permalink
Browse files

added test for upcoming AT+CFUN after 5 errors

  • Loading branch information...
1 parent c15e8ea commit 2978dd4cb04e09733362682679bae891d8ca8228 @adammck committed Apr 23, 2009
Showing with 27 additions and 0 deletions.
  1. +27 −0 spec/rubygsm.rb
View
@@ -20,4 +20,31 @@
Gsm::Modem.new(modem)
end.should_not raise_error
end
+
+ it "resets the modem after 5 consecutive errors" do
+
+ # this modem will return errors when AT+CSQ is
+ # called, UNTIL the modem is reset. a flag is
+ # also set, so we can check for the reset
+ class TestModem < Gsm::Mock::Modem
+ attr_reader :has_reset
+
+ def at_csq(*args)
+ @has_reset ? super : false
+ end
+
+ def at_cfun(*args)
+ (@has_reset = true)
+ end
+ end
+
+ # start rubygsm, and call
+ # the troublesome method
+ modem = TestModem.new
+ gsm = Gsm::Modem.new(modem)
+ gsm.signal_strength
+
+ # it should have called AT+CFUN!
+ modem.has_reset.should == true
+ end
end

0 comments on commit 2978dd4

Please sign in to comment.