diff --git a/lib/motion/spec/helpers/ui.rb b/lib/motion/spec/helpers/ui.rb
index 6d447e60..e1ce1be0 100644
--- a/lib/motion/spec/helpers/ui.rb
+++ b/lib/motion/spec/helpers/ui.rb
@@ -169,6 +169,12 @@ module Bacon
# * :tab => true
def tests(controller_class, options = {})
@controller_class = controller_class
+ @options = {
+ # name of storyboard file in resources directory
+ :storyboard_name => 'MainStoryboard',
+ # id of controller as assigned in Xcode
+ :id => nil
+ }.merge(options)
extend Bacon::Functional::API
extend Bacon::Functional::ContextExt
end
@@ -213,7 +219,15 @@ module Bacon
attr_accessor :controller
def controller
- @controller ||= @controller_class.alloc.init
+ @controller ||= if @options[:id]
+ storyboard.instantiateViewControllerWithIdentifier(@options[:id])
+ else
+ @controller_class.alloc.init
+ end
+ end
+
+ def storyboard
+ @storyboard ||= UIStoryboard.storyboardWithName(@options[:storyboard_name], bundle:nil)
end
end
diff --git a/test/bacon-ui/resources/AlternateStoryboard.storyboard b/test/bacon-ui/resources/AlternateStoryboard.storyboard
new file mode 100644
index 00000000..4da3367c
--- /dev/null
+++ b/test/bacon-ui/resources/AlternateStoryboard.storyboard
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/bacon-ui/resources/MainStoryboard.storyboard b/test/bacon-ui/resources/MainStoryboard.storyboard
new file mode 100644
index 00000000..5b23414c
--- /dev/null
+++ b/test/bacon-ui/resources/MainStoryboard.storyboard
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/bacon-ui/spec/continuous_gestures_spec.rb b/test/bacon-ui/spec/continuous_gestures_spec.rb
index 2496fabe..72ea0b84 100644
--- a/test/bacon-ui/spec/continuous_gestures_spec.rb
+++ b/test/bacon-ui/spec/continuous_gestures_spec.rb
@@ -38,6 +38,7 @@ end
describe "Bacon::Functional::API, concerning continuous gestures" do
tests ScrollViewController
+ # TODO this spec fails if the Accessibility Inspector is on
it "creates 'pinch open' and 'pinch close' gesture events" do
before = controller.scrollView.zoomScale
pinch_open 'Scroll view'
@@ -67,6 +68,7 @@ describe "Bacon::Functional::API, concerning continuous gestures" do
pinch_open 'Scroll view'
end
+ # TODO this spec fails if the Accessibility Inspector is on
it "drags from point A to point B" do
before = controller.scrollView.contentOffset
drag 'Scroll view', :from => CGPointMake(310, 100), :to => CGPointMake(5, 150)
@@ -74,6 +76,7 @@ describe "Bacon::Functional::API, concerning continuous gestures" do
controller.scrollView.contentOffset.y.should < before.y
end
+ # TODO this spec fails if the Accessibility Inspector is on
it "drags along the specified list of points" do
view = controller.scrollView
before = view.contentOffset
diff --git a/test/bacon-ui/spec/storyboard_spec.rb b/test/bacon-ui/spec/storyboard_spec.rb
new file mode 100644
index 00000000..5f75c966
--- /dev/null
+++ b/test/bacon-ui/spec/storyboard_spec.rb
@@ -0,0 +1,47 @@
+class StoryboardViewController < UIViewController
+
+ # The view associated with this controller in the storyboard has a single
+ # UILabel with an accessibility label of 'Storyboard' and a text value of
+ # 'Hello, Rubymotion'
+
+ def viewDidLoad
+ label = UILabel.alloc.init
+ label.text = 'Code'
+ view.addSubview(label)
+ end
+
+end
+
+describe "Storyboard support when not used" do
+ tests StoryboardViewController
+
+ it "does not load from storyboard without an id" do
+ labels = views(UILabel)
+ labels.count.should == 1
+ labels.first.text.should == 'Code'
+ end
+end
+
+shared "a controller from a storyboard" do
+ it "has the label defined in the storyboard" do
+ labels = views(UILabel)
+ labels.count.should == 2
+ view('Storyboard').text.should == 'Hello, RubyMotion'
+ end
+end
+
+describe "Storyboard support defaults" do
+ tests StoryboardViewController, :id => 'main'
+
+ it "uses MainStoryboard if no name is provided" do
+ @options[:storyboard_name].should == 'MainStoryboard'
+ end
+
+ behaves_like "a controller from a storyboard"
+end
+
+describe "Storyboard support with named storyboard" do
+ tests StoryboardViewController, :storyboard_name => 'AlternateStoryboard', :id => 'alternate'
+
+ behaves_like "a controller from a storyboard"
+end