bpm 1.0.0.beta.4 → 1.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/TODO.md +4 -10
  3. data/backbone/LICENSE +22 -0
  4. data/backbone/README +25 -0
  5. data/backbone/Rakefile +42 -0
  6. data/backbone/backbone-0.5.1.bpkg +0 -0
  7. data/backbone/examples/backbone-localstorage.js +84 -0
  8. data/backbone/examples/todos/destroy.png +0 -0
  9. data/backbone/examples/todos/index.html +87 -0
  10. data/backbone/examples/todos/todos.css +311 -0
  11. data/backbone/examples/todos/todos.js +258 -0
  12. data/backbone/index.html +2606 -0
  13. data/backbone/index.js +1 -0
  14. data/backbone/lib/backbone.js +1149 -0
  15. data/backbone/lib/index.js +1 -0
  16. data/backbone/package.json +14 -0
  17. data/backbone/test/collection.js +345 -0
  18. data/backbone/test/events.js +70 -0
  19. data/backbone/test/model.coffee +43 -0
  20. data/backbone/test/model.js +424 -0
  21. data/backbone/test/noconflict.js +12 -0
  22. data/backbone/test/router.js +116 -0
  23. data/backbone/test/speed.js +45 -0
  24. data/backbone/test/sync.js +133 -0
  25. data/backbone/test/test-zepto.html +30 -0
  26. data/backbone/test/test.html +31 -0
  27. data/backbone/test/vendor/jquery-1.5.js +8176 -0
  28. data/backbone/test/vendor/jslitmus.js +649 -0
  29. data/backbone/test/vendor/json2.js +481 -0
  30. data/backbone/test/vendor/qunit.css +196 -0
  31. data/backbone/test/vendor/qunit.js +1364 -0
  32. data/backbone/test/vendor/underscore-1.1.6.js +807 -0
  33. data/backbone/test/vendor/zepto-0.6.js +692 -0
  34. data/backbone/test/view.js +137 -0
  35. data/lib/bpm/cli/base.rb +22 -7
  36. data/lib/bpm/package.rb +17 -5
  37. data/lib/bpm/project.rb +49 -32
  38. data/lib/bpm/version.rb +1 -1
  39. data/spec/cli/add_spec.rb +22 -4
  40. data/spec/cli/fetch_spec.rb +0 -1
  41. data/spec/cli/init_spec.rb +25 -10
  42. data/spec/cli/list_spec.rb +103 -62
  43. data/spec/cli/pack_spec.rb +36 -4
  44. data/spec/fixtures/packages/backbone/LICENSE +22 -0
  45. data/spec/fixtures/packages/backbone/README +25 -0
  46. data/spec/fixtures/packages/backbone/Rakefile +42 -0
  47. data/spec/fixtures/packages/backbone/examples/backbone-localstorage.js +84 -0
  48. data/spec/fixtures/packages/backbone/examples/todos/destroy.png +0 -0
  49. data/spec/fixtures/packages/backbone/examples/todos/index.html +87 -0
  50. data/spec/fixtures/packages/backbone/examples/todos/todos.css +311 -0
  51. data/spec/fixtures/packages/backbone/examples/todos/todos.js +258 -0
  52. data/spec/fixtures/packages/backbone/index.html +2606 -0
  53. data/spec/fixtures/packages/backbone/lib/backbone.js +1149 -0
  54. data/spec/fixtures/packages/backbone/lib/index.js +1 -0
  55. data/spec/fixtures/packages/backbone/package.json +14 -0
  56. data/spec/fixtures/packages/backbone/test/collection.js +345 -0
  57. data/spec/fixtures/packages/backbone/test/events.js +70 -0
  58. data/spec/fixtures/packages/backbone/test/model.coffee +43 -0
  59. data/spec/fixtures/packages/backbone/test/model.js +424 -0
  60. data/spec/fixtures/packages/backbone/test/noconflict.js +12 -0
  61. data/spec/fixtures/packages/backbone/test/router.js +116 -0
  62. data/spec/fixtures/packages/backbone/test/speed.js +45 -0
  63. data/spec/fixtures/packages/backbone/test/sync.js +133 -0
  64. data/spec/fixtures/packages/backbone/test/test-zepto.html +30 -0
  65. data/spec/fixtures/packages/backbone/test/test.html +31 -0
  66. data/spec/fixtures/packages/backbone/test/vendor/jquery-1.5.js +8176 -0
  67. data/spec/fixtures/packages/backbone/test/vendor/jslitmus.js +649 -0
  68. data/spec/fixtures/packages/backbone/test/vendor/json2.js +481 -0
  69. data/spec/fixtures/packages/backbone/test/vendor/qunit.css +196 -0
  70. data/spec/fixtures/packages/backbone/test/vendor/qunit.js +1364 -0
  71. data/spec/fixtures/packages/backbone/test/vendor/underscore-1.1.6.js +807 -0
  72. data/spec/fixtures/packages/backbone/test/vendor/zepto-0.6.js +692 -0
  73. data/spec/fixtures/packages/backbone/test/view.js +137 -0
  74. data/spec/fixtures/projects/init_app/assets/bpm_libs.js +1 -1
  75. data/spec/fixtures/projects/init_app/assets/bpm_styles.css +1 -1
  76. data/spec/fixtures/projects/init_app/new_project.json +1 -10
  77. data/spec/pipeline_spec.rb +5 -5
  78. data/spec/plugins/minifier_spec.rb +1 -1
  79. data/spec/plugins/transport_spec.rb +1 -1
  80. metadata +116 -28
  81. data/spec/fixtures/projects/init_app/assets/new_project/bpm_libs.js +0 -6
  82. data/spec/fixtures/projects/init_app/assets/new_project/bpm_styles.css +0 -5
