require "spec_helper" require "ib/generator" describe IB::Generator do it "generates stubs header with ios platform" do files = IB::Parser.new.find_all("spec/fixtures/common") stubs = IB::Generator.new(:ios).render_stub_file('generator/templates/Stubs.h.erb', files) stubs.should == <<-OBJC // Generated by IB v#{IB::VERSION} gem. Do not edit it manually // Run `rake ib:open` to refresh #import #import #import @interface AppDelegate @property IBOutlet UIWindow * window; @property IBOutlet UINavigationController * navigationController; @end @interface CustomView: UIView @property IBOutlet UIGreenLabel * greenLabel; @property IBOutlet UILabel * redLabel; @property IBOutlet id untyped_label; @property IBOutlet id yellowLabel; @property IBOutletCollection(UIGreenLabel) NSArray * greenLabelCollection; @property IBOutletCollection(UILabel) NSArray * redLabelCollection; @property IBOutletCollection(id) NSArray * untyped_label_collection; @property IBOutletCollection(id) NSArray * yellowLabelCollection; -(IBAction) someAction:(id) sender; -(IBAction) segueAction:(UIStoryboardSegue*) sender; -(IBAction) anotherAction:(id) button; -(IBAction) actionWithComment:(id) sender; -(IBAction) actionWithBrackets:(id) sender; -(IBAction) actionWithoutArgs; -(IBAction) actionWithDefaultedArgs:(id) sender; @end @interface EmptyView: UIView @end @interface AnotherView: EmptyView @end OBJC end it "generates stubs header with osx platform" do files = IB::Parser.new.find_all("spec/fixtures/common") stubs = IB::Generator.new(:osx).render_stub_file('generator/templates/Stubs.h.erb', files) stubs.should == <<-OBJC // Generated by IB v#{IB::VERSION} gem. Do not edit it manually // Run `rake ib:open` to refresh #import #import #import @interface AppDelegate @property IBOutlet UIWindow * window; @property IBOutlet UINavigationController * navigationController; @end @interface CustomView: UIView @property IBOutlet UIGreenLabel * greenLabel; @property IBOutlet UILabel * redLabel; @property IBOutlet id untyped_label; @property IBOutlet id yellowLabel; @property IBOutletCollection(UIGreenLabel) NSArray * greenLabelCollection; @property IBOutletCollection(UILabel) NSArray * redLabelCollection; @property IBOutletCollection(id) NSArray * untyped_label_collection; @property IBOutletCollection(id) NSArray * yellowLabelCollection; -(IBAction) someAction:(id) sender; -(IBAction) segueAction:(UIStoryboardSegue*) sender; -(IBAction) anotherAction:(id) button; -(IBAction) actionWithComment:(id) sender; -(IBAction) actionWithBrackets:(id) sender; -(IBAction) actionWithoutArgs; -(IBAction) actionWithDefaultedArgs:(id) sender; @end @interface EmptyView: UIView @end @interface AnotherView: EmptyView @end OBJC end it "generates stubs implement" do files = IB::Parser.new.find_all("spec/fixtures/common") stubs = IB::Generator.new(:ios).render_stub_file('generator/templates/Stubs.m.erb', files) stubs.should == <<-OBJC // Generated by IB v#{IB::VERSION} gem. Do not edit it manually // Run `rake ib:open` to refresh #import "Stubs.h" @implementation AppDelegate @end @implementation CustomView @end @implementation EmptyView @end @implementation AnotherView @end OBJC end end