spec/screen_spec.rb in ProMotion-0.6.0 vs spec/screen_spec.rb in ProMotion-0.6.1
- old
+ new
@@ -10,15 +10,24 @@
it "should store title" do
HomeScreen.get_title.should == 'Home'
end
- it "should let the instance reset the title" do
+ it "should set default title on new instances" do
+ @screen.title.should == "Home"
+ end
+
+ it "should let the instance set its title" do
@screen.title = "instance method"
- HomeScreen.get_title.should == 'instance method'
+ @screen.title.should == 'instance method'
end
+ it "should not let the instance reset the default title" do
+ @screen.title = "instance method"
+ HomeScreen.get_title.should != 'instance method'
+ end
+
it "should store debug mode" do
HomeScreen.debug_mode = true
HomeScreen.debug_mode.should == true
end
@@ -71,14 +80,14 @@
@screen.mock!(:should_autorotate) { true }
@screen.shouldAutorotate.should == true
end
it "-willRotateToInterfaceOrientation" do
- @screen.mock! :will_rotate do |orientation, duration|
+ @screen.mock! :will_rotate do |orientation, duration|
orientation.should == UIInterfaceOrientationPortrait
duration.should == 0.5
- end
+ end
@screen.willRotateToInterfaceOrientation(UIInterfaceOrientationPortrait, duration: 0.5)
end
it "-didRotateFromInterfaceOrientation" do
@screen.mock!(:on_rotate) { true }
@@ -102,9 +111,59 @@
@screen.navigationItem.rightBarButtonItem.should.not == nil
end
it "should have a left bar button item" do
@screen.navigationItem.leftBarButtonItem.should.not == nil
+ end
+
+ end
+
+ describe "bar button behavior" do
+ describe "system bar buttons" do
+ before do
+ @screen.set_nav_bar_right_button nil, action: :add_something, system_icon: UIBarButtonSystemItemAdd
+ end
+
+ it "has a right bar button item of the correct type" do
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
+ end
+
+ it "is an add button" do
+ @screen.navigationItem.rightBarButtonItem.action.should == :add_something
+ end
+ end
+
+ describe 'titled bar buttons' do
+ before do
+ @screen.set_nav_bar_right_button "Save", action: :save_something, style: UIBarButtonItemStyleDone
+ end
+
+ it "has a right bar button item of the correct type" do
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
+ end
+
+ it "has a right bar button item of the correct style" do
+ @screen.navigationItem.rightBarButtonItem.style.should == UIBarButtonItemStyleDone
+ end
+
+ it "is titled correctly" do
+ @screen.navigationItem.rightBarButtonItem.title.should == 'Save'
+ end
+ end
+
+ describe 'image bar buttons' do
+ before do
+ @image = UIImage.alloc.init
+ @screen.set_nav_bar_right_button @image, action: :save_something, style: UIBarButtonItemStyleDone
+ end
+
+ it "has a right bar button item of the correct type" do
+ @screen.navigationItem.rightBarButtonItem.should.be.instance_of UIBarButtonItem
+ end
+
+ it "is has the right image" do
+ @screen.navigationItem.rightBarButtonItem.title.should == nil
+ end
end
end
end