@@ -0,0 +1,137 @@
1
+ $(document).ready(function() {
2
+
3
+ module("Backbone.View");
4
+
5
+ var view = new Backbone.View({
6
+ id : 'test-view',
7
+ className : 'test-view'
8
+ });
9
+
10
+ test("View: constructor", function() {
11
+ equals(view.el.id, 'test-view');
12
+ equals(view.el.className, 'test-view');
13
+ equals(view.options.id, 'test-view');
14
+ equals(view.options.className, 'test-view');
15
+ });
16
+
17
+ test("View: jQuery", function() {
18
+ view.el = document.body;
19
+ ok(view.$('#qunit-header a').get(0).innerHTML.match(/Backbone Test Suite/));
20
+ ok(view.$('#qunit-header a').get(1).innerHTML.match(/Backbone Speed Suite/));
21
+ });
22
+
23
+ test("View: make", function() {
24
+ var div = view.make('div', {id: 'test-div'}, "one two three");
25
+ equals(div.tagName.toLowerCase(), 'div');
26
+ equals(div.id, 'test-div');
27
+ equals($(div).text(), 'one two three');
28
+ });
29
+
30
+ test("View: initialize", function() {
31
+ var View = Backbone.View.extend({
32
+ initialize: function() {
33
+ this.one = 1;
34
+ }
35
+ });
36
+ var view = new View;
37
+ equals(view.one, 1);
38
+ });
39
+
40
+ test("View: delegateEvents", function() {
41
+ var counter = counter2 = 0;
42
+ view.el = document.body;
43
+ view.increment = function(){ counter++; };
44
+ $(view.el).bind('click', function(){ counter2++; });
45
+ var events = {"click #qunit-banner": "increment"};
46
+ view.delegateEvents(events);
47
+ $('#qunit-banner').trigger('click');
48
+ equals(counter, 1);
49
+ equals(counter2, 1);
50
+ $('#qunit-banner').trigger('click');
51
+ equals(counter, 2);
52
+ equals(counter2, 2);
53
+ view.delegateEvents(events);
54
+ $('#qunit-banner').trigger('click');
55
+ equals(counter, 3);
56
+ equals(counter2, 3);
57
+ });
58
+
59
+ test("View: _ensureElement with DOM node el", function() {
60
+ var ViewClass = Backbone.View.extend({
61
+ el: document.body
62
+ });
63
+ var view = new ViewClass;
64
+ equals(view.el, document.body);
65
+ });
66
+
67
+ test("View: _ensureElement with string el", function() {
68
+ var ViewClass = Backbone.View.extend({
69
+ el: "body"
70
+ });
71
+ var view = new ViewClass;
72
+ equals(view.el, document.body);
73
+
74
+ ViewClass = Backbone.View.extend({
75
+ el: "body > h2"
76
+ });
77
+ view = new ViewClass;
78
+ equals(view.el, $("#qunit-banner").get(0));
79
+
80
+ ViewClass = Backbone.View.extend({
81
+ el: "#nonexistent"
82
+ });
83
+ view = new ViewClass;
84
+ ok(!view.el);
85
+ });
86
+
87
+ test("View: with attributes", function() {
88
+ var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}});
89
+ equals(view.el.className, 'one');
90
+ equals(view.el.id, 'two');
91
+ });
92
+
93
+ test("View: multiple views per element", function() {
94
+ var count = 0, ViewClass = Backbone.View.extend({
95
+ el: $("body"),
96
+ events: {
97
+ "click": "click"
98
+ },
99
+ click: function() {
100
+ count++;
101
+ }
102
+ });
103
+
104
+ var view1 = new ViewClass;
105
+ $("body").trigger("click");
106
+ equals(1, count);
107
+
108
+ var view2 = new ViewClass;
109
+ $("body").trigger("click");
110
+ equals(3, count);
111
+
112
+ view1.delegateEvents();
113
+ $("body").trigger("click");
114
+ equals(5, count);
115
+ });
116
+
117
+ test("View: custom events, with namespaces", function() {
118
+ var count = 0;
119
+ var ViewClass = Backbone.View.extend({
120
+ el: $('body'),
121
+ events: {
122
+ "fake$event.namespaced": "run"
123
+ },
124
+ run: function() {
125
+ count++;
126
+ }
127
+ });
128
+
129
+ var view = new ViewClass;
130
+ $('body').trigger('fake$event').trigger('fake$event');
131
+ equals(count, 2);
132
+ $('body').unbind('.namespaced');
133
+ $('body').trigger('fake$event');
134
+ equals(count, 2);
135
+ });
136
+
137
+ });
data/lib/bpm/cli/base.rb CHANGED
@@ -207,12 +207,27 @@ module BPM
207
207
  end
