rucola 0.0.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/ChangeLog +468 -0
  2. data/History.txt +25 -0
  3. data/License.txt +1 -1
  4. data/Manifest.txt +32 -0
  5. data/README.txt +9 -67
  6. data/Rakefile +39 -31
  7. data/TODO +10 -18
  8. data/app_generators/rucola/rucola_generator.rb +15 -8
  9. data/app_generators/rucola/templates/Rakefile.erb +35 -7
  10. data/app_generators/rucola/templates/config/boot.rb +0 -1
  11. data/app_generators/rucola/templates/config/dependencies.rb +31 -0
  12. data/app_generators/rucola/templates/config/environment.rb +0 -1
  13. data/app_generators/rucola/templates/config/environments/debug.rb +13 -1
  14. data/app_generators/rucola/templates/config/environments/release.rb +15 -1
  15. data/app_generators/rucola/templates/config/environments/test.rb +7 -1
  16. data/app_generators/rucola/templates/misc/rb_main.rb.erb +12 -1
  17. data/app_generators/rucola/templates/project.pbxproj.erb +4 -0
  18. data/app_generators/rucola/templates/script/console +10 -0
  19. data/app_generators/rucola/templates/test/controllers/test_application_controller.rb +22 -10
  20. data/app_generators/rucola/templates/test/test_helper.rb +1 -0
  21. data/bin/rucola +4 -2
  22. data/lib/rucola/dependencies.rb +241 -0
  23. data/lib/rucola/dependencies/exclusions.rb +20 -0
  24. data/lib/rucola/dependencies/override_require_and_gem.rb +30 -0
  25. data/lib/rucola/dependencies/resolver.rb +68 -0
  26. data/lib/rucola/fsevents.rb +108 -0
  27. data/lib/rucola/initializer.rb +149 -117
  28. data/lib/rucola/log.rb +61 -0
  29. data/lib/rucola/nib.rb +3 -3
  30. data/lib/rucola/reloader.rb +39 -0
  31. data/lib/rucola/ruby_debug.rb +27 -0
  32. data/lib/rucola/rucola_support.rb +1 -2
  33. data/lib/rucola/rucola_support/core_ext.rb +4 -2
  34. data/lib/rucola/rucola_support/core_ext/objc.rb +9 -4
  35. data/lib/rucola/rucola_support/core_ext/objc/nsimage.rb +22 -0
  36. data/lib/rucola/rucola_support/core_ext/ruby.rb +11 -4
  37. data/lib/rucola/rucola_support/core_ext/ruby/file.rb +11 -0
  38. data/lib/rucola/rucola_support/core_ext/ruby/kernel.rb +16 -0
  39. data/lib/rucola/rucola_support/core_ext/ruby/object.rb +47 -0
  40. data/lib/rucola/rucola_support/core_ext/ruby/string.rb +8 -0
  41. data/lib/rucola/rucola_support/notifications/notifications.rb +26 -28
  42. data/lib/rucola/rucola_support/rc_app.rb +18 -0
  43. data/lib/rucola/tasks/dependencies.rake +49 -0
  44. data/lib/rucola/tasks/deploy.rake +131 -0
  45. data/lib/rucola/tasks/main.rake +39 -6
  46. data/lib/rucola/tasks/xcode.rake +54 -11
  47. data/lib/rucola/test_case.rb +138 -0
  48. data/lib/rucola/test_helper.rb +11 -5
  49. data/lib/rucola/version.rb +2 -2
  50. data/lib/rucola/xcode.rb +39 -9
  51. data/rucola_generators/controller/templates/test_controller_template.rb.erb +19 -7
  52. data/rucola_generators/simple_model/USAGE +5 -0
  53. data/rucola_generators/simple_model/simple_model_generator.rb +54 -0
  54. data/rucola_generators/simple_model/templates/simple_model.rb.erb +2 -0
  55. data/rucola_generators/simple_model/templates/test_simple_model.rb.erb +11 -0
  56. data/rucola_generators/window_controller/templates/test_window_controller_template.rb.erb +24 -13
  57. data/test/fixtures/dependencies/foo.rb +2 -0
  58. data/test/fixtures/dependencies/foo/bar.rb +0 -0
  59. data/test/fixtures/dependencies/foo/baz.rb +0 -0
  60. data/test/fixtures/dependencies/requires_fileutils.rb +1 -0
  61. data/test/fixtures/some_reloadable_class.rb +4 -0
  62. data/test/test_core_ext.rb +80 -0
  63. data/test/test_dependencies.rb +205 -0
  64. data/test/test_fsevents.rb +152 -0
  65. data/test/test_helper.rb +30 -1
  66. data/test/test_initializer.rb +56 -23
  67. data/test/test_log.rb +44 -0
  68. data/test/test_objc_core_ext.rb +23 -0
  69. data/test/test_rc_app.rb +5 -0
  70. data/test/test_reloader.rb +28 -0
  71. data/test/test_rucola_generator.rb +7 -0
  72. data/test/test_simple_model_generator.rb +48 -0
  73. data/test/test_xcode.rb +85 -5
  74. data/website/index.html +17 -91
  75. data/website/index.txt +14 -81
  76. data/website/template.rhtml +1 -1
  77. metadata +120 -76
