spec/lotion/application_spec.rb in lotion-0.0.1 vs spec/lotion/application_spec.rb in lotion-0.1.0

- old
+ new

@@ -1,16 +1,49 @@ -require 'spec_helper' +#= require lotion/application describe Lotion::Application do - subject { Class.new do + + subject do include Lotion::Application - end.new } + end + before do + @center = subject.notification_center + end + it 'includes the correct concerns' do + subject.should be_a( Lotion::Notifications ) + end + it 'defines #screen' do + subject.screen.should == UIScreen.mainScreen + end + it 'defines #window' do + subject.window.should be_a( UIWindow ) + end + it 'defined #views' do + subject.views.should be_a( Hash ) + end + it 'notifies after application startup' do + options = { :foo => 'bar' } - it { should respond_to( :application ) } + @center.mock! 'postNotificationName:object:userInfo:' do |name, from, info| + name.should == 'application:startup' + from.should == subject + info.should == options + end - let( :application ){ double 'application' } - let( :options ){ double 'launch options' } + subject.application( nil, didFinishLaunchingWithOptions:options ).should == true + end + it 'responds to #on' do + subject.should.respond_to :on + end + it 'attaches commands to notifications' do + command = stub :call, :return => true - it 'should return true, of course' do - subject.application( application, options ).should == true + @center.mock! 'addObserver:selector:name:object:' do |klass, selector, name, object| + klass.should == command + selector.should == 'call:' + name.should == 'foo' + object.should == nil + end + + subject.on 'foo', command end end