ruber 0.0.8 → 0.0.9
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/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/hint_solver_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require './spec/common'
|
2
|
-
require 'ruber/
|
2
|
+
require 'ruber/world/hint_solver'
|
3
3
|
require 'ruber/editor/document'
|
4
4
|
require 'ruber/pane'
|
5
5
|
|
6
|
-
describe Ruber::
|
6
|
+
describe Ruber::World::HintSolver do
|
7
7
|
|
8
8
|
class HintSolverSpecComponentManager < Qt::Object
|
9
9
|
extend Forwardable
|
@@ -29,7 +29,7 @@ describe Ruber::MainWindow::HintSolver do
|
|
29
29
|
|
30
30
|
it 'takes the tab widget as argument' do
|
31
31
|
tabs = KDE::TabWidget.new
|
32
|
-
lambda{Ruber::
|
32
|
+
lambda{Ruber::World::HintSolver.new tabs, KParts::PartManager.new(@main_window), []}.should_not raise_error
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -38,7 +38,7 @@ describe Ruber::MainWindow::HintSolver do
|
|
38
38
|
|
39
39
|
before do
|
40
40
|
@tabs = KDE::TabWidget.new
|
41
|
-
@solver = Ruber::
|
41
|
+
@solver = Ruber::World::HintSolver.new @tabs, KParts::PartManager.new(@main_window), []
|
42
42
|
@doc = Ruber::Document.new nil
|
43
43
|
end
|
44
44
|
|
@@ -332,7 +332,7 @@ describe Ruber::MainWindow::HintSolver do
|
|
332
332
|
|
333
333
|
before do
|
334
334
|
@tabs = KDE::TabWidget.new
|
335
|
-
@solver = Ruber::
|
335
|
+
@solver = Ruber::World::HintSolver.new @tabs, KParts::PartManager.new(@main_window), []
|
336
336
|
@doc = Ruber::Document.new nil
|
337
337
|
end
|
338
338
|
|
data/spec/kde_sugar_spec.rb
CHANGED
@@ -93,6 +93,22 @@ describe 'KDE::Url' do
|
|
93
93
|
|
94
94
|
end
|
95
95
|
|
96
|
+
describe '#eql?' do
|
97
|
+
it 'returns true if the two URLs are equal according to ==' do
|
98
|
+
u1, u2 = 2.times.map{KDE::Url.new 'file:///xyz'}
|
99
|
+
u1.should eql(u2)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#hash' do
|
104
|
+
|
105
|
+
it 'returns the hash value of the path' do
|
106
|
+
u = KDE::Url.new 'file://xyz'
|
107
|
+
u.hash.should == u.path.hash
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
96
112
|
end
|
97
113
|
|
98
114
|
describe 'KDE::MimeType#=~' do
|
data/spec/output_widget_spec.rb
CHANGED
@@ -1089,36 +1089,165 @@ describe Ruber::OutputWidget do
|
|
1089
1089
|
@mod.append_row Qt::StandardItem.new('')
|
1090
1090
|
end
|
1091
1091
|
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1092
|
+
context 'when the argument is a Qt::ModelIndex' do
|
1093
|
+
|
1094
|
+
it 'calls #find_filename_in_string passing the text associated with the index as argument' do
|
1095
|
+
@mod.item(0,0).text = __FILE__
|
1096
|
+
flexmock(@ow).should_receive(:find_filename_in_string).with __FILE__
|
1097
|
+
@ow.send :find_filename_in_index, @mod.index(0,0)
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
context 'when the argument is a string' do
|
1103
|
+
|
1104
|
+
it 'calls #find_filename_in_string passing the string as argument' do
|
1105
|
+
@mod.item(0,0).text = __FILE__
|
1106
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with __FILE__
|
1107
|
+
@ow.send :find_filename_in_index, __FILE__
|
1108
|
+
end
|
1109
|
+
|
1096
1110
|
end
|
1097
1111
|
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1112
|
+
context 'when #find_filename_in_string returns nil' do
|
1113
|
+
|
1114
|
+
it 'returns nil' do
|
1115
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return nil
|
1116
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should be_nil
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
end
|
1120
|
+
|
1121
|
+
context 'when #find_filename_in_string returns a string' do
|
1122
|
+
|
1123
|
+
it 'returns an array with the string as first argument and 0 as second argument' do
|
1124
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return __FILE__
|
1125
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1126
|
+
end
|
1127
|
+
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
context 'when #find_filename_in_string returns an array with one element' do
|
1131
|
+
|
1132
|
+
it 'returns the array after appending a 0 to it' do
|
1133
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [__FILE__]
|
1134
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
context 'when #find_filename_in_string returns an array with two elements' do
|
1140
|
+
|
1141
|
+
it 'returns the array' do
|
1142
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [__FILE__, 6]
|
1143
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
|
1144
|
+
end
|
1145
|
+
|
1102
1146
|
end
|
1103
1147
|
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1148
|
+
context 'when the string or first element of the array returned by #find_filename_in_string is an absolute path' do
|
1149
|
+
|
1150
|
+
it 'transforms it in a canonical path' do
|
1151
|
+
path_parts = __FILE__.split('/')
|
1152
|
+
orig_path = path_parts[0..-2].join('/') + '/../' + path_parts[-2..-1].join('/')
|
1153
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return [orig_path, 0]
|
1154
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1155
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return orig_path
|
1156
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1157
|
+
end
|
1158
|
+
|
1107
1159
|
end
|
1108
1160
|
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1161
|
+
context 'when the string or first element of the array returned by #find_filename_in_string is a relative path' do
|
1162
|
+
|
1163
|
+
it 'transforms it into an absolute filename relative to the working directory' do
|
1164
|
+
@ow.working_dir = File.dirname __FILE__
|
1165
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [File.basename(__FILE__), 6]
|
1166
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [File.basename(__FILE__)]
|
1167
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return File.basename(__FILE__)
|
1168
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
|
1169
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1170
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
it 'transforms it in a canonical path' do
|
1174
|
+
@ow.working_dir = File.dirname File.dirname(__FILE__)
|
1175
|
+
path_parts = __FILE__.split('/')
|
1176
|
+
orig_path = "spec/../spec/#{File.basename(__FILE__)}"
|
1177
|
+
|
1178
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [orig_path, 6]
|
1179
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [orig_path]
|
1180
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return orig_path
|
1181
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
|
1182
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1183
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1184
|
+
end
|
1185
|
+
|
1112
1186
|
end
|
1113
1187
|
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1188
|
+
context 'when the string or first element of the array returned by #find_filename_in_string is an URL with the file scheme' do
|
1189
|
+
|
1190
|
+
context 'if the name of the file is an absolute path' do
|
1191
|
+
|
1192
|
+
it 'returns the path corresponding to the URL as first element of the array' do
|
1193
|
+
url = 'file://' + __FILE__
|
1194
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return [url, 0]
|
1195
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1196
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return url
|
1197
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
it 'transforms it in a canonical path' do
|
1201
|
+
path_parts = __FILE__.split('/')
|
1202
|
+
url = 'file://' + path_parts[0..-2].join('/') + '/../' + path_parts[-2..-1].join('/')
|
1203
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return [url, 0]
|
1204
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1205
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.and_return url
|
1206
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1207
|
+
end
|
1208
|
+
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
context 'if the name of the file is a relative path' do
|
1212
|
+
|
1213
|
+
it 'transforms it into an absolute filename relative to the working directory' do
|
1214
|
+
@ow.working_dir = File.dirname __FILE__
|
1215
|
+
url = 'file://' + File.basename(__FILE__)
|
1216
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url, 6]
|
1217
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url]
|
1218
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return url
|
1219
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
|
1220
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1221
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
it 'transforms it in a canonical path' do
|
1225
|
+
@ow.working_dir = File.dirname File.dirname(__FILE__)
|
1226
|
+
url = "file://spec/../spec/#{File.basename(__FILE__)}"
|
1227
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url, 6]
|
1228
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url]
|
1229
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return url
|
1230
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
|
1231
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1232
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
end
|
1236
|
+
|
1117
1237
|
end
|
1118
1238
|
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1239
|
+
context 'when the string or first element of the array returned by #find_filename_in_string is an URL with a scheme different from file' do
|
1240
|
+
|
1241
|
+
it 'returns the URL as it is as the first element of the array' do
|
1242
|
+
url = 'http://xyz/abc.it'
|
1243
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url, 6]
|
1244
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url]
|
1245
|
+
flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return url
|
1246
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [url, 6]
|
1247
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [url, 0]
|
1248
|
+
@ow.send(:find_filename_in_index, @mod.index(0,0)).should == [url, 0]
|
1249
|
+
end
|
1250
|
+
|
1122
1251
|
end
|
1123
1252
|
|
1124
1253
|
it 'removes the first filename from the index text before passing it to find_filename_in_string if the index corresponds to the title and the @skip_first_file_in_title instance variable is true' do
|
@@ -1425,37 +1554,6 @@ describe Ruber::OutputWidget::Model do
|
|
1425
1554
|
|
1426
1555
|
end
|
1427
1556
|
|
1428
|
-
describe '#flags' do
|
1429
|
-
|
1430
|
-
before do
|
1431
|
-
@mod = @ow.model
|
1432
|
-
end
|
1433
|
-
|
1434
|
-
it 'returns the value specified in the @flags variable if the index is valid and the global_flags attribute is not nil' do
|
1435
|
-
flags = Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
|
1436
|
-
@mod.global_flags = flags
|
1437
|
-
@mod.append_row Qt::StandardItem.new('x')
|
1438
|
-
@mod.flags(@mod.index(0,0)).should == flags.to_i
|
1439
|
-
end
|
1440
|
-
|
1441
|
-
it 'returns Qt::NoItemFlags if the inxed is not valid and the global_flags attribute is not nil' do
|
1442
|
-
flags = Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
|
1443
|
-
@mod.global_flags = flags
|
1444
|
-
@mod.append_row Qt::StandardItem.new('x')
|
1445
|
-
@mod.flags(Qt::ModelIndex.new).should == Qt::NoItemFlags.to_i
|
1446
|
-
end
|
1447
|
-
|
1448
|
-
it 'calls super if the global_flags attribute is nil' do
|
1449
|
-
@mod.global_flags = nil
|
1450
|
-
it = Qt::StandardItem.new('x')
|
1451
|
-
flags = Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsDragEnabled
|
1452
|
-
it.flags = flags
|
1453
|
-
@mod.append_row it
|
1454
|
-
@mod.flags(it.index).to_i.should == flags.to_i
|
1455
|
-
@mod.flags(Qt::ModelIndex.new).to_i.should == Qt::ItemIsDropEnabled.to_i
|
1456
|
-
end
|
1457
|
-
|
1458
|
-
end
|
1459
1557
|
|
1460
1558
|
describe '#set' do
|
1461
1559
|
|
@@ -1495,6 +1593,19 @@ describe Ruber::OutputWidget::Model do
|
|
1495
1593
|
@mod.set 'Test', :message, 2, :col => 4, :parent => @mod.item(0,0)
|
1496
1594
|
end
|
1497
1595
|
|
1596
|
+
it 'sets the flags of the new item to the value returned by #global_flags' do
|
1597
|
+
flags = Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
|
1598
|
+
@mod.global_flags = flags
|
1599
|
+
it = @mod.set 'test', :message, 0
|
1600
|
+
it.flags.should == flags
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
it 'leaves the default flags for the item if #global_flags returns nil' do
|
1604
|
+
@mod.global_flags = nil
|
1605
|
+
it = @mod.set 'test', :message, 0
|
1606
|
+
it.flags.should == Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled
|
1607
|
+
end
|
1608
|
+
|
1498
1609
|
it 'calls the set_output_type method of the output widget passing it the index of the item and the type argument' do
|
1499
1610
|
5.times{|i| @mod.append_row Qt::StandardItem.new(i.to_s)}
|
1500
1611
|
flexmock(@ow).should_receive(:set_output_type).once.with(FlexMock.on{|i| i.is_a?(Qt::ModelIndex) and i.row == 3 and i.column == 5}, :message)
|
@@ -1665,6 +1776,21 @@ describe '#insert' do
|
|
1665
1776
|
lambda{@mod.insert 'x', :message, -15}.should raise_error(IndexError, "Row index -10 is out of range. The allowed values are from 0 to 5")
|
1666
1777
|
end
|
1667
1778
|
|
1779
|
+
it 'sets the flags of the new item to the value returned by #global_flags' do
|
1780
|
+
flags = Qt::ItemIsEnabled | Qt::ItemIsUserCheckable
|
1781
|
+
@mod.global_flags = flags
|
1782
|
+
row = @mod.insert ['x', 'y'], :message, 0
|
1783
|
+
row.each{|it| it.flags.should == flags}
|
1784
|
+
end
|
1785
|
+
|
1786
|
+
it 'leaves the default flags for the item if #global_flags returns nil' do
|
1787
|
+
@mod.global_flags = nil
|
1788
|
+
flags = Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled
|
1789
|
+
row = @mod.insert ['x', 'y'], :message, 0
|
1790
|
+
row.each{|it| it.flags.should == flags}
|
1791
|
+
end
|
1792
|
+
|
1793
|
+
|
1668
1794
|
end
|
1669
1795
|
|
1670
1796
|
describe '#insert_lines' do
|
data/spec/pane_spec.rb
CHANGED
@@ -114,18 +114,35 @@ describe Ruber::Pane do
|
|
114
114
|
|
115
115
|
describe '#view' do
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
117
|
+
context 'if the pane is in single view' do
|
118
|
+
|
119
|
+
before do
|
120
|
+
@view = @doc.create_view(nil)
|
121
|
+
@pane = Ruber::Pane.new @view
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'returns the view if the pane contains a single view' do
|
125
|
+
@pane.view.should == @view
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'returns nil if the view has been closed' do
|
129
|
+
@view.close
|
130
|
+
@pane.view.should be_nil
|
131
|
+
end
|
132
|
+
|
121
133
|
end
|
122
134
|
|
135
|
+
|
123
136
|
it 'returns nil if the pane contains multiple panes' do
|
124
137
|
views = 2.times.map{@doc.create_view(nil)}
|
125
138
|
pane = Ruber::Pane.new Qt::Vertical, views[0], views[1]
|
126
139
|
pane.view.should be_nil
|
127
140
|
end
|
128
141
|
|
142
|
+
it 'returns nil if the only view has been removed' do
|
143
|
+
|
144
|
+
end
|
145
|
+
|
129
146
|
end
|
130
147
|
|
131
148
|
describe '#split' do
|
@@ -690,6 +707,13 @@ describe Ruber::Pane do
|
|
690
707
|
res.should == [@views[0]]
|
691
708
|
end
|
692
709
|
|
710
|
+
it 'does nothing if the pane is in single view and the only view has been closed' do
|
711
|
+
res = []
|
712
|
+
@views[0].close
|
713
|
+
@pane.each_view{|v| res << v}
|
714
|
+
res.should == []
|
715
|
+
end
|
716
|
+
|
693
717
|
it 'returns self' do
|
694
718
|
@pane.each_view{}.should == @pane
|
695
719
|
@pane.split @views[0], @views[1], Qt::Vertical
|
@@ -713,7 +737,7 @@ describe Ruber::Pane do
|
|
713
737
|
res_single.should == [@views[0]]
|
714
738
|
res_multi.should == [@views[0], @views[1], @views[3], @views[2]]
|
715
739
|
end
|
716
|
-
|
740
|
+
|
717
741
|
end
|
718
742
|
|
719
743
|
describe '#parent_pane' do
|
data/spec/plugin_spec.rb
CHANGED
@@ -1071,7 +1071,7 @@ describe 'Ruber::Plugin#update_project' do
|
|
1071
1071
|
@plug = Ruber::Plugin.new Ruber::PluginSpecification.full(@data)
|
1072
1072
|
@prj = Ruber::Project.new 'test.ruprj', 'Test'
|
1073
1073
|
@plug.register_with_project @prj
|
1074
|
-
@doc = Ruber::Document.new
|
1074
|
+
@doc = Ruber::Document.new __FILE__
|
1075
1075
|
end
|
1076
1076
|
|
1077
1077
|
it 'calls remove_options_from_project passing false as second argument' do
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec/framework'
|
2
|
+
require './spec/common'
|
3
|
+
require 'ruber/world/project_factory'
|
4
|
+
|
5
|
+
require 'tempfile'
|
6
|
+
require 'tmpdir'
|
7
|
+
|
8
|
+
describe Ruber::World::ProjectFactory do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@factory = Ruber::World::ProjectFactory.new
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#project' do
|
15
|
+
|
16
|
+
context 'when called with a file name as argument' do
|
17
|
+
|
18
|
+
before do
|
19
|
+
@file = Tempfile.new ['project_factory_test', '.ruprj']
|
20
|
+
@file.write YAML.dump({:general => {:project_name => 'project_factory_test'}})
|
21
|
+
@file.flush
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
@file.close!
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a new project associated with the file if no other project is associated with it' do
|
29
|
+
prj = @factory.project @file.path
|
30
|
+
prj.should be_a(Ruber::Project)
|
31
|
+
prj.project_file.should == @file.path
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns an existing project associated with the same file, if that project exists' do
|
35
|
+
old = @factory.project @file.path
|
36
|
+
new = @factory.project @file.path
|
37
|
+
new.should == old
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'emits the project_created signal passing the project as argument if a new project was created' do
|
41
|
+
prj = Ruber::Project.new @file.path
|
42
|
+
flexmock(Ruber::Project).should_receive(:new).with(@file.path, nil).once.and_return prj
|
43
|
+
mk = flexmock{|m| m.should_receive(:test).once.with(prj)}
|
44
|
+
@factory.connect(SIGNAL('project_created(QObject*)')){|pr| mk.test pr}
|
45
|
+
@factory.project @file.path
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'doesn\'t return an existing project which has been closed' do
|
49
|
+
old = @factory.project @file.path
|
50
|
+
old.close
|
51
|
+
new = @factory.project @file.path
|
52
|
+
new.should_not == old
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when called with a file name and a project name as arguments' do
|
60
|
+
|
61
|
+
it 'returns a new project associated with the file if no other project is associated with it' do
|
62
|
+
file = File.join Dir.tmpdir, 'project_factory_test.ruprj'
|
63
|
+
prj = @factory.project file, 'project_factory_test'
|
64
|
+
prj.should be_a(Ruber::Project)
|
65
|
+
prj.project_file.should == file
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns the existing project associated with the file if there is such a project and the name of the project is equal to the second argument' do
|
69
|
+
file = File.join Dir.tmpdir, 'project_factory_test.ruprj'
|
70
|
+
old = @factory.project file, 'project_factory_test'
|
71
|
+
prj = @factory.project file, 'project_factory_test'
|
72
|
+
prj.should == old
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'emits the project_created signal passing the project as argument if a new project was created' do
|
76
|
+
name = 'project_factory_test'
|
77
|
+
file = File.join Dir.tmpdir, 'project_factory_test.ruprj'
|
78
|
+
prj = Ruber::Project.new file, name
|
79
|
+
flexmock(Ruber::Project).should_receive(:new).once.with(file, name).and_return prj
|
80
|
+
mk = flexmock{|m| m.should_receive(:test).once.with(prj)}
|
81
|
+
@factory.connect(SIGNAL('project_created(QObject*)')){|pr| mk.test pr}
|
82
|
+
@factory.project file, name
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'raises ProjectFactory::MismatchingNameError if there\'s a project associated with the same file but the project name is different from the second argument' do
|
86
|
+
file = File.join Dir.tmpdir, 'project_factory_test.ruprj'
|
87
|
+
old_name = 'project_factory_test'
|
88
|
+
old = @factory.project file, old_name
|
89
|
+
new_name = 'project_factory_test_other_name'
|
90
|
+
lambda{@factory.project file, new_name}.should raise_error(Ruber::World::ProjectFactory::MismatchingNameError, "A project associated with #{file} exists, but the corresponding project name is #{old_name} instead of #{new_name}")
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'doesn\'t return an existing project which has been closed' do
|
94
|
+
file = File.join Dir.tmpdir, 'project_factory_test.ruprj'
|
95
|
+
old = @factory.project file, 'project_factory_test'
|
96
|
+
old.close false
|
97
|
+
new = @factory.project file, 'project_factory_test'
|
98
|
+
new.should_not == old
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|