Skip to content
Browse files

add specs

  • Loading branch information...
1 parent 6efd779 commit 50b94a03612f169537b78507701271b6a44bb5ce @lrz lrz committed Sep 10, 2012
Showing with 34 additions and 5 deletions.
  1. +2 −0 Timer/app/timer_controller.rb
  2. +32 −5 Timer/spec/main_spec.rb
View
2 Timer/app/timer_controller.rb
@@ -1,4 +1,6 @@
class TimerController < UIViewController
+ attr_reader :timer
+
def viewDidLoad
margin = 20
View
37 Timer/spec/main_spec.rb
@@ -1,9 +1,36 @@
-describe "Application 'Timer'" do
- before do
- @app = UIApplication.sharedApplication
+describe "The Timer view controller" do
+ tests TimerController
+
+ it "has a timer label" do
+ view('Tap to start').should.not == nil
+ end
+
+ it "starts a timer" do
+ tap 'Start'
+ controller.timer.isValid.should == true
end
- it "has one window" do
- @app.windows.size.should == 1
+ it "increases the timer label value" do
+ label = view('Tap to start')
+ label.text.to_f.should == 0
+
+ tap 'Start'
+ proper_wait 1
+ tap 'Stop'
+ label.text.to_f.should > 1
+ label.text.to_f.should < 2
+ end
+
+ it "resets the timer on each run" do
+ label = view('Tap to start')
+
+ tap 'Start'
+ proper_wait 1
+ tap 'Stop'
+
+ tap 'Start'
+ tap 'Stop'
+
+ label.text.to_f.should < 1
end
end

0 comments on commit 50b94a0

Please sign in to comment.
Something went wrong with that request. Please try again.