208
208
 
209
209
  desc "list", "View available packages for download"
210
- method_option :all, :type => :boolean, :default => false, :aliases => ['-a'], :desc => 'List all versions available'
211
- method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'List prerelease versions available'
210
+ method_option :remote, :type => :boolean, :default => false, :aliases => ['-r'], :desc => 'List packages on remote server'
211
+ method_option :all, :type => :boolean, :default => false, :aliases => ['-a'], :desc => 'List all versions available (remote only)'
212
+ method_option :prerelease, :type => :boolean, :default => false, :aliases => ['--pre'], :desc => 'List prerelease versions available (remote only)'
213
+ method_option :development, :type => :boolean, :default => false,
214
+ :aliases => ['--dev'], :desc => 'List development dependencies instead of runtime (local only)'
212
215
  def list(*packages)
213
- remote = BPM::Remote.new
214
- index = remote.list_packages(packages, options[:all], options[:prerelease])
215
- print_specs(packages, index)
216
+ if options[:remote]
217
+ remote = BPM::Remote.new
218
+ index = remote.list_packages(packages, options[:all], options[:prerelease])
219
+ print_specs(packages, index)
220
+ else
221
+ packages = nil if packages.size == 0
222
+ project = find_project
223
+ project.verify_and_repair
224
+
225
+ deps = options[:development] ? project.sorted_development_deps : project.sorted_runtime_deps
226
+ deps.each do |dep|
227
+ next if packages && !packages.include?(dep.name)
228
+ say "#{dep.name} (#{dep.version})"
229
+ end
230
+ end
216
231
  end
217
232
 
218
233
  desc "init [PATHS]", "Configure a project to use bpm for management"
@@ -325,7 +340,7 @@ module BPM
325
340
  end
