rucola 0.0.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +468 -0
- data/History.txt +25 -0
- data/License.txt +1 -1
- data/Manifest.txt +32 -0
- data/README.txt +9 -67
- data/Rakefile +39 -31
- data/TODO +10 -18
- data/app_generators/rucola/rucola_generator.rb +15 -8
- data/app_generators/rucola/templates/Rakefile.erb +35 -7
- data/app_generators/rucola/templates/config/boot.rb +0 -1
- data/app_generators/rucola/templates/config/dependencies.rb +31 -0
- data/app_generators/rucola/templates/config/environment.rb +0 -1
- data/app_generators/rucola/templates/config/environments/debug.rb +13 -1
- data/app_generators/rucola/templates/config/environments/release.rb +15 -1
- data/app_generators/rucola/templates/config/environments/test.rb +7 -1
- data/app_generators/rucola/templates/misc/rb_main.rb.erb +12 -1
- data/app_generators/rucola/templates/project.pbxproj.erb +4 -0
- data/app_generators/rucola/templates/script/console +10 -0
- data/app_generators/rucola/templates/test/controllers/test_application_controller.rb +22 -10
- data/app_generators/rucola/templates/test/test_helper.rb +1 -0
- data/bin/rucola +4 -2
- data/lib/rucola/dependencies.rb +241 -0
- data/lib/rucola/dependencies/exclusions.rb +20 -0
- data/lib/rucola/dependencies/override_require_and_gem.rb +30 -0
- data/lib/rucola/dependencies/resolver.rb +68 -0
- data/lib/rucola/fsevents.rb +108 -0
- data/lib/rucola/initializer.rb +149 -117
- data/lib/rucola/log.rb +61 -0
- data/lib/rucola/nib.rb +3 -3
- data/lib/rucola/reloader.rb +39 -0
- data/lib/rucola/ruby_debug.rb +27 -0
- data/lib/rucola/rucola_support.rb +1 -2
- data/lib/rucola/rucola_support/core_ext.rb +4 -2
- data/lib/rucola/rucola_support/core_ext/objc.rb +9 -4
- data/lib/rucola/rucola_support/core_ext/objc/nsimage.rb +22 -0
- data/lib/rucola/rucola_support/core_ext/ruby.rb +11 -4
- data/lib/rucola/rucola_support/core_ext/ruby/file.rb +11 -0
- data/lib/rucola/rucola_support/core_ext/ruby/kernel.rb +16 -0
- data/lib/rucola/rucola_support/core_ext/ruby/object.rb +47 -0
- data/lib/rucola/rucola_support/core_ext/ruby/string.rb +8 -0
- data/lib/rucola/rucola_support/notifications/notifications.rb +26 -28
- data/lib/rucola/rucola_support/rc_app.rb +18 -0
- data/lib/rucola/tasks/dependencies.rake +49 -0
- data/lib/rucola/tasks/deploy.rake +131 -0
- data/lib/rucola/tasks/main.rake +39 -6
- data/lib/rucola/tasks/xcode.rake +54 -11
- data/lib/rucola/test_case.rb +138 -0
- data/lib/rucola/test_helper.rb +11 -5
- data/lib/rucola/version.rb +2 -2
- data/lib/rucola/xcode.rb +39 -9
- data/rucola_generators/controller/templates/test_controller_template.rb.erb +19 -7
- data/rucola_generators/simple_model/USAGE +5 -0
- data/rucola_generators/simple_model/simple_model_generator.rb +54 -0
- data/rucola_generators/simple_model/templates/simple_model.rb.erb +2 -0
- data/rucola_generators/simple_model/templates/test_simple_model.rb.erb +11 -0
- data/rucola_generators/window_controller/templates/test_window_controller_template.rb.erb +24 -13
- data/test/fixtures/dependencies/foo.rb +2 -0
- data/test/fixtures/dependencies/foo/bar.rb +0 -0
- data/test/fixtures/dependencies/foo/baz.rb +0 -0
- data/test/fixtures/dependencies/requires_fileutils.rb +1 -0
- data/test/fixtures/some_reloadable_class.rb +4 -0
- data/test/test_core_ext.rb +80 -0
- data/test/test_dependencies.rb +205 -0
- data/test/test_fsevents.rb +152 -0
- data/test/test_helper.rb +30 -1
- data/test/test_initializer.rb +56 -23
- data/test/test_log.rb +44 -0
- data/test/test_objc_core_ext.rb +23 -0
- data/test/test_rc_app.rb +5 -0
- data/test/test_reloader.rb +28 -0
- data/test/test_rucola_generator.rb +7 -0
- data/test/test_simple_model_generator.rb +48 -0
- data/test/test_xcode.rb +85 -5
- data/website/index.html +17 -91
- data/website/index.txt +14 -81
- data/website/template.rhtml +1 -1
- metadata +120 -76
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'rucola/fsevents'
|
3
|
+
|
4
|
+
describe "FSEvents initialization" do
|
5
|
+
before do
|
6
|
+
@path = File.dirname(__FILE__)
|
7
|
+
@paths = [@path]
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should raise an ArgumentError if a non existing path is specified" do
|
11
|
+
lambda { Rucola::FSEvents.new('/non/existing/path') {|events| 'nothing' } }.should.raise ArgumentError
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should raise an ArgumentError if no block was passed" do
|
15
|
+
lambda { Rucola::FSEvents.new(@paths) }.should.raise ArgumentError
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should take at minimum an array of paths and a block" do
|
19
|
+
fsevents = Rucola::FSEvents.new(@paths) { |events| 'nothing' }
|
20
|
+
fsevents.should.be.an.instance_of Rucola::FSEvents
|
21
|
+
fsevents.paths.first.should.be @path
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have some default values" do
|
25
|
+
fsevents = Rucola::FSEvents.new(@paths) { |events| 'nothing' }
|
26
|
+
fsevents.allocator.should.be OSX::KCFAllocatorDefault
|
27
|
+
fsevents.context.should.be nil
|
28
|
+
fsevents.since.should.be OSX::KFSEventStreamEventIdSinceNow
|
29
|
+
fsevents.latency.should == 0.0
|
30
|
+
fsevents.flags.should == 0
|
31
|
+
fsevents.stream.should.be nil
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be possible to create and start a stream with one call" do
|
35
|
+
fsevents = mock('FSEvents')
|
36
|
+
Rucola::FSEvents.expects(:new).with(@paths).returns(fsevents)
|
37
|
+
fsevents.expects(:create_stream)
|
38
|
+
fsevents.expects(:start)
|
39
|
+
|
40
|
+
result = Rucola::FSEvents.start_watching(@path) {|events| 'nothing' }
|
41
|
+
result.should.be(fsevents)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should accept options to tweak event parameters" do
|
45
|
+
fsevents = Rucola::FSEvents.new(@paths,
|
46
|
+
:latency => 5.2,
|
47
|
+
:since => 24051980
|
48
|
+
) { |events| 'nothing' }
|
49
|
+
fsevents.since.should.be 24051980
|
50
|
+
fsevents.latency.should == 5.2
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "FSEvents when setting up the stream" do
|
55
|
+
before do
|
56
|
+
@path = File.dirname(__FILE__)
|
57
|
+
@paths = [@path]
|
58
|
+
@fsevents = Rucola::FSEvents.new(@paths) { |events| 'nothing' }
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should create a real FSEvents stream" do
|
62
|
+
@fsevents.create_stream
|
63
|
+
@fsevents.stream.should.be.an.instance_of OSX::ConstFSEventStreamRef
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should raise a Rucola::FSEvents::StreamError if the stream could not be created" do
|
67
|
+
OSX.expects(:FSEventStreamCreate).returns(nil)
|
68
|
+
lambda { @fsevents.create_stream }.should.raise Rucola::FSEvents::StreamError
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should register the stream with the current runloop" do
|
72
|
+
stream_mock = mock('Stream')
|
73
|
+
OSX.expects(:FSEventStreamCreate).returns(stream_mock)
|
74
|
+
runloop_mock = mock('Runloop')
|
75
|
+
OSX.expects(:CFRunLoopGetCurrent).returns(runloop_mock)
|
76
|
+
OSX.expects(:FSEventStreamScheduleWithRunLoop).with(stream_mock, runloop_mock, OSX::KCFRunLoopDefaultMode)
|
77
|
+
@fsevents.create_stream
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should start the stream" do
|
81
|
+
stream_mock = mock('Stream')
|
82
|
+
@fsevents.instance_variable_set(:@stream, stream_mock)
|
83
|
+
OSX.expects(:FSEventStreamStart).with(stream_mock).returns(true)
|
84
|
+
@fsevents.start
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should raise a Rucola::FSEvents::StreamError if the stream could not be started" do
|
88
|
+
OSX.expects(:FSEventStreamStart).returns(false)
|
89
|
+
lambda { @fsevents.start }.should.raise Rucola::FSEvents::StreamError
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "FSEvents when started the stream" do
|
94
|
+
before do
|
95
|
+
@paths = [TMP_PATH]
|
96
|
+
end
|
97
|
+
|
98
|
+
def touch_file
|
99
|
+
sleep 0.25
|
100
|
+
`touch #{@paths.first}/test.txt`
|
101
|
+
sleep 1.5
|
102
|
+
`rm #{@paths.first}/test.txt`
|
103
|
+
end
|
104
|
+
|
105
|
+
def start(fsevents)
|
106
|
+
fsevents.create_stream
|
107
|
+
fsevents.start
|
108
|
+
Thread.new { OSX.CFRunLoopRun }
|
109
|
+
end
|
110
|
+
|
111
|
+
xit "should run the user specified block when one of the paths that was specified is modified" do
|
112
|
+
some_mock = mock
|
113
|
+
some_mock.expects(:call!)
|
114
|
+
|
115
|
+
fsevents = Rucola::FSEvents.new(@paths) do |events|
|
116
|
+
some_mock.call!
|
117
|
+
|
118
|
+
events.length.should == 1
|
119
|
+
event = events.first
|
120
|
+
event.should.be.an.instance_of Rucola::FSEvents::FSEvent
|
121
|
+
event.path.should == @paths.first
|
122
|
+
end
|
123
|
+
p fsevents
|
124
|
+
start(fsevents)
|
125
|
+
touch_file
|
126
|
+
fsevents.stop
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "FSEvent" do
|
131
|
+
before do
|
132
|
+
@tmp_path = TMP_PATH
|
133
|
+
@new_file, @old_file = "#{@tmp_path}/new_file", "#{@tmp_path}/old_file"
|
134
|
+
|
135
|
+
`touch #{@old_file}`
|
136
|
+
sleep 1
|
137
|
+
`touch #{@new_file}`
|
138
|
+
end
|
139
|
+
|
140
|
+
after do
|
141
|
+
`rm #{@old_file}`
|
142
|
+
`rm #{@new_file}`
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should return an array of file entries in the path that the event occurred in, sorted by modification time (first element = last mod.)" do
|
146
|
+
Rucola::FSEvents::FSEvent.new(nil, 666, @tmp_path).files.should == [@new_file, @old_file]
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return the last modified file" do
|
150
|
+
Rucola::FSEvents::FSEvent.new(nil, 999, @tmp_path).last_modified_file.should == @new_file
|
151
|
+
end
|
152
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -4,10 +4,39 @@ require "test/spec"
|
|
4
4
|
require "mocha"
|
5
5
|
require 'osx/cocoa'
|
6
6
|
|
7
|
+
# suppress all the warnings about contsants being re-initialized when re-requiring the same lib
|
8
|
+
$VERBOSE = nil
|
9
|
+
|
7
10
|
$:.unshift File.expand_path('../../lib', __FILE__)
|
8
11
|
|
9
12
|
FIXTURES = File.expand_path('../fixtures/', __FILE__)
|
10
13
|
$TESTING = true
|
11
14
|
|
15
|
+
require 'pathname'
|
16
|
+
RUBYCOCOA_ROOT = Pathname.new(File.expand_path(File.dirname(__FILE__)))
|
17
|
+
RUBYCOCOA_ENV = 'test'
|
18
|
+
TMP_PATH = File.expand_path('../../tmp/', __FILE__)
|
19
|
+
|
12
20
|
require 'rucola/rucola_support'
|
13
|
-
require 'rucola/test_helper'
|
21
|
+
require 'rucola/test_helper'
|
22
|
+
|
23
|
+
# Don't know if this is good enough yet to add to the helpers for apps.
|
24
|
+
# Need to see what assert_difference does.
|
25
|
+
module Test::Spec::Rucola
|
26
|
+
module ShouldChange
|
27
|
+
def change(string, difference = 1, obj = nil)
|
28
|
+
initial_value = (obj.nil? ? eval(string) : obj.instance_eval(string))
|
29
|
+
@object.call
|
30
|
+
(obj.nil? ? eval(string) : obj.instance_eval(string)).should == initial_value + difference
|
31
|
+
end
|
32
|
+
end
|
33
|
+
module ShouldNotChange
|
34
|
+
def change(string, obj = nil)
|
35
|
+
initial_value = (obj.nil? ? eval(string) : obj.instance_eval(string))
|
36
|
+
@object.call
|
37
|
+
(obj.nil? ? eval(string) : obj.instance_eval(string)).should == initial_value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
Test::Spec::Should.send(:include, Test::Spec::Rucola::ShouldChange)
|
42
|
+
Test::Spec::ShouldNot.send(:include, Test::Spec::Rucola::ShouldNotChange)
|
data/test/test_initializer.rb
CHANGED
@@ -3,12 +3,18 @@ require 'rucola/initializer'
|
|
3
3
|
|
4
4
|
RUBYCOCOA_ROOT = Pathname.new('/MyApp')
|
5
5
|
|
6
|
+
module Rucola::Reloader; end
|
7
|
+
|
6
8
|
describe "Initializer's Class methods" do
|
7
9
|
# it "should load the plugins directly after loading the initializer file" do
|
8
10
|
# Rucola::Initializer.expects(:load_plugins)
|
9
11
|
# load 'rucola/initializer.rb'
|
10
12
|
# end
|
11
13
|
|
14
|
+
after do
|
15
|
+
Rucola::Initializer.instance_variable_set(:@initializer, nil)
|
16
|
+
end
|
17
|
+
|
12
18
|
it "should return the path to the plugins root directory" do
|
13
19
|
Rucola::Initializer.plugins_root.to_s.should == '/MyApp/vendor/plugins'
|
14
20
|
end
|
@@ -18,15 +24,17 @@ describe "Initializer's Class methods" do
|
|
18
24
|
Rucola::Initializer.expects(:plugins_root).returns(plugin_root_mock)
|
19
25
|
plugin_root_mock.expects(:exist?).returns(true)
|
20
26
|
|
21
|
-
|
22
|
-
plugin_root_mock.expects(:children).returns([
|
27
|
+
dir_with_initrb_mock, dir_without_initrb_mock = mock('Dir'), mock('Dir without init.irb')
|
28
|
+
plugin_root_mock.expects(:children).returns([dir_with_initrb_mock, dir_without_initrb_mock])
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
initrb_for_dir_with_initrb_mock = mock('init.rb does exist')
|
31
|
+
dir_with_initrb_mock.expects(:+).with('init.rb').returns(initrb_for_dir_with_initrb_mock)
|
32
|
+
initrb_for_dir_with_initrb_mock.expects(:exist?).returns(true)
|
33
|
+
Kernel.expects(:require).with(initrb_for_dir_with_initrb_mock)
|
26
34
|
|
27
|
-
|
28
|
-
|
29
|
-
|
35
|
+
initrb_for_dir_without_initrb_mock = mock('init.rb does not exist')
|
36
|
+
dir_without_initrb_mock.expects(:+).with('init.rb').returns(initrb_for_dir_without_initrb_mock)
|
37
|
+
initrb_for_dir_without_initrb_mock.expects(:exist?).returns(false)
|
30
38
|
|
31
39
|
Rucola::Initializer.load_plugins
|
32
40
|
end
|
@@ -39,10 +47,8 @@ describe "Initializer's Class methods" do
|
|
39
47
|
end
|
40
48
|
|
41
49
|
it "should perform the application's specific configuration and start the app" do
|
42
|
-
config_mock = mock('Configuration')
|
43
|
-
Rucola::Configuration.expects(:new).returns(config_mock)
|
44
50
|
initializer_mock = mock('Initializer')
|
45
|
-
Rucola::Initializer.expects(:new).
|
51
|
+
Rucola::Initializer.expects(:new).returns(initializer_mock)
|
46
52
|
initializer_mock.expects(:process)
|
47
53
|
Rucola::Initializer.expects(:start_app)
|
48
54
|
|
@@ -50,31 +56,58 @@ describe "Initializer's Class methods" do
|
|
50
56
|
end
|
51
57
|
|
52
58
|
it "should yield the configuration instance for setup purposes (this is used in the environments)" do
|
53
|
-
|
54
|
-
Rucola::Configuration.expects(:new).returns(config_mock)
|
55
|
-
Rucola::Initializer.any_instance.expects(:process)
|
56
|
-
Rucola::Initializer.expects(:start_app)
|
59
|
+
Rucola::Initializer.any_instance.stubs(:process)
|
57
60
|
|
58
61
|
Rucola::Initializer.run do |config|
|
59
|
-
config.should.be
|
62
|
+
config.should.be.instance_of Rucola::Configuration
|
63
|
+
|
64
|
+
Rucola::Initializer.run do |same_config|
|
65
|
+
same_config.should.be config
|
66
|
+
end
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
63
70
|
it "should actually start the main app run loop" do
|
64
|
-
|
65
|
-
Rucola::Initializer.start_app
|
71
|
+
with_env('release') { should_start_app(1) }
|
66
72
|
end
|
67
73
|
|
68
74
|
it "should not start the main app run loop if the RUBYCOCOA_ENV is 'test'" do
|
69
|
-
|
70
|
-
OSX.expects(:NSApplicationMain).times(0)
|
71
|
-
Rucola::Initializer.start_app
|
75
|
+
with_env('test') { should_start_app(0) }
|
72
76
|
end
|
73
77
|
|
74
78
|
it "should not start the main app run loop if ENV['DONT_START_RUBYCOCOA_APP'] has been set" do
|
75
|
-
::RUBYCOCOA_ENV = 'release'
|
76
79
|
ENV['DONT_START_RUBYCOCOA_APP'] = 'true'
|
77
|
-
|
80
|
+
should_start_app(0)
|
81
|
+
ENV['DONT_START_RUBYCOCOA_APP'] = nil
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def should_start_app(times = 0)
|
87
|
+
OSX.expects(:NSApplicationMain).times(times)
|
78
88
|
Rucola::Initializer.start_app
|
79
89
|
end
|
80
|
-
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "Initializer's instance methods" do
|
93
|
+
|
94
|
+
it "should not start the Reloader if that's set in the config" do
|
95
|
+
initializer = Rucola::Initializer.new
|
96
|
+
initializer.configuration.use_reloader = false
|
97
|
+
|
98
|
+
Kernel.expects(:require).times(0)
|
99
|
+
Rucola::Reloader.expects(:start!).times(0)
|
100
|
+
initializer.use_reloader!
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should start the Reloader if that's set in the config" do
|
104
|
+
initializer = Rucola::Initializer.new
|
105
|
+
initializer.configuration.use_reloader = true
|
106
|
+
|
107
|
+
Kernel.expects(:require).with('rucola/reloader')
|
108
|
+
Rucola::Reloader.expects(:start!)
|
109
|
+
initializer.use_reloader!
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# TODO: test dependencies.
|
data/test/test_log.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'rucola/log'
|
3
|
+
|
4
|
+
describe "Log" do
|
5
|
+
it "should be a singleton class" do
|
6
|
+
Rucola::Log.instance.object_id.should == Rucola::Log.instance.object_id
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "A Log instance" do
|
11
|
+
class LogCall < Exception; end
|
12
|
+
|
13
|
+
before do
|
14
|
+
@log = Rucola::Log.instance
|
15
|
+
OSX.stubs(:NSLog).raises(LogCall)
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
@log.level = @log.level_for_env
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the default level for a certain env" do
|
23
|
+
with_env('test') { @log.level_for_env.should == Rucola::Log::SILENT }
|
24
|
+
with_env('debug') { @log.level_for_env.should == Rucola::Log::DEBUG }
|
25
|
+
with_env('release') { @log.level_for_env.should == Rucola::Log::ERROR }
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should only log messages of the right level" do
|
29
|
+
@log.level = Rucola::Log::SILENT
|
30
|
+
lambda { @log.debug('-') }.should.not.raise(LogCall)
|
31
|
+
lambda { @log.error('-') }.should.not.raise(LogCall)
|
32
|
+
@log.level = Rucola::Log::DEBUG
|
33
|
+
lambda { @log.debug('-') }.should.raise(LogCall)
|
34
|
+
lambda { @log.error('-') }.should.raise(LogCall)
|
35
|
+
@log.level = Rucola::Log::ERROR
|
36
|
+
lambda { @log.debug('-') }.should.not.raise(LogCall)
|
37
|
+
lambda { @log.error('-') }.should.raise(LogCall)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should allow a change of log level" do
|
41
|
+
@log.level = Rucola::Log::DEBUG
|
42
|
+
@log.level.should == Rucola::Log::DEBUG
|
43
|
+
end
|
44
|
+
end
|
data/test/test_objc_core_ext.rb
CHANGED
@@ -34,4 +34,27 @@ describe "NSObject default mixins" do
|
|
34
34
|
it "should not mixin the initialize hooks if it's a subclass of a class that starts with anything else but 'Rucola::RC'" do
|
35
35
|
NotSubClassOfRC.methods.should.not.include '_rucola_register_initialize_hook'
|
36
36
|
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "NSImage.imageNamed" do
|
40
|
+
before do
|
41
|
+
@image1 = File.join(Rucola::RCApp.assets_path, 'hot_babe.jpg')
|
42
|
+
@image2 = File.join(Rucola::RCApp.assets_path, 'not_so_hot_babe.png')
|
43
|
+
Dir.stubs(:glob).with("#{Rucola::RCApp.assets_path}/*.*").returns(['.', '..', @image2, @image1])
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should find images without in app/assets" do
|
47
|
+
OSX::NSImage.any_instance.expects(:initWithContentsOfFile).with(@image1)
|
48
|
+
OSX::NSImage.imageNamed('hot_babe')
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should find images with extension in app/assets" do
|
52
|
+
OSX::NSImage.any_instance.expects(:initWithContentsOfFile).with(@image2)
|
53
|
+
OSX::NSImage.imageNamed('not_so_hot_babe.png')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should pass any unfound image name on to the original implementation" do
|
57
|
+
OSX::NSImage.expects(:super_imageNamed).with('whateva')
|
58
|
+
OSX::NSImage.imageNamed('whateva')
|
59
|
+
end
|
37
60
|
end
|
data/test/test_rc_app.rb
CHANGED
@@ -45,6 +45,11 @@ describe 'Rucola::RCApp' do
|
|
45
45
|
RCApp.path_for_model(Person).should == "#{@root_path}/app/models/person.rb"
|
46
46
|
end
|
47
47
|
|
48
|
+
it "should return the path to this applications app support dir" do
|
49
|
+
RCApp.stubs(:app_name).returns('FooApp')
|
50
|
+
RCApp.application_support_path.should == File.expand_path('~/Library/Application Support/FooApp')
|
51
|
+
end
|
52
|
+
|
48
53
|
it "should return the path for a given view" do
|
49
54
|
view_path = "#{@root_path}/app/views/Preferences.nib"
|
50
55
|
RCApp.path_for_view('Preferences').should == view_path
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
require 'rucola/reloader'
|
3
|
+
|
4
|
+
class SomeReloadableClass
|
5
|
+
def self.a_original_class_method; end
|
6
|
+
def a_original_instance_method; end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Reloader" do
|
10
|
+
it "should be able to reload a file/class" do
|
11
|
+
SomeReloadableClass.instance_methods(false).should == ['a_original_instance_method']
|
12
|
+
SomeReloadableClass.own_class_methods.should == ['a_original_class_method']
|
13
|
+
|
14
|
+
Rucola::Reloader.reload("#{FIXTURES}/some_reloadable_class.rb")
|
15
|
+
|
16
|
+
SomeReloadableClass.instance_methods(false).should == ['a_new_instance_method']
|
17
|
+
SomeReloadableClass.own_class_methods.should == ['a_new_class_method']
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should start watching app/controllers and reload a file if it has been modified" do
|
21
|
+
file = '/some/path/some_controller.rb'
|
22
|
+
event = mock('FSEvent')
|
23
|
+
event.expects(:last_modified_file).returns(file)
|
24
|
+
Rucola::FSEvents.expects(:start_watching).with(Rucola::RCApp.controllers_path, Rucola::RCApp.models_path).yields([event])
|
25
|
+
Rucola::Reloader.expects(:reload).with(file)
|
26
|
+
Rucola::Reloader.start!
|
27
|
+
end
|
28
|
+
end
|
@@ -39,16 +39,21 @@ class TestRucolaGenerator < Test::Unit::TestCase
|
|
39
39
|
assert_directory_exists "app/controllers"
|
40
40
|
assert_directory_exists "app/models"
|
41
41
|
assert_directory_exists "app/views"
|
42
|
+
assert_directory_exists "app/assets"
|
43
|
+
|
42
44
|
assert_directory_exists "config/environments"
|
43
45
|
assert_directory_exists "misc/English.lproj/MainMenu.nib"
|
44
46
|
assert_directory_exists "test/controllers"
|
47
|
+
assert_directory_exists "test/lib"
|
45
48
|
assert_directory_exists "test/models"
|
49
|
+
assert_directory_exists "lib"
|
46
50
|
assert_directory_exists "vendor"
|
47
51
|
|
48
52
|
assert_generated_file "Rakefile"
|
49
53
|
|
50
54
|
assert_generated_file "app/controllers/application_controller.rb"
|
51
55
|
assert_generated_file "config/boot.rb"
|
56
|
+
assert_generated_file "config/dependencies.rb"
|
52
57
|
assert_generated_file "config/environment.rb"
|
53
58
|
assert_generated_file "config/environments/debug.rb"
|
54
59
|
assert_generated_file "config/environments/release.rb"
|
@@ -71,7 +76,9 @@ class TestRucolaGenerator < Test::Unit::TestCase
|
|
71
76
|
assert_generated_file "test/controllers/test_application_controller.rb"
|
72
77
|
|
73
78
|
assert_directory_exists "script"
|
79
|
+
assert_generated_file "script/console"
|
74
80
|
assert_generated_file "script/plugin"
|
81
|
+
assert `ls -l #{File.expand_path('../tmp/myproject/script/console', __FILE__)}`[0..9] == '-rwxr-xr-x'
|
75
82
|
assert `ls -l #{File.expand_path('../tmp/myproject/script/plugin', __FILE__)}`[0..9] == '-rwxr-xr-x'
|
76
83
|
end
|
77
84
|
|