@@ -1,8 +1,8 @@
1
1
  module Rucola #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 3
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -2,9 +2,7 @@ require 'osx/cocoa'
2
2
  require 'pathname'
3
3
 
4
4
  module Rucola
5
- class Xcode
6
- # FIXME: We should probably generate random id keys!
7
-
5
+ class Xcode #:nodoc:
8
6
  attr_reader :project
9
7
  attr_reader :project_path
10
8
  attr_reader :project_data
@@ -86,7 +84,41 @@ module Rucola
86
84
  build_phase['files'].push(object_id) unless build_phase['files'].include?(object_id)
87
85
  end
88
86
 
89
- NEW_COPY_FRAMEWORKS_BUILD_PHASE = ['519A79DB0CC8AE6B00CBE85D', {
87
+ # Returns an array of framework objects that are in the project.
88
+ def frameworks
89
+ objects.select {|obj| obj.last['name'].include?('framework') unless obj.last['name'].nil? }
90
+ end
91
+
92
+ # Adds a framework to a project.
93
+ # Returns [framework_obj, fileref_obj].
94
+ def add_framework(name, path)
95
+ source_tree = path[0, 1] == '/' ? '<absolute>' : '<group>'
96
+ framework_obj = [generate_object_id, { 'isa' => 'PBXFileReference', 'lastKnownFileType' => 'wrapper.framework', 'name' => name, 'path' => path, 'sourceTree' => source_tree }.to_ns]
97
+ add_object(*framework_obj)
98
+
99
+ fileref_obj = [generate_object_id, { 'fileRef' => framework_obj.first, 'isa' => 'PBXBuildFile'}.to_ns]
100
+ add_object(*fileref_obj)
101
+
102
+ linked_frameworks_group = object_for_name('Linked Frameworks')
103
+ linked_frameworks_group.last['children'].push(framework_obj.first)
104
+
105
+ [framework_obj, fileref_obj]
106
+ end
107
+
108
+ def generate_uuid
109
+ ("%04x%04x%04x%04x%04x%04x" % [rand(0x0010000),rand(0x0010000),rand(0x0010000),rand(0x0010000),rand(0x0010000),rand(0x0010000)]).upcase
110
+ end
111
+
112
+ # Makes sure that an unique object UUID is returned
113
+ def generate_object_id
114
+ uuids = objects.keys
115
+ begin
116
+ uuid = generate_uuid
117
+ end while uuids.include?(uuid)
118
+ uuid
119
+ end
120
+
121
+ NEW_COPY_FRAMEWORKS_BUILD_PHASE = {
90
122
  'name' => 'Copy Frameworks',
91
123
  'isa' => 'PBXCopyFilesBuildPhase',
92
124
  'buildActionMask' => '2147483647',
@@ -94,14 +126,12 @@ module Rucola
94
126
  'dstSubfolderSpec' => 10, # TODO: is 10 the number for the location popup choice: Frameworks
95
127
  'runOnlyForDeploymentPostprocessing' => 0,
96
128
  'files' => [].to_ns
97
- }]
129
+ }
98
130
  # Creates a new framework copy build phase.
99
131
  # It does not add it to the objects nor the build phases,
100
132
  # do this with +add_object+ and +add_build_phase_to_project_target+.
101
- #
102
- # FIXME: Need to generate the id's instead of static.
103
133
  def new_framework_copy_build_phase
104
- NEW_COPY_FRAMEWORKS_BUILD_PHASE
134
+ [generate_object_id, NEW_COPY_FRAMEWORKS_BUILD_PHASE]
105
135
  end
106
136
 
107
137
  # Changes the path of the framework +framework_name+ to the path +new_path_to_framework+.
@@ -121,7 +151,7 @@ module Rucola
121
151
  framework_id, framework_values = object_for_name(framework_name)
122
152
 
123
153
  # create a new file wrapper for in the copy build phase
124
- framework_in_build_phase_id = '511E98590CC8C5940003DED9'
154
+ framework_in_build_phase_id = generate_object_id
125
155
  framework_in_build_phase_values = {
126
156
  'isa' => 'PBXBuildFile',
127
157
  'fileRef' => framework_id
@@ -1,19 +1,31 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe '<%= name.camel_case %>Controller' do
4
- before do
5
- @controller = <%= name.camel_case %>Controller.alloc.init
6
- end
7
-
4
+ tests <%= name.camel_case %>Controller
5
+
6
+ # If necessary, you can setup custom objects for the ib_outlets defined in the class.
7
+ # Note however that by using 'tests <%= name.camel_case %>Controller' all the outlets will get stubbed
8
+ # with stubs that respond to every message with nil.
9
+ #
10
+ # def after_setup
11
+ # ib_outlets :window => mock("Main Window"),
12
+ # :tableView => OSX::NSTableView.alloc.init,
13
+ # :searchField => OSX::NSSearchField.alloc.init
14
+ #
15
+ # window.stubs(:title => 'Main Window')
16
+ # tableView.addTableColumn OSX::NSTableColumn.alloc.init
17
+ # searchField.stringValue = "foo"
18
+ # end
19
+
8
20
  it "should initialize" do
9
- @controller.should.be.an.instance_of <%= name.camel_case %>Controller
21
+ controller.should.be.an.instance_of <%= name.camel_case %>Controller
10
22
  end
11
23
 
12
24
  it "should do stuff at awakeFromNib" do
13
25
  # Some example code of testing your #awakeFromNib.
14
26
  #
15
- # @controller.ib_outlet(:some_text_view).expects(:string=).with('foo')
27
+ # controller.ib_outlet(:some_text_view).expects(:string=).with('foo')
16
28
 
17
- @controller.awakeFromNib
29
+ controller.awakeFromNib
18
30
  end
19
31
  end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Generates a model which is simply a subclass of OSX::NSObject.
3
+
4
+ Usage:
5
+ script/generate simple_model foo_bar
@@ -0,0 +1,54 @@
1
+ require 'rucola/rucola_support'
2
+
3
+ class SimpleModelGenerator < RubiGen::Base
4
+
5
+ default_options :author => nil
6
+
7
+ attr_reader :name
8
+
9
+ def initialize(runtime_args, runtime_options = {})
10
+ super
11
+ usage if args.empty?
12
+ @name = args.shift
13
+ extract_options
14
+ end
15
+
16
+ def manifest
17
+ record do |m|
18
+ # Ensure appropriate folder(s) exists
19
+ m.directory 'app/models'
20
+ m.directory 'test/models'
21
+
22
+ # Create stubs
23
+ m.template "simple_model.rb.erb", "app/models/#{@name.snake_case}.rb"
24
+ m.template "test_simple_model.rb.erb", "test/models/test_#{@name.snake_case}.rb"
25
+ end
26
+ end
27
+
28
+ protected
29
+ def banner
30
+ <<-EOS
31
+ Creates a model that inherits from NSObject.
32
+
33
+ USAGE: #{$0} #{spec.name} name"
34
+ EOS
35
+ end
36
+
37
+ def add_options!(opts)
38
+ # opts.separator ''
39
+ # opts.separator 'Options:'
40
+ # For each option below, place the default
41
+ # at the top of the file next to "default_options"
42
+ # opts.on("-a", "--author=\"Your Name\"", String,
43
+ # "Some comment about this option",
44
+ # "Default: none") { |options[:author]| }
45
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
46
+ end
47
+
48
+ def extract_options
49
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
50
+ # Templates can access these value via the attr_reader-generated methods, but not the
51
+ # raw instance variable value.
52
+ # @author = options[:author]
53
+ end
54
+ end
@@ -0,0 +1,2 @@
1
+ class <%= name.camel_case %> < OSX::NSObject
2
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ describe '<%= name.camel_case %>' do
4
+ before do
5
+ @model = <%= name.camel_case %>.alloc.init
6
+ end
7
+
8
+ it "should initialize" do
9
+ @model.should.be.an.instance_of <%= name.camel_case %>
10
+ end
11
+ end
@@ -1,26 +1,37 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe '<%= name.camel_case %>Controller' do
4
- before do
5
- @controller = <%= name.camel_case %>Controller.alloc.init
6
-
7
- # If this is a window controller belonging to a document model,
8
- # then this will allow you to mock the document.
9
- #
10
- # @document = mock('Document')
11
- # @controller.stubs(:document).returns(@document)
12
- end
13
-
4
+ tests <%= name.camel_case %>Controller
5
+
6
+ # If necessary, you can setup custom objects for the ib_outlets defined in the class.
7
+ # Note however that by using 'tests <%= name.camel_case %>Controller' all the outlets will get stubbed
8
+ # with stubs that respond to every message with nil.
9
+ #
10
+ # def after_setup
11
+ # ib_outlets :window => mock("Main Window"),
12
+ # :tableView => OSX::NSTableView.alloc.init,
13
+ # :searchField => OSX::NSSearchField.alloc.init
14
+ #
15
+ # window.stubs(:title => 'Main Window')
16
+ # tableView.addTableColumn OSX::NSTableColumn.alloc.init
17
+ # searchField.stringValue = "foo"
18
+ #
19
+ # # If this is a window controller belonging to a document model,
20
+ # # then this will allow you to mock the document.
21
+ # #
22
+ # # @document = mock('Document')
23
+ # end
24
+
14
25
  it "should initialize" do
15
- @controller.should.be.an.instance_of <%= name.camel_case %>Controller
26
+ controller.should.be.an.instance_of <%= name.camel_case %>Controller
16
27
  end
17
28
 
18
29
  it "should do stuff at awakeFromNib" do
19
30
  # Some example code of testing your #awakeFromNib.
20
31
  #
21
32
  # @document.expects(:some_method).returns('foo')
22
- # @controller.ib_outlet(:some_text_view).expects(:string=).with('foo')
33
+ # controller.ib_outlet(:some_text_view).expects(:string=).with('foo')
23
34
 
24
- @controller.awakeFromNib
35
+ controller.awakeFromNib
25
36
  end
26
37
  end
@@ -0,0 +1,2 @@
1
+ require 'foo/bar'
2
+ require File.expand_path('../foo/baz.rb', __FILE__)
File without changes
File without changes
@@ -0,0 +1 @@
1
+ require 'fileutils'
@@ -0,0 +1,4 @@
1
+ class SomeReloadableClass
2
+ def self.a_new_class_method; end
3
+ def a_new_instance_method; end
4
+ end
@@ -1,5 +1,51 @@
1
1
  require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
+ class FooBar
4
+ def self.a_original_class_method
5
+ end
6
+ end
7
+
8
+ module Baz
9
+ def a_new_class_method; end
10
+ end
11
+ FooBar.extend(Baz)
12
+
13
+ class FooBarSubclass < FooBar
14
+ def self.a_original_class_method_in_a_subclass
15
+ end
16
+ end
17
+
18
+ # Object ext. specs
19
+
20
+ describe "Object: class methods" do
21
+ it "should return the metaclass of a class" do
22
+ class << FooBar
23
+ self.should.be FooBar.metaclass
24
+ end
25
+ end
26
+
27
+ it "should return an array of class methods that have been added by extending the class" do
28
+ FooBar.extended_class_methods.should.include 'a_new_class_method'
29
+ FooBar.extended_class_methods.should.not.include 'a_original_class_method'
30
+ end
31
+
32
+ it "should return an array of all the class methods that were defined in this class without the ones that were defined in superclasses" do
33
+ FooBarSubclass.own_class_methods.should.include 'a_original_class_method_in_a_subclass'
34
+ FooBarSubclass.own_class_methods.should.not.include 'a_original_class_method'
35
+ end
36
+
37
+ it "should return an array of all the class methods that were defined in only this class, so not from it's superclasses or from extending" do
38
+ FooBar.original_class_methods.should.include 'a_original_class_method'
39
+ FooBar.original_class_methods.should.not.include 'a_new_class_method'
40
+
41
+ FooBarSubclass.original_class_methods.should.include 'a_original_class_method_in_a_subclass'
42
+ FooBarSubclass.original_class_methods.should.not.include 'a_original_class_method'
43
+ FooBarSubclass.original_class_methods.should.not.include 'a_new_class_method'
44
+ end
45
+ end
46
+
47
+ # String ext. specs
48
+
3
49
  describe 'String#camel_case' do
4
50
  it "should return foo_bar as FooBar" do
5
51
  "foo_bar".camel_case.should == 'FooBar'
@@ -13,3 +59,37 @@ describe 'String#camel_case' do
13
59
  'foo'.camel_case.should == 'Foo'
14
60
  end
15
61
  end
62
+
63
+ describe "String#to_const" do
64
+ it "should return the constant FooBar for string 'foo_bar'" do
65
+ "foo_bar".to_const.should.be FooBar
66
+ end
67
+
68
+ it "should return the constant FooBar for string 'FooBar'" do
69
+ "FooBar".to_const.should.be FooBar
70
+ end
71
+ end
72
+
73
+ # File ext. specs
74
+
75
+ describe "File.to_const" do
76
+ it "should return the constant FooBar for file '/some/path/foo_bar.rb'" do
77
+ File.to_const('/some/path/foo_bar.rb').should.be FooBar
78
+ end
79
+
80
+ it "should return the constant FooBar for file 'foo_bar.rb'" do
81
+ File.to_const('foo_bar.rb').should.be FooBar
82
+ end
83
+ end
84
+
85
+ # Kernel ext. specs
86
+
87
+ describe "Kernel.logger" do
88
+ it "should return a Rucola Log class instance" do
89
+ Kernel.log.kind_of?(Rucola::Log).should == true
90
+ end
91
+
92
+ it "should return the same logger instance on multiple calls" do
93
+ Kernel.log.object_id.should == Kernel.log.object_id
94
+ end
95
+ end
@@ -0,0 +1,205 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'rucola/dependencies'
3
+
4
+ Rucola::Dependencies.verbose = false
5
+ $LOAD_PATH.unshift(File.join(FIXTURES, 'dependencies/'))
6
+
7
+ module DependenciesSpecHelper
8
+ def self.included(klass)
9
+ klass.class_eval do
10
+ after do
11
+ @dep = nil
12
+ FileUtils.rm_rf(copied_deps_path)
13
+ end
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def deps_path(file = '')
20
+ File.join(FIXTURES, 'dependencies', file)
21
+ end
22
+
23
+ def copied_deps_path(file = '')
24
+ File.join(TMP_PATH, 'copied_dependencies', file)
25
+ end
26
+
27
+ def stubbed_equal_required_files
28
+ klass = Rucola::Dependencies::RequiredFile
29
+ klass.any_instance.stubs(:resolve_relative_and_full_path).returns(['path/foo.rb', '/full/path/foo.rb'])
30
+ [klass.new(''), klass.new('')]
31
+ end
32
+ end
33
+
34
+ describe "Dependencies::Dependency" do
35
+ include DependenciesSpecHelper
36
+
37
+ before do
38
+ @dep = Rucola::Dependencies::Dependency.new('foo')
39
+ end
40
+
41
+ after do
42
+ @dep = nil
43
+ FileUtils.rm_rf(copied_deps_path)
44
+ end
45
+
46
+ it "should initialize" do
47
+ @dep.should.be.instance_of Rucola::Dependencies::Dependency
48
+ @dep.name.should == 'foo'
49
+ end
50
+
51
+ it "should be able to require it" do
52
+ Kernel.expects(:require).with('foo')
53
+ @dep.require!
54
+ end
55
+
56
+ it "should activate a specific gem if a version is specified" do
57
+ Kernel.stubs(:require)
58
+ @dep.instance_variable_set(:@version, '1.1.1')
59
+ Gem.expects(:activate).with('foo', '1.1.1')
60
+ @dep.require!
61
+ end
62
+
63
+ it "should be able to resolve the files it needs" do
64
+ lambda { @dep.resolve! }.should.not.change('$LOADED_FEATURES.dup')
65
+ required_files = @dep.required_files.map {|f| f.full_path }.sort
66
+ required_files.should == [deps_path('foo.rb'), deps_path('foo/bar.rb'), deps_path('foo/baz.rb')]
67
+ end
68
+
69
+ # FIXME: For some reason running this in the complete test suite will fail.
70
+ # But in practice or by only running this test it works :/
71
+ xit "should be able to copy to the specified destination path" do
72
+ @dep.resolve!
73
+ @dep.copy_to(copied_deps_path)
74
+ %w{ foo.rb foo/bar.rb foo/baz.rb }.each do |file|
75
+ File.exist?(copied_deps_path(file)).should.be true
76
+ end
77
+ end
78
+
79
+ it "should be possible to only copy `gem` lib files" do
80
+ should_copy_types(:gem)
81
+ @dep.copy_to(copied_deps_path, :types => [:gem])
82
+ end
83
+
84
+ it "should be possible to only copy `standard` lib files" do
85
+ should_copy_types(:standard)
86
+ @dep.copy_to(copied_deps_path, :types => [:standard])
87
+ end
88
+
89
+ it "should be possible to only copy `gem` libs" do
90
+ should_copy_types(:other)
91
+ @dep.copy_to(copied_deps_path, :types => [:other])
92
+ end
93
+
94
+ it "should be possible to combine the types of libs to be copied" do
95
+ should_copy_types(:other, :gem)
96
+ @dep.copy_to(copied_deps_path, :types => [:other, :gem])
97
+ end
98
+
99
+ it "should be possible to get a list of required files of only certain types" do
100
+ dep = Rucola::Dependencies::Dependency.new('requires_fileutils')
101
+ dep.resolve!
102
+ dep.required_files_of_types(:other).all? {|f| f.should.be.other_lib }
103
+ dep.required_files_of_types(:standard).all? {|f| f.should.be.standard_lib }
104
+ end
105
+
106
+ private
107
+
108
+ def should_copy_types(*types)
109
+ keys = [:gem, :other, :standard]
110
+ files = []
111
+ keys.each do |type|
112
+ file = mock(type.to_s)
113
+ file.stubs({ :full_path => '/some/path', :gem_lib? => false, :standard_lib? => false, :other_lib? => false }.merge({ "#{type}_lib?".to_sym => true }))
114
+ if types.include?(type)
115
+ file.expects(:copy_to).times(1).with(copied_deps_path)
116
+ else
117
+ file.expects(:copy_to).times(0)
118
+ end
119
+ files << file
120
+ end
121
+ @dep.instance_variable_set(:@required_files, files)
122
+ end
123
+ end
124
+
125
+ describe "Dependencies" do
126
+ include DependenciesSpecHelper
127
+
128
+ before do
129
+ @deps = Rucola::Dependencies.new
130
+ @deps.dependency 'foo'
131
+ @deps.dependency 'rubynode', '>=0.1.3'
132
+ @deps.dependency 'fileutils'
133
+ @deps.resolve!
134
+ end
135
+
136
+ it "should create a Dependency instance when a dependency is specified" do
137
+ lambda { @deps.dependency('hpricot') }.should.change("@deps.dependencies.length", +1, self)
138
+ end
139
+
140
+ it "should be able to require all the dependencies" do
141
+ @deps.dependencies.each { |dep| dep.expects(:require!) }
142
+ @deps.require!
143
+ end
144
+
145
+ it "should be able to resolve all the files needed by the dependencies" do
146
+ @deps.dependencies.each do |dep|
147
+ dep.required_files.should.not.be.empty
148
+ end
149
+ end
150
+
151
+ it "should be able to copy to the specified destination path" do
152
+ @deps.copy_to(copied_deps_path)
153
+ %w{ foo.rb rubynode.rb fileutils.rb }.each do |file|
154
+ File.exist?(copied_deps_path(file)).should.be true
155
+ end
156
+ end
157
+
158
+ it "should be possible to only copy specific types of files" do
159
+ @deps.dependencies.each do |dep|
160
+ dep.expects(:copy_to).with(copied_deps_path, { :types => [:gem, :other]})
161
+ end
162
+ @deps.copy_to(copied_deps_path, :types => [:gem, :other])
163
+ end
164
+
165
+ it "should be able to return a complete list of unique required files" do
166
+ files = stubbed_equal_required_files
167
+ @deps.dependencies.stubs(:collect).returns([[files.first], [files.last]])
168
+
169
+ @deps.required_files.length.should.be 1
170
+ end
171
+ end
172
+
173
+ describe "Dependencies::Dependency::RequiredFile" do
174
+ include DependenciesSpecHelper
175
+
176
+ it "should be able to compare to another instance" do
177
+ files = stubbed_equal_required_files
178
+ files.first.should == files.last
179
+ end
180
+ end
181
+
182
+ describe "Dependencies, with problematic dependencies" do
183
+ before do
184
+ @deps = Rucola::Dependencies.new
185
+ end
186
+
187
+ # FIXME: resolving activesupport works, but combined with stubbing resolve_relative_and_full_path it breaks...
188
+ xit "should not break with activesupport" do
189
+ @deps.dependency 'activesupport'
190
+ @deps.resolve!
191
+ @deps.dependencies.first.required_files.should.not.be.empty
192
+ end
193
+
194
+ it "should not break with osx/cocoa (excluded)" do
195
+ @deps.dependency 'osx/cocoa'
196
+ @deps.resolve!
197
+ @deps.dependencies.first.required_files.should.be.empty
198
+ end
199
+
200
+ it "should not break with osx/foundation (excluded)" do
201
+ @deps.dependency 'osx/foundation'
202
+ @deps.resolve!
203
+ @deps.dependencies.first.required_files.should.be.empty
204
+ end
205
+ end