Test that an actual different storyboard is loaded.

Also simplify option initialization a little.
This commit is contained in:
Eloy Duran
2012-07-13 21:33:05 +02:00
parent f357dfd6cd
commit 0928fafe6f
4 changed files with 14 additions and 16 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
*.swp
*.orig
.DS_Store
*.storyboardc
build

View File

@@ -168,13 +168,7 @@ module Bacon
# * :navigation => true
# * :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)
@controller_class, @options = controller_class, options
extend Bacon::Functional::API
extend Bacon::Functional::ContextExt
end
@@ -227,7 +221,7 @@ module Bacon
end
def storyboard
@storyboard ||= UIStoryboard.storyboardWithName(@options[:storyboard_name], bundle:nil)
@storyboard ||= UIStoryboard.storyboardWithName(@options[:storyboard] || 'MainStoryboard', bundle:nil)
end
end

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11E53" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="iYx-M1-K9o">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11D50d" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="iYx-M1-K9o">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<development defaultVersion="4200" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1181"/>
</dependencies>
@@ -15,8 +14,8 @@
<rect key="frame" x="0.0" y="20" width="320" height="460"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Hello, RubyMotion" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="agt-qQ-mcA">
<rect key="frame" x="90" y="114" width="141" height="21"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Allo allo, RubyMotion" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="agt-qQ-mcA">
<rect key="frame" x="79" y="114" width="162" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Storyboard"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>

View File

@@ -2,7 +2,7 @@ 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'
# 'Hello, Rubymotion' and 'Allo allo, RubyMotion'.
def viewDidLoad
label = UILabel.alloc.init
@@ -26,7 +26,6 @@ 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
@@ -34,14 +33,18 @@ describe "Storyboard support defaults" do
tests StoryboardViewController, :id => 'main'
it "uses MainStoryboard if no name is provided" do
@options[:storyboard_name].should == 'MainStoryboard'
view('Storyboard').text.should == 'Hello, RubyMotion'
end
behaves_like "a controller from a storyboard"
end
describe "Storyboard support with named storyboard" do
tests StoryboardViewController, :storyboard_name => 'AlternateStoryboard', :id => 'alternate'
tests StoryboardViewController, :storyboard => 'AlternateStoryboard', :id => 'alternate'
it "uses a specific storyboard if one is provided" do
view('Storyboard').text.should == 'Allo allo, RubyMotion'
end
behaves_like "a controller from a storyboard"
end