spec/screen_helpers_spec.rb in ProMotion-0.6.0 vs spec/screen_helpers_spec.rb in ProMotion-0.6.1
- old
+ new
@@ -33,29 +33,43 @@
it "should add a subview to another element with attributes" do
sub_subview = UIView.alloc.initWithFrame CGRectZero
@screen.add_to @subview, sub_subview, { backgroundColor: UIColor.redColor }
@subview.subviews.last.backgroundColor.should == UIColor.redColor
end
-
+
end
describe "nav bar buttons" do
-
+
before do
@screen = HomeScreen.new(nav_bar: true)
end
-
+
it "should add a left nav bar button" do
@screen.set_nav_bar_left_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
@screen.navigationItem.leftBarButtonItem.class.should == UIBarButtonItem
end
-
+
it "should add a right nav bar button" do
@screen.set_nav_bar_right_button "Cancel", action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
@screen.navigationItem.rightBarButtonItem.class.should == UIBarButtonItem
end
-
+
+ it "should add an image right nav bar button" do
+ image = UIImage.imageNamed("list.png")
+ @screen.set_nav_bar_right_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
+ @screen.navigationItem.rightBarButtonItem.image.class.should == UIImage
+ @screen.navigationItem.rightBarButtonItem.image.should == image
+ end
+
+ it "should add an image left nav bar button" do
+ image = UIImage.imageNamed("list.png")
+ @screen.set_nav_bar_left_button image, action: :return_to_some_other_screen, type: UIBarButtonItemStylePlain
+ @screen.navigationItem.leftBarButtonItem.image.class.should == UIImage
+ @screen.navigationItem.leftBarButtonItem.image.should == image
+ end
+
end
describe "screen navigation" do
before do
@@ -141,23 +155,13 @@
it "should pop onto navigation controller if current screen is on nav stack already" do
@screen.mock!(:push_view_controller) { |vc| vc.should.be.instance_of BasicScreen }
@screen.open_screen BasicScreen
end
- it "should open the main controller if no options are provided" do
+ it "should open the provided view controller as root view if no other conditions are met" do
parent_screen = HomeScreen.new
- nav_controller = ProMotion::NavigationController.new
new_screen = BasicScreen.new
- new_screen.stub! :main_controller, return: nav_controller
-
- parent_screen.mock!(:open_view_controller) { |vc| vc.should.be == nav_controller }
- parent_screen.open_screen new_screen
- end
-
- it "should open the provided view controller if no other conditions are met" do
- parent_screen = HomeScreen.new
- new_screen = BasicScreen.new
- parent_screen.mock!(:open_view_controller) { |vc| vc.should.be == new_screen }
+ parent_screen.mock!(:open_root_screen) { |vc| vc.should.be == new_screen }
parent_screen.open_screen new_screen
end
end