326
341
 
327
342
  # make sure the project app status matches
328
- project = BPM::Project.new(path, name)
343
+ project = BPM::Project.new path
329
344
 
330
345
  if project.build_app? != !!include_app
331
346
  project.build_app = include_app
@@ -349,7 +364,7 @@ module BPM
349
364
  def find_project
350
365
  if options[:project]
351
366
  project_path = File.expand_path options[:project]
352
- if BPM::Project.is_project_root? project_path
367
+ if !BPM::Project.is_project_root?(project_path)
353
368
  abort "#{project_path} does not appear to be managed by bpm"
354
369
  else
355
370
  project = BPM::Project.new project_path
data/lib/bpm/package.rb CHANGED
@@ -19,6 +19,7 @@ module BPM
19
19
  "author" => :string,
20
20
  "homepage" => :string,
21
21
  "summary" => :string,
22
+ "url" => :string,
22
23
  "dependencies" => :hash,
23
24
  "dependencies:development" => :hash,
24
25
  "bpm:build" => :hash,
@@ -31,12 +32,12 @@ module BPM
31
32
  PLUGIN_FIELDS = %w[bpm:formats bpm:minifier bpm:transport bpm:use:transport]
32
33
 
33
34
  # Fields that can be loaded straight into the gemspec
34
- SPEC_FIELDS = %w[name email homepage summary description]
35
+ SPEC_FIELDS = %w[name email]
35
36
 
36
37
  # Fields that should be bundled up into JSON in the gemspec
37
38
  METADATA_FIELDS = %w[keywords licenses engines main bin directories pipeline bpm:build bpm:formats bpm:transport]
38
39
 
39
- REQUIRED_FIELDS = %w[name description summary homepage author version directories]
40
+ REQUIRED_FIELDS = %w[name author version]
40
41
 
41
42
  attr_accessor *FIELDS.keys.map{|f| f.gsub(':', '_') }
42
43
 
@@ -74,6 +75,10 @@ module BPM
74
75
  spec.licenses = licenses.map{|l| l["type"]}
75
76
  spec.executables = bin_files.map{|p| File.basename(p) } if bin_path
76
77
 
78
+ spec.homepage = homepage || url
79
+ spec.description = description || summary
80
+ spec.summary = summary || description
81
+
77
82
  metadata = Hash[METADATA_FIELDS.map{|f| [f, send(c2u(f)) ] }]
78
83
  spec.requirements = [metadata.to_json]
79
84
 
@@ -136,7 +141,6 @@ module BPM
136
141
  build_names += PLUGIN_FIELDS.map do |field_name|
137
142
  val = self.send(c2u(field_name))
138
143
  val = val && val =~ /^#{name}\// ? val[name.size+1..-1]+'.js' : nil
139
- puts "FIELD: #{field_name} #{self.send(c2u(field_name))} val=#{val}"
140
144
  val
141
145
  end
142
146
 
@@ -191,7 +195,7 @@ module BPM
191
195
  # Returns a hash of dependencies inferred from the build settings.
192
196
  def dependencies_build
193
197
  ret = {}
194
-
198
+
195
199
  bpm_build.each do |target_name, opts|
196
200
  next unless opts.is_a?(Hash)
197
201
 
@@ -221,7 +225,7 @@ module BPM
221
225
  end
222
226
 
223
227
  def validate
224
- validate_fields && validate_version && validate_paths
228
+ validate_fields && validate_version && validate_paths && validate_summary && validate_homepage
225
229
  end
226
230
 
227
231
  def valid?
@@ -390,6 +394,14 @@ module BPM
390
394
  end
391
395
  end
392
396
 
397
+ def validate_summary
398
+ summary || description
399
+ end
400
+
401
+ def validate_homepage
402
+ homepage || url
403
+ end
404
+
393
405
  def add_error(message)
394
406
  self.errors << message
395
407
  end
data/lib/bpm/project.rb CHANGED
@@ -44,10 +44,12 @@ module BPM
44
44
  # If no name, try to find project json and get name from it
45
45
  project_file = self.class.project_file_path(root_path)
