Skip to content

Instantly share code, notes, and snippets.

@jonmorehouse
Created August 1, 2014 21:06
Show Gist options
  • Save jonmorehouse/821f92f3bcfaebdb431b to your computer and use it in GitHub Desktop.
Save jonmorehouse/821f92f3bcfaebdb431b to your computer and use it in GitHub Desktop.
class FeedScreen < PM::Screen
def on_load
@control ||= begin
c = UISegmentedControl.plain ["all", "following"]
c.selectedSegmentIndex = 0
c.accessibilityLabel = "nav_control"
c.on :change.uicontrolevent do
switch_screens
end
c
end
self.navigationItem.titleView = @control
end
def switch_screens
# switch screens
end
end
# testing with the actual feed screen fails
describe "Feed Screen" do
tests FeedScreen
def controller
@controller ||= FeedScreen.new nav_bar: true
end
it "should call the :switch_screens method when clicking a control button" do
# fails
controller.mock!(:switch_screens)
tap controller.navigationItem.titleView :at => :right
end
end
# targeting the feed screens navigation controller successfully runs the specs
describe "Feed Screen" do
tests PM::NavigationController
def controller
@controller ||= FeedScreen.new nav_bar: true
@controller.navigationController
end
it "should call the :switch_screens method when clicking a control button" do
controller.mock!(:switch_screens)
tap controller.navigationBar.topItem, :at => :right
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment