ruber 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +21 -0
- data/data/share/apps/ruber/ruberui.rc +3 -1
- data/lib/ruber/application/application.rb +22 -23
- data/lib/ruber/application/plugin.yaml +7 -2
- data/lib/ruber/{projects → application}/project_files_list.rb +0 -0
- data/lib/ruber/{projects → application}/project_files_widget.rb +0 -0
- data/lib/ruber/application/ui/project_files_rule_chooser_widget.rb +74 -0
- data/lib/ruber/{projects → application}/ui/project_files_rule_chooser_widget.ui +0 -0
- data/lib/ruber/application/ui/project_files_widget.rb +117 -0
- data/lib/ruber/{projects → application}/ui/project_files_widget.ui +0 -0
- data/lib/ruber/component_manager.rb +14 -9
- data/lib/ruber/editor/document.rb +35 -5
- data/lib/ruber/kde_sugar.rb +16 -0
- data/lib/ruber/main_window/choose_plugins_dlg.rb +7 -4
- data/lib/ruber/main_window/main_window.rb +131 -193
- data/lib/ruber/main_window/main_window_actions.rb +157 -58
- data/lib/ruber/main_window/main_window_internal.rb +145 -54
- data/lib/ruber/main_window/open_file_in_project_dlg.rb +4 -4
- data/lib/ruber/main_window/plugin.yaml +3 -6
- data/lib/ruber/main_window/ui/workspace_settings_widget.rb +2 -2
- data/lib/ruber/main_window/workspace.rb +62 -32
- data/lib/ruber/output_widget.rb +20 -16
- data/lib/ruber/pane.rb +11 -5
- data/lib/ruber/project.rb +27 -12
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
- data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
- data/lib/ruber/utils.rb +37 -4
- data/lib/ruber/version.rb +1 -1
- data/lib/ruber/world/document_factory.rb +121 -0
- data/lib/ruber/world/document_list.rb +396 -0
- data/lib/ruber/world/environment.rb +470 -0
- data/lib/ruber/{main_window → world}/hint_solver.rb +1 -1
- data/lib/ruber/world/plugin.yaml +11 -0
- data/lib/ruber/world/project_factory.rb +131 -0
- data/lib/ruber/world/project_list.rb +265 -0
- data/lib/ruber/world/ui/workspace_settings_widget.rb +51 -0
- data/lib/ruber/{main_window → world}/ui/workspace_settings_widget.ui +0 -0
- data/lib/ruber/world/world.rb +307 -0
- data/plugins/auto_end/auto_end.rb +135 -9
- data/plugins/autosave/autosave.rb +4 -4
- data/plugins/find_in_files/find_in_files.rb +5 -5
- data/plugins/find_in_files/find_in_files_widgets.rb +1 -1
- data/plugins/project_browser/project_browser.rb +4 -4
- data/plugins/rake/rake.rb +4 -4
- data/plugins/rake/rake_extension.rb +1 -1
- data/plugins/rspec/rspec.rb +4 -4
- data/plugins/rspec/ruber_rspec_formatter.rb +2 -2
- data/plugins/ruby_development/ruby_development.rb +3 -3
- data/plugins/ruby_runner/ruby_runner.rb +2 -2
- data/plugins/state/plugin.yaml +6 -8
- data/plugins/state/state.rb +201 -391
- data/plugins/state/ui/config_widget.rb +5 -5
- data/plugins/state/ui/config_widget.ui +3 -3
- data/plugins/syntax_checker/syntax_checker.rb +4 -0
- data/spec/annotation_model_spec.rb +1 -1
- data/spec/auto_end_spec.rb +98 -47
- data/spec/component_manager_spec.rb +80 -21
- data/spec/document_factory_spec.rb +115 -0
- data/spec/document_list_spec.rb +560 -450
- data/spec/document_spec.rb +143 -55
- data/spec/editor_view_spec.rb +2 -2
- data/spec/environment_spec.rb +1900 -0
- data/spec/hint_solver_spec.rb +5 -5
- data/spec/kde_sugar_spec.rb +16 -0
- data/spec/output_widget_spec.rb +177 -51
- data/spec/pane_spec.rb +29 -5
- data/spec/plugin_spec.rb +1 -1
- data/spec/project_factory_spec.rb +104 -0
- data/spec/project_list_spec.rb +352 -447
- data/spec/project_spec.rb +34 -33
- data/spec/qt_sugar_spec.rb +2 -2
- data/spec/state_spec.rb +508 -811
- data/spec/utils_spec.rb +149 -98
- data/spec/workspace_spec.rb +120 -9
- data/spec/world_spec.rb +1219 -0
- metadata +23 -14
- data/lib/ruber/documents/document_list.rb +0 -412
- data/lib/ruber/documents/plugin.yaml +0 -4
- data/lib/ruber/main_window/view_manager.rb +0 -431
- data/lib/ruber/projects/plugin.yaml +0 -11
- data/lib/ruber/projects/project_list.rb +0 -314
data/spec/document_spec.rb
CHANGED
@@ -25,12 +25,82 @@ describe Ruber::Document do
|
|
25
25
|
include FlexMock::ArgumentTypes
|
26
26
|
|
27
27
|
before do
|
28
|
+
|
28
29
|
@app = KDE::Application.instance
|
29
30
|
@w = Qt::Widget.new
|
30
31
|
@comp = DocumentSpecComponentManager.new
|
31
32
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return(@comp)
|
32
|
-
@doc = Ruber::Document.new @app
|
33
|
-
end
|
33
|
+
@doc = Ruber::Document.new nil, @app
|
34
|
+
end
|
35
|
+
|
36
|
+
# describe '.new' do
|
37
|
+
#
|
38
|
+
# context 'when called with a file name as first argument' do
|
39
|
+
#
|
40
|
+
# it 'returns a new document for the given file if no documents for it exist' do
|
41
|
+
# old = Ruber::Document.new __FILE__
|
42
|
+
# file = File.join( File.dirname(__FILE__), 'common.rb')
|
43
|
+
# new = Ruber::Document.new file
|
44
|
+
# new.should_not == old
|
45
|
+
# new.path.should == file
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# it 'returns the existing document for the given file instead of creating a new one, if a document for that file already exists' do
|
49
|
+
# old = Ruber::Document.new __FILE__
|
50
|
+
# new = Ruber::Document.new __FILE__
|
51
|
+
# urls = Ruber::Document.instance_variable_get(:@docs).keys
|
52
|
+
# new.should == old
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# it 'takes into account documents created without a file which have later been saved' do
|
56
|
+
# old = Ruber::Document.new
|
57
|
+
# url = KDE::Url.new(__FILE__)
|
58
|
+
# flexmock(old).should_receive(:url).and_return url
|
59
|
+
# old.instance_eval{emit document_url_changed(url)}
|
60
|
+
# new = Ruber::Document.new __FILE__
|
61
|
+
# new.should == old
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# it 'takes into account documents which have been saved with another name' do
|
65
|
+
# old = Ruber::Document.new File.join( File.dirname(__FILE__), 'common.rb')
|
66
|
+
# url = KDE::Url.new(__FILE__)
|
67
|
+
# flexmock(old).should_receive(:url).and_return url
|
68
|
+
# old.instance_eval{emit document_url_changed(url)}
|
69
|
+
# new = Ruber::Document.new __FILE__
|
70
|
+
# new.should == old
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# it 'doesn\'t return a document which has been closed' do
|
74
|
+
# old = Ruber::Document.new __FILE__
|
75
|
+
# old_id = old.object_id
|
76
|
+
# old.close
|
77
|
+
# new = Ruber::Document.new __FILE__
|
78
|
+
# new.object_id.should_not == old_id
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# it 'doesn\'t use documents whose URL have changed for the old url' do
|
82
|
+
# old = Ruber::Document.new __FILE__
|
83
|
+
# new_file = File.join( File.dirname(__FILE__), 'common.rb')
|
84
|
+
# url = KDE::Url.new(new_file)
|
85
|
+
# flexmock(old).should_receive(:url).and_return url
|
86
|
+
# old.instance_eval{emit document_url_changed(url)}
|
87
|
+
# new = Ruber::Document.new __FILE__
|
88
|
+
# new.should_not == old
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# context 'when called without a file name' do
|
94
|
+
#
|
95
|
+
# it 'always returns a new document' do
|
96
|
+
# old = [Ruber::Document.new(__FILE__), Ruber::Document.new]
|
97
|
+
# new = Ruber::Document.new
|
98
|
+
# old.each{|d| new.should_not == d}
|
99
|
+
# end
|
100
|
+
#
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# end
|
34
104
|
|
35
105
|
describe ', when created' do
|
36
106
|
|
@@ -47,27 +117,27 @@ describe Ruber::Document do
|
|
47
117
|
end
|
48
118
|
|
49
119
|
it 'opens a given file if new is called with a string or KDE::Url second argument' do
|
50
|
-
doc = Ruber::Document.new @app
|
120
|
+
doc = Ruber::Document.new __FILE__, @app
|
51
121
|
doc.text.should == File.read(__FILE__)
|
52
122
|
doc.url.path.should == __FILE__
|
53
|
-
doc = Ruber::Document.new
|
123
|
+
doc = Ruber::Document.new KDE::Url.from_path(__FILE__), @app
|
54
124
|
doc.text.should == File.read(__FILE__)
|
55
125
|
doc.url.path.should == __FILE__
|
56
126
|
end
|
57
127
|
|
58
128
|
it 'creates a document project for itself, after opening the file (if given)' do
|
59
|
-
doc = Ruber::Document.new @app
|
129
|
+
doc = Ruber::Document.new nil, @app
|
60
130
|
prj = doc.instance_variable_get(:@project)
|
61
131
|
prj.should be_a(Ruber::DocumentProject)
|
62
132
|
prj.project_name.should be_empty
|
63
|
-
doc = Ruber::Document.new @app
|
133
|
+
doc = Ruber::Document.new __FILE__, @app
|
64
134
|
prj = doc.instance_variable_get(:@project)
|
65
135
|
prj.should be_a(Ruber::DocumentProject)
|
66
136
|
prj.project_name.should == KDE::Url.new(__FILE__).to_encoded.to_s
|
67
137
|
end
|
68
138
|
|
69
139
|
it 'isn\'t active' do
|
70
|
-
doc = Ruber::Document.new @app
|
140
|
+
doc = Ruber::Document.new __FILE__, @app
|
71
141
|
doc.should_not be_active
|
72
142
|
end
|
73
143
|
|
@@ -78,12 +148,12 @@ describe Ruber::Document do
|
|
78
148
|
context 'when called with :local' do
|
79
149
|
|
80
150
|
it 'returns true if the document is associated with a local file' do
|
81
|
-
doc = Ruber::Document.new
|
151
|
+
doc = Ruber::Document.new __FILE__
|
82
152
|
doc.should have_file(:local)
|
83
153
|
end
|
84
154
|
|
85
155
|
it 'returns false if the document is associated with a remote file' do
|
86
|
-
doc = Ruber::Document.new
|
156
|
+
doc = Ruber::Document.new KDE::Url.new('http://github.com/stcrocco/ruber/raw/master/ruber.gemspec')
|
87
157
|
doc.should_not have_file(:local)
|
88
158
|
end
|
89
159
|
|
@@ -97,12 +167,12 @@ describe Ruber::Document do
|
|
97
167
|
context 'when called with :remote' do
|
98
168
|
|
99
169
|
it 'returns false if the document is associated with a local file' do
|
100
|
-
doc = Ruber::Document.new
|
170
|
+
doc = Ruber::Document.new __FILE__
|
101
171
|
doc.should_not have_file(:remote)
|
102
172
|
end
|
103
173
|
|
104
174
|
it 'returns true if the document is associated with a remote file' do
|
105
|
-
doc = Ruber::Document.new
|
175
|
+
doc = Ruber::Document.new KDE::Url.new('http://github.com/stcrocco/ruber/raw/master/ruber.gemspec')
|
106
176
|
doc.should have_file(:remote)
|
107
177
|
end
|
108
178
|
|
@@ -116,13 +186,13 @@ describe Ruber::Document do
|
|
116
186
|
context 'when called with :any or no arguments' do
|
117
187
|
|
118
188
|
it 'returns true if the document is associated with a local file' do
|
119
|
-
doc = Ruber::Document.new
|
189
|
+
doc = Ruber::Document.new __FILE__
|
120
190
|
doc.should have_file(:any)
|
121
191
|
doc.should have_file
|
122
192
|
end
|
123
193
|
|
124
194
|
it 'returns true if the document is associated with a remote file' do
|
125
|
-
doc = Ruber::Document.new
|
195
|
+
doc = Ruber::Document.new KDE::Url.new('http://github.com/stcrocco/ruber/raw/master/ruber.gemspec')
|
126
196
|
doc.should have_file(:any)
|
127
197
|
doc.should have_file
|
128
198
|
end
|
@@ -140,7 +210,7 @@ describe Ruber::Document do
|
|
140
210
|
describe '#own_project' do
|
141
211
|
|
142
212
|
it 'returns the DocumentProject associated with the document' do
|
143
|
-
doc = Ruber::Document.new @app
|
213
|
+
doc = Ruber::Document.new __FILE__, @app
|
144
214
|
doc.own_project.project_name.should == KDE::Url.new(__FILE__).url
|
145
215
|
end
|
146
216
|
|
@@ -151,9 +221,9 @@ describe Ruber::Document do
|
|
151
221
|
before do
|
152
222
|
@list = flexmock
|
153
223
|
@prj = flexmock(:project_files => @list)
|
154
|
-
@
|
155
|
-
flexmock(Ruber).should_receive(:[]).with(:
|
156
|
-
@doc = Ruber::Document.new @app
|
224
|
+
@world = flexmock{|m| m.should_receive(:active_project).and_return(@prj).by_default}
|
225
|
+
flexmock(Ruber).should_receive(:[]).with(:world).and_return(@world)
|
226
|
+
@doc = Ruber::Document.new __FILE__, @app
|
157
227
|
end
|
158
228
|
|
159
229
|
it 'returns the current project if one exists and the document belongs to it' do
|
@@ -167,12 +237,12 @@ describe Ruber::Document do
|
|
167
237
|
end
|
168
238
|
|
169
239
|
it 'returns the document project if the document isn\'t associated with a file' do
|
170
|
-
@doc = Ruber::Document.new @app
|
240
|
+
@doc = Ruber::Document.new nil, @app
|
171
241
|
@doc.project.should be_a(Ruber::DocumentProject)
|
172
242
|
end
|
173
243
|
|
174
244
|
it 'returns the document project if there isn\'t a project open' do
|
175
|
-
@
|
245
|
+
@world.should_receive(:active_project).and_return nil
|
176
246
|
@doc.project.should be_a(Ruber::DocumentProject)
|
177
247
|
end
|
178
248
|
|
@@ -193,7 +263,7 @@ describe Ruber::Document do
|
|
193
263
|
Tempfile.open('ruber_document_test') do |f|
|
194
264
|
f.write 'test'
|
195
265
|
f.flush
|
196
|
-
doc = Ruber::Document.new
|
266
|
+
doc = Ruber::Document.new f.path
|
197
267
|
flexmock(doc.send :internal).should_receive(:is_read_write).once.and_return false
|
198
268
|
flexmock(doc).should_receive(:document_save_as).once
|
199
269
|
doc.text += ' added'
|
@@ -205,7 +275,7 @@ describe Ruber::Document do
|
|
205
275
|
Tempfile.open('ruber_document_test') do |f|
|
206
276
|
f.write 'test'
|
207
277
|
f.flush
|
208
|
-
doc = Ruber::Document.new
|
278
|
+
doc = Ruber::Document.new f.path
|
209
279
|
flexmock(doc.own_project).should_receive(:save).once
|
210
280
|
doc.text += ' added'
|
211
281
|
doc.save
|
@@ -216,7 +286,7 @@ describe Ruber::Document do
|
|
216
286
|
Tempfile.open('ruber_document_test') do |f|
|
217
287
|
f.write 'test'
|
218
288
|
f.flush
|
219
|
-
doc = Ruber::Document.new
|
289
|
+
doc = Ruber::Document.new f.path
|
220
290
|
doc.text += ' added'
|
221
291
|
doc.save.should be_true
|
222
292
|
File.read( f.path ).should == 'test added'
|
@@ -251,14 +321,14 @@ describe Ruber::Document do
|
|
251
321
|
@doc.mime_type.should == 'application/x-ruby'
|
252
322
|
end
|
253
323
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
324
|
+
# it 'returns a list of the views associated with it' do
|
325
|
+
# @doc.views.should be_empty
|
326
|
+
# old_view = @doc.create_view nil
|
327
|
+
# @doc.views[0].should == old_view
|
328
|
+
# new_view = @doc.create_view nil
|
329
|
+
# @doc.views[1].should == new_view
|
330
|
+
# @doc.views.should == [old_view, new_view]
|
331
|
+
# end
|
262
332
|
|
263
333
|
it 'emits the "modified_changed(QObject*, bool)" signal when the modified status changes' do
|
264
334
|
m = flexmock
|
@@ -300,9 +370,10 @@ describe Ruber::Document do
|
|
300
370
|
@doc.should be_pristine
|
301
371
|
@doc.text = "a"
|
302
372
|
@doc.should_not be_pristine
|
303
|
-
|
373
|
+
# projects = flexmock(:current => nil)
|
304
374
|
config = flexmock{|m| m.should_receive(:[]).with(:general, :default_script_directory).and_return ENV['HOME']}
|
305
|
-
flexmock(
|
375
|
+
world = flexmock(:active_project => nil)
|
376
|
+
flexmock(Ruber).should_receive(:[]).with(:world).and_return(world)
|
306
377
|
flexmock(Ruber).should_receive(:[]).with(:config).and_return(config)
|
307
378
|
flexmock(Ruber).should_receive(:[]).with(:main_window).and_return(Qt::Widget.new)
|
308
379
|
Tempfile.open('ruber_document_test') do |f|
|
@@ -312,7 +383,7 @@ describe Ruber::Document do
|
|
312
383
|
@doc.save
|
313
384
|
@doc.should_not be_pristine
|
314
385
|
end
|
315
|
-
Ruber::Document.new(
|
386
|
+
Ruber::Document.new(__FILE__).should_not be_pristine
|
316
387
|
end
|
317
388
|
|
318
389
|
["text_changed(QObject*)", "about_to_close(QObject*)", 'about_to_close(QObject*)',
|
@@ -378,7 +449,7 @@ describe Ruber::Document do
|
|
378
449
|
end
|
379
450
|
|
380
451
|
it 'should return true when close_url succeeds' do
|
381
|
-
doc = Ruber::Document.new
|
452
|
+
doc = Ruber::Document.new __FILE__
|
382
453
|
doc.close_url(false).should be_true
|
383
454
|
end
|
384
455
|
|
@@ -405,12 +476,12 @@ describe 'Ruber::Document#close' do
|
|
405
476
|
@w = Qt::Widget.new
|
406
477
|
@comp = DocumentSpecComponentManager.new
|
407
478
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return(@comp)
|
408
|
-
@doc = Ruber::Document.new @app
|
479
|
+
@doc = Ruber::Document.new nil, @app
|
409
480
|
flexmock(@doc.instance_variable_get(:@project)).should_receive(:save).by_default
|
410
481
|
end
|
411
482
|
|
412
483
|
it 'returns immediately if ask is true and query_close returns false' do
|
413
|
-
doc = Ruber::Document.new
|
484
|
+
doc = Ruber::Document.new __FILE__
|
414
485
|
exp = doc.object_id
|
415
486
|
m = flexmock('test'){|mk| mk.should_receive(:document_closing).never}
|
416
487
|
doc.connect(SIGNAL('closing(QObject*)')){|d| m.document_closing d.object_id}
|
@@ -419,7 +490,7 @@ describe 'Ruber::Document#close' do
|
|
419
490
|
end
|
420
491
|
|
421
492
|
it 'calls the save method of the project after emitting the "closing" signal' do
|
422
|
-
@doc = Ruber::Document.new @app
|
493
|
+
@doc = Ruber::Document.new __FILE__, @app
|
423
494
|
m = flexmock{|mk| mk.should_receive(:document_closing).once.globally.ordered}
|
424
495
|
@doc.connect(SIGNAL('closing(QObject*)')){m.document_closing}
|
425
496
|
flexmock(@doc.instance_variable_get(:@project)).should_receive(:save).once.globally.ordered
|
@@ -432,23 +503,23 @@ describe 'Ruber::Document#close' do
|
|
432
503
|
end
|
433
504
|
|
434
505
|
it 'should call the "close_url", if closing is confirmed' do
|
435
|
-
doc = Ruber::Document.new
|
506
|
+
doc = Ruber::Document.new __FILE__
|
436
507
|
flexmock(doc).should_receive(:close_url).once.with(false)
|
437
508
|
doc.close
|
438
|
-
doc = Ruber::Document.new
|
509
|
+
doc = Ruber::Document.new __FILE__
|
439
510
|
flexmock(doc).should_receive(:close_url).once.with(false)
|
440
511
|
doc.close false
|
441
512
|
end
|
442
513
|
|
443
514
|
it 'should emit the "closing(QObject*)" signal if closing is confirmed' do
|
444
|
-
doc = Ruber::Document.new
|
515
|
+
doc = Ruber::Document.new __FILE__
|
445
516
|
exp = doc.object_id
|
446
517
|
m = flexmock('test'){|mk| mk.should_receive(:document_closing).once.with(exp)}
|
447
518
|
flexmock(doc).should_receive(:close_url).and_return true
|
448
519
|
doc.connect(SIGNAL('closing(QObject*)')){|d| m.document_closing d.object_id}
|
449
520
|
flexmock(doc).should_receive(:query_close).and_return true
|
450
521
|
doc.close
|
451
|
-
doc = Ruber::Document.new
|
522
|
+
doc = Ruber::Document.new __FILE__
|
452
523
|
exp1 = doc.object_id
|
453
524
|
m.should_receive(:document_closing).with(exp1).once
|
454
525
|
flexmock(doc).should_receive(:query_close)
|
@@ -457,7 +528,7 @@ describe 'Ruber::Document#close' do
|
|
457
528
|
end
|
458
529
|
|
459
530
|
it 'closes the views, if any, after emitting the closing signal, if closing is confirmed' do
|
460
|
-
doc = Ruber::Document.new
|
531
|
+
doc = Ruber::Document.new __FILE__
|
461
532
|
views = 3.times.map{doc.create_view}
|
462
533
|
exp = doc.object_id
|
463
534
|
m = flexmock('test'){|mk| mk.should_receive(:document_closing).once.with(exp).globally.ordered}
|
@@ -467,9 +538,9 @@ describe 'Ruber::Document#close' do
|
|
467
538
|
flexmock(doc).should_receive(:query_close).and_return true
|
468
539
|
doc.close false
|
469
540
|
end
|
470
|
-
|
541
|
+
|
471
542
|
it 'calls the #save method of the project if the document path is not empty' do
|
472
|
-
doc = Ruber::Document.new
|
543
|
+
doc = Ruber::Document.new __FILE__
|
473
544
|
exp = doc.object_id
|
474
545
|
flexmock(doc).should_receive(:close_url).and_return true
|
475
546
|
flexmock(doc.instance_variable_get(:@project)).should_receive(:save).once
|
@@ -494,7 +565,7 @@ end
|
|
494
565
|
|
495
566
|
|
496
567
|
it 'should disconnect any slot/block connected to it after emitting the closing signal if closing is confirmed' do
|
497
|
-
doc = Ruber::Document.new
|
568
|
+
doc = Ruber::Document.new __FILE__
|
498
569
|
exp = doc.object_id
|
499
570
|
flexmock(doc).should_receive(:close_url).and_return true
|
500
571
|
def doc.disconnect *args;end
|
@@ -505,16 +576,16 @@ end
|
|
505
576
|
end
|
506
577
|
|
507
578
|
# it 'should dispose of itself after emitting the closing signal, if closing is confirmed' do
|
508
|
-
# doc = Ruber::Document.new
|
579
|
+
# doc = Ruber::Document.new __FILE__
|
509
580
|
# doc.close false
|
510
581
|
# doc.should be_disposed
|
511
582
|
# end
|
512
583
|
|
513
584
|
it 'should return true, if closing is confirmed and successful and false otherwise' do
|
514
|
-
doc = Ruber::Document.new
|
585
|
+
doc = Ruber::Document.new __FILE__
|
515
586
|
flexmock(doc).should_receive(:close_url).once.and_return true
|
516
587
|
doc.close( false).should be_true
|
517
|
-
doc = Ruber::Document.new
|
588
|
+
doc = Ruber::Document.new __FILE__
|
518
589
|
flexmock(doc).should_receive(:close_url).once.and_return false
|
519
590
|
doc.close( false).should be_false
|
520
591
|
flexmock(doc).should_receive(:query_close).once.and_return false
|
@@ -529,7 +600,7 @@ describe 'Ruber::Document#extension' do
|
|
529
600
|
@app = KDE::Application.instance
|
530
601
|
@comp = DocumentSpecComponentManager.new
|
531
602
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return @comp
|
532
|
-
@doc = Ruber::Document.new @app
|
603
|
+
@doc = Ruber::Document.new nil, @app
|
533
604
|
end
|
534
605
|
|
535
606
|
it 'calls the extension method of its project' do
|
@@ -546,7 +617,7 @@ describe 'Ruber::Document#file_type_match?' do
|
|
546
617
|
@app = KDE::Application.instance
|
547
618
|
@comp = DocumentSpecComponentManager.new
|
548
619
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return( @comp).by_default
|
549
|
-
@doc = Ruber::Document.new @app
|
620
|
+
@doc = Ruber::Document.new __FILE__, @app
|
550
621
|
end
|
551
622
|
|
552
623
|
it 'should return true if both arguments are empty' do
|
@@ -583,7 +654,7 @@ describe 'Ruber::Document#file_type_match?' do
|
|
583
654
|
end
|
584
655
|
|
585
656
|
it 'should always return false when doing pattern matching if the document is not associated with a file' do
|
586
|
-
@doc = Ruber::Document.new @app
|
657
|
+
@doc = Ruber::Document.new nil, @app
|
587
658
|
@doc.file_type_match?([], %w[*.txt *.rb]).should be_false
|
588
659
|
end
|
589
660
|
|
@@ -615,8 +686,8 @@ describe 'Ruber::Document#document_save_as' do
|
|
615
686
|
flexmock(Ruber).should_receive(:[]).with(:main_window).and_return(@w).by_default
|
616
687
|
@comp = DocumentSpecComponentManager.new
|
617
688
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return(@comp).by_default
|
618
|
-
@
|
619
|
-
flexmock(Ruber).should_receive(:[]).with(:
|
689
|
+
@world = flexmock{|m| m.should_receive(:active_project).and_return(nil).by_default}
|
690
|
+
flexmock(Ruber).should_receive(:[]).with(:world).and_return(@world).by_default
|
620
691
|
@config = flexmock('config')
|
621
692
|
@config.should_receive(:[]).with(:general, :default_script_directory).and_return('/').by_default
|
622
693
|
flexmock(Ruber).should_receive(:[]).with(:config).and_return(@config).by_default
|
@@ -645,7 +716,7 @@ describe 'Ruber::Document#document_save_as' do
|
|
645
716
|
|
646
717
|
it 'uses the current project\'s project directory as default directory if there is a current project' do
|
647
718
|
prj = flexmock(:project_directory => File.dirname(__FILE__))
|
648
|
-
@
|
719
|
+
@world.should_receive(:active_project).once.and_return prj
|
649
720
|
res = OpenStruct.new(:file_names => ['/test.rb'], :encoding => 'UTF-16')
|
650
721
|
flexmock(KDE::EncodingFileDialog).should_receive(:get_save_file_name_and_encoding).once.with(String, File.dirname(__FILE__), String, Qt::Widget, String).and_return(res)
|
651
722
|
@doc.send :document_save_as
|
@@ -728,7 +799,7 @@ describe Ruber::Document do
|
|
728
799
|
describe '#save_settings' do
|
729
800
|
|
730
801
|
it 'calls the #save method of the project if the document path is not empty' do
|
731
|
-
doc = Ruber::Document.new
|
802
|
+
doc = Ruber::Document.new __FILE__
|
732
803
|
exp = doc.object_id
|
733
804
|
flexmock(doc.own_project).should_receive(:save).once
|
734
805
|
doc.save_settings
|
@@ -885,4 +956,21 @@ describe Ruber::Document do
|
|
885
956
|
|
886
957
|
end
|
887
958
|
|
959
|
+
describe '#views' do
|
960
|
+
|
961
|
+
before do
|
962
|
+
@doc = Ruber::Document.new
|
963
|
+
end
|
964
|
+
|
965
|
+
it 'returns a list of all the views associated with the document' do
|
966
|
+
views = 3.times.map{@doc.create_view}
|
967
|
+
@doc.views.should == views
|
968
|
+
end
|
969
|
+
|
970
|
+
it 'returns an empty list if there\'s no view associated with the document' do
|
971
|
+
@doc.views.should == []
|
972
|
+
end
|
973
|
+
|
974
|
+
end
|
975
|
+
|
888
976
|
end
|
data/spec/editor_view_spec.rb
CHANGED
@@ -68,7 +68,7 @@ describe Ruber::EditorView do
|
|
68
68
|
@comp = Qt::Object.new
|
69
69
|
flexmock(@comp).should_receive(:each_component)
|
70
70
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return @comp
|
71
|
-
@doc = Ruber::Document.new @app
|
71
|
+
@doc = Ruber::Document.new nil, @app
|
72
72
|
@view = @doc.create_view @w
|
73
73
|
end
|
74
74
|
|
@@ -200,7 +200,7 @@ describe 'Ruber::EditorView#execute_action' do
|
|
200
200
|
@comp = Qt::Object.new
|
201
201
|
flexmock(@comp).should_receive(:each_component)
|
202
202
|
flexmock(Ruber).should_receive(:[]).with(:components).and_return @comp
|
203
|
-
@doc = Ruber::Document.new @app
|
203
|
+
@doc = Ruber::Document.new nil, @app
|
204
204
|
@view = @doc.create_view @w
|
205
205
|
end
|
206
206
|
|