46
46
  name = File.basename(project_file, '.json') if project_file
47
+ else
48
+ project_file = File.join root_path, "#{name}.json"
47
49
  end
48
50
 
49
51
  @name = name || File.basename(root_path)
50
- @json_path = File.join(root_path, "#{@name}.json")
52
+ @json_path = project_file
51
53
 
52
54
  load_json && validate
53
55
  end
@@ -78,6 +80,10 @@ module BPM
78
80
  File.join([@root_path, 'packages', package_name].compact)
79
81
  end
80
82
 
83
+ def vendor_root(*paths)
84
+ File.join @root_path, 'vendor', *paths
85
+ end
86
+
81
87
  def internal_package_root(package_name=nil)
82
88
  File.join([@root_path, BPM_DIR, 'packages', package_name].compact)
83
89
  end
@@ -91,31 +97,33 @@ module BPM
91
97
  end
92
98
 
93
99
  def build_app?
94
- !!(bpm_build && bpm_build["#{name}/bpm_libs.js"])
100
+ !!(bpm_build && bpm_build["bpm_libs.js"] &&
101
+ bpm_build["bpm_libs.js"]["directories"] &&
102
+ bpm_build["bpm_libs.js"]["directories"].size>0)
95
103
  end
96
104
 
97
105
  def build_app=(value)
98
106
 
99
- bpm_libs = "#{name}/bpm_libs.js"
100
- bpm_styles = "#{name}/bpm_styles.css"
107
+ bpm_libs = "bpm_libs.js"
108
+ bpm_styles = "bpm_styles.css"
101
109
 
102
110
  if value
103
- if bpm_build[bpm_libs].nil?
104
- bpm_build[bpm_libs] = {
105
- "directories" => ["app"],
106
- "minifier" => "uglify-js"
107
- }
108
- end
111
+ bpm_build[bpm_libs] ||= {}
112
+ hash = bpm_build[bpm_libs]
113
+ hash['directories'] ||= []
114
+ hash['directories'] << 'lib' if hash['directories'].size==0
115
+ hash['minifier'] ||= 'uglify-js'
109
116
 
110
- if bpm_build[bpm_styles].nil?
111
- bpm_build[bpm_styles] = {
112
- "directories" => ["css"]
113
- }
114
- end
115
-
117
+ bpm_build[bpm_styles] ||= {}
118
+ hash = bpm_build[bpm_styles]
119
+ hash['directories'] ||= []
120
+ hash['directories'] << 'css' if hash['directories'].size==0
121
+
122
+ directories ||= {}
123
+ directories['lib'] ||= ['app']
116
124
  else
117
- bpm_build.delete bpm_libs
118
- bpm_build.delete bpm_styles
125
+ bpm_build[bpm_libs]['directories'] = []
126
+ bpm_build[bpm_styles]['directories'] = []
119
127
  end
120
128
  value
121
129
  end
@@ -135,9 +143,9 @@ module BPM
135
143
  end
136
144
 
137
145
  def rebuild_preview(verbose=false)
138
-
146
+
139
147
  needs_rebuild = true
140
-
148
+
141
149
  if File.directory?(preview_root)
142
150
  cur_previews = Dir[preview_root('**', '*')].sort.reject { |x| File.directory?(x) }
143
151
  exp_filenames = buildable_asset_filenames(:debug)
@@ -159,22 +167,22 @@ module BPM
159
167
  # Add a new dependency
160
168
  #
161
169
  # Adds to the project json and installs dependency
162
-
170
+
163
171
  def add_dependencies(new_deps, development=false, verbose=false)
164
172
  old_deps = build_local_dependency_list(false) || []
165
173
  hard_deps = (development ? dependencies_development : dependencies).merge(new_deps)
166
174
  all_hard_deps = all_dependencies.merge(new_deps)
167
- exp_deps = find_non_local_dependencies(hard_deps, true)
168
-
175
+ exp_deps = find_non_local_dependencies(all_hard_deps, true)
176
+
169
177
  puts "Fetching packages from remote..." if verbose
170
178
  core_fetch_dependencies(exp_deps, verbose)
