Watson1978
5/8/2012 - 12:17 PM

main_spec.rb

describe "Application 'StopWatch'" do
  before do
    @app = UIApplication.sharedApplication
    @controller = @app.windows.first.rootViewController
  end

  it "has one window" do
    @app.windows.size.should == 1
  end

  it "should have a label" do
    label = @controller.instance_variable_get(:@label)
    label.should != nil
  end

  it "should start a timer" do
    @app.sendAction("startTimer:", to: @controller, from: self, forEvent: nil)

    timer = @controller.instance_variable_get(:@timer)
    timer.should != nil
  end

  it "should stop a timer" do
    @app.sendAction("startTimer:", to: @controller, from: self, forEvent: nil)
    @app.sendAction("stopTimer:", to: @controller, from: self, forEvent: nil)

    timer = @controller.instance_variable_get(:@timer)
    timer.should == nil
  end

end