171
-
179
+
172
180
  if development
173
181
  self.dependencies_development = hard_deps
174
182
  else
175
183
  self.dependencies = hard_deps
176
184
  end
177
-
185
+
178
186
  rebuild_dependency_list(all_hard_deps, verbose)
179
187
 
180
188
  local_deps.each do |dep|
@@ -263,7 +271,7 @@ module BPM
263
271
  $stdout << "~ Building #{asset.logical_path}..." if verbose
264
272
  File.open(dst_path, 'w+') { |fd| fd << asset.to_s }
265
273
  if verbose
266
- gzip_size = `gzip -c #{dst_path}`.size
274
+ gzip_size = `gzip -c #{dst_path}`.bytesize
267
275
  gzip_size = gzip_size < 1024 ? "#{gzip_size} bytes" : "#{gzip_size / 1024} Kb"
268
276
  $stdout << " (gzipped size: #{gzip_size})\n"
269
277
  end
@@ -506,8 +514,8 @@ module BPM
506
514
  next if seen.include?(name)
507
515
  seen << name
508
516
 
509
- package_root = local_package_root(name)
510
- if File.exists?(package_root)
517
+ package_root = locate_local_package(name)
518
+ if package_root
511
519
  pkg = BPM::Package.new(package_root)
512
520
  pkg.load_json
513
521
 
@@ -590,7 +598,7 @@ module BPM
590
598
  # Tell if package is vendored
591
599
 
592
600
  def has_local_package?(package_name)
593
- File.directory?(local_package_root(package_name))
601
+ !!locate_local_package(package_name)
594
602
  end
595
603
 
596
604
 
@@ -640,6 +648,16 @@ module BPM
640
648
  end
641
649
 
642
650
 
651
+ def locate_local_package(package_name)
652
+ src_path = local_package_root package_name
653
+ unless File.directory?(src_path)
654
+ src_path = Dir[vendor_root('*','packages','*')].find do |path|
655
+ File.basename(path)==package_name && File.directory?(path)
656
+ end
657
+ end
658
+ src_path
659
+ end
660
+
643
661
  # Find package locally or in global cache
644
662
 
645
663
  def locate_package(package_name, vers, verbose)
@@ -649,9 +667,8 @@ module BPM
649
667
  # previous one we had didn't do anything, so it's better to have
650
668
  # none than one that doesn't work
651
669
  vers = ">= 0" if vers == ">= 0-pre"
652
- src_path = local ?
653
- local_package_root(package_name) :
654
- BPM::Local.new.source_root(package_name, vers)
670
+ src_path = local ? locate_local_package(package_name) :
671
+ BPM::Local.new.source_root(package_name, vers)
655
672
 
656
673
  return nil unless src_path
657
674
 
data/lib/bpm/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module BPM
2
- VERSION = "1.0.0.beta.4"
2
+ VERSION = "1.0.0.beta.5"
3
3
  COMPAT_VERSION = '1.0.0'
4
4
  end
data/spec/cli/add_spec.rb CHANGED
@@ -127,7 +127,7 @@ describe 'bpm add' do
127
127
  end
128
128
 
129
129
  it "should make a soft dependency a hard dependency" do
130
- bpm 'compile'
130
+ bpm 'rebuild'
131
131
  wait
132
132
  has_soft_dependency 'ivory', '0.0.1' # precond
133
133
 
@@ -154,8 +154,6 @@ describe 'bpm add' do
154
154
  no_dependency 'custom_package'
155
155
  end
156
156
 
157
- it "should verify working with config-less projects"
158
-
159
157
  it "should work with .bpkg file" do
160
158
  FileUtils.cp fixtures('gems', "custom_generator-1.0.bpkg"), '.'
161
159
  bpm "add", "custom_generator-1.0.bpkg" and wait
@@ -171,7 +169,7 @@ describe 'bpm add' do
171
169
  output = stdout.read
172
170
  output.should include("Added development package 'custom_generator' (1.0)")
173
171
 
174
- bpm 'compile', '--mode=debug' and wait
172
+ bpm 'rebuild', '--mode=debug' and wait
175
173
  has_development_dependency 'custom_generator', '1.0'
176
174
  no_dependency 'custom_generator', false
177
175
  end
@@ -179,3 +177,23 @@ describe 'bpm add' do
179
177
  end
180
178
 
181
179
  end
180
+
181
+ describe "bpm add using a vendor directory" do
182
+ before do
183
+ goto_home
184
+ set_host
185
+ start_fake(FakeGemServer.new)
186
+ FileUtils.cp_r project_fixture('hello_dev'), '.'
187
+ FileUtils.mkdir_p home('hello_dev', 'vendor')
188
+ FileUtils.cp_r project_fixture('hello_world'), home('hello_dev', 'vendor', 'hello_world')
189
+ cd home('hello_dev')
190
+ end
191
+
192
+ it "should include custom_package defined in a project found vendor" do
193
+ bpm 'add', 'custom_package' and wait
194
+
195
+ File.read(home('hello_dev', 'assets', 'bpm_libs.js')).should include("custom_package (2.0.0)")
196
+ end
197
+
198
+ end
199
+
@@ -19,7 +19,6 @@ describe 'bpm fetch' do
19
19
 
20
20
  bpm "fetch", '--verbose'
21
21
  out = stdout.read
22
- puts out
23
22
  out.should include("Fetched dependent packages for hello_world")
24
23
 
25
24
  # note: ivory is a soft dependency from core-test
@@ -29,14 +29,32 @@ describe "bpm init on existing directory" do
29
29
  end
30
30
 
31
31
  it "should not overwrite existing project file" do
32
- File.open("new_project.json", 'w'){|f| f.print "Valuable info!" }
33
-
34
- bpm 'init', '--skip' # skip, since we can't test the prompt
32
+
33
+ dummy_project = {
34
+ "name" => "custom_project",
35
+ "bpm" => "1.0.0"
36
+ }
37
+
38
+ File.open("new_project.json", 'w'){|f| f.print dummy_project.to_json }
35
39
 
36
- output = stdout.read.gsub(/\e\[\d+m/,'') # without colors
40
+ bpm 'init', '--skip' and wait # skip, since we can't test the prompt
41
+ File.read("new_project.json").should == dummy_project.to_json
42
+ end
43
+
44
+ it "should not overwrite existing project file (with different name)" do
45
+
46
+ dummy_project = {
47
+ "name" => "custom_project",
48
+ "bpm" => "1.0.0"
49
+ }
50
+
51
+ File.open("package.json", 'w'){|f| f.print dummy_project.to_json }
37
52
 
38
- output.should =~ /skip\s+new_project.json/
39
- File.read("new_project.json").should == "Valuable info!"
53
+ bpm 'init' and wait
54
+ exit_status.should be_success
55
+
56
+ File.read("package.json").should == dummy_project.to_json
57
+ File.exists?('new_project.json').should_not be_true
40
58
  end
41
59
 
42
60
  it "should update the project with app but save other settings" do
@@ -50,9 +68,6 @@ describe "bpm init on existing directory" do
50
68
 
51
69
  bpm 'init', '--app' and wait
52
70
 
53
- app_package = home 'new_project', 'assets', 'new_project', 'bpm_libs.js'
54
- File.exists?(app_package).should be_true
55
-
56
71
  json = JSON.load File.read(project_json)
57
72
  json["custom_property"].should == "I haz it"
58
73
  json["bpm:build"]["bpm_libs.js"].should_not be_nil
@@ -104,7 +119,7 @@ describe "bpm init on a non-existant directory" do
104
119
 
105
120
 
106
121
  files = %w(LICENSE README.md index.html app/main.js BpmTest.json)
107
- generated_files = %w(assets/bpm_libs.js assets/bpm_styles.css assets/BpmTest/bpm_libs.js assets/BpmTest/bpm_styles.css)
122
+ generated_files = %w(assets/bpm_libs.js assets/bpm_styles.css)
108
123
 
109
124
  # output without coloration
110
125
  output = stdout.read.gsub(/\e\[\d+m/,'')