ruber 0.0.5 → 0.0.7

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.
Files changed (83) hide show
  1. data/CHANGES +25 -0
  2. data/bin/ruber +0 -0
  3. data/data/share/apps/ruber/ruberui.rc +15 -1
  4. data/data/share/icons/{ruber.png → ruber-old.pgn} +0 -0
  5. data/lib/ruber/application/application.rb +216 -73
  6. data/lib/ruber/application/plugin.yaml +2 -2
  7. data/lib/ruber/document_project.rb +25 -5
  8. data/lib/ruber/documents/document_list.rb +11 -15
  9. data/lib/ruber/editor/document.rb +106 -50
  10. data/lib/ruber/editor/editor_view.rb +4 -2
  11. data/lib/ruber/external_program_plugin.rb +8 -0
  12. data/lib/ruber/kde_config_option_backend.rb +12 -4
  13. data/lib/ruber/kde_sugar.rb +35 -1
  14. data/lib/ruber/main_window/choose_plugins_dlg.rb +10 -10
  15. data/lib/ruber/main_window/hint_solver.rb +263 -0
  16. data/lib/ruber/main_window/main_window.rb +462 -206
  17. data/lib/ruber/main_window/main_window_actions.rb +228 -62
  18. data/lib/ruber/main_window/main_window_internal.rb +169 -115
  19. data/lib/ruber/main_window/plugin.yaml +13 -3
  20. data/lib/ruber/main_window/save_modified_files_dlg.rb +1 -1
  21. data/lib/ruber/main_window/ui/choose_plugins_widget.rb +1 -1
  22. data/lib/ruber/main_window/ui/main_window_settings_widget.rb +1 -1
  23. data/lib/ruber/main_window/ui/new_project_widget.rb +1 -1
  24. data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +1 -1
  25. data/lib/ruber/main_window/ui/output_color_widget.rb +1 -1
  26. data/lib/ruber/main_window/ui/workspace_settings_widget.rb +51 -0
  27. data/lib/ruber/main_window/ui/workspace_settings_widget.ui +28 -0
  28. data/lib/ruber/main_window/view_manager.rb +418 -0
  29. data/lib/ruber/main_window/workspace.png +0 -0
  30. data/lib/ruber/output_widget.rb +43 -37
  31. data/lib/ruber/pane.rb +621 -0
  32. data/lib/ruber/plugin_specification_reader.rb +8 -1
  33. data/lib/ruber/projects/project_files_list.rb +6 -0
  34. data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +1 -1
  35. data/lib/ruber/projects/ui/project_files_widget.rb +1 -1
  36. data/lib/ruber/qt_sugar.rb +94 -4
  37. data/lib/ruber/utils.rb +16 -7
  38. data/lib/ruber/version.rb +2 -2
  39. data/plugins/autosave/autosave.rb +62 -1
  40. data/plugins/autosave/plugin.yaml +1 -0
  41. data/plugins/autosave/ui/autosave_config_widget.rb +37 -14
  42. data/plugins/autosave/ui/autosave_config_widget.ui +62 -12
  43. data/plugins/find_in_files/find_in_files_widgets.rb +1 -3
  44. data/plugins/find_in_files/ui/config_widget.rb +1 -1
  45. data/plugins/find_in_files/ui/find_in_files_widget.rb +1 -1
  46. data/plugins/rake/plugin.yaml +1 -1
  47. data/plugins/rake/ui/add_quick_task_widget.rb +1 -1
  48. data/plugins/rake/ui/choose_task_widget.rb +1 -1
  49. data/plugins/rake/ui/config_widget.rb +1 -1
  50. data/plugins/rake/ui/project_widget.rb +1 -1
  51. data/plugins/rspec/rspec.rb +14 -22
  52. data/plugins/rspec/ruber_rspec_formatter.rb +4 -1
  53. data/plugins/rspec/ui/rspec_project_widget.rb +1 -1
  54. data/plugins/ruby_development/plugin.yaml +7 -2
  55. data/plugins/ruby_development/ruby_development.rb +134 -13
  56. data/plugins/ruby_development/ui/config_widget.rb +66 -0
  57. data/plugins/ruby_development/ui/config_widget.ui +58 -0
  58. data/plugins/ruby_development/ui/project_widget.rb +1 -1
  59. data/plugins/ruby_runner/plugin.yaml +2 -2
  60. data/plugins/ruby_runner/ruby_runner.rb +15 -3
  61. data/plugins/ruby_runner/ui/config_widget.rb +1 -1
  62. data/plugins/ruby_runner/ui/project_widget.rb +1 -1
  63. data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +1 -1
  64. data/plugins/state/plugin.yaml +6 -2
  65. data/plugins/state/state.rb +305 -81
  66. data/plugins/state/ui/config_widget.rb +1 -1
  67. data/spec/common.rb +11 -3
  68. data/spec/document_list_spec.rb +8 -8
  69. data/spec/document_project_spec.rb +98 -25
  70. data/spec/document_spec.rb +178 -152
  71. data/spec/editor_view_spec.rb +26 -5
  72. data/spec/framework.rb +5 -0
  73. data/spec/hint_solver_spec.rb +450 -0
  74. data/spec/kde_sugar_spec.rb +73 -6
  75. data/spec/output_widget_spec.rb +172 -156
  76. data/spec/pane_spec.rb +1165 -0
  77. data/spec/plugin_specification_reader_spec.rb +37 -1
  78. data/spec/project_files_list_spec.rb +30 -20
  79. data/spec/qt_sugar_spec.rb +269 -0
  80. data/spec/state_spec.rb +566 -353
  81. data/spec/utils_spec.rb +1 -1
  82. data/spec/view_manager_spec.rb +71 -0
  83. metadata +16 -4
@@ -4,26 +4,93 @@ require 'ruber/kde_sugar'
4
4
 
5
5
  describe 'KDE::Url' do
6
6
 
7
- it 'should be serializable using YAML' do
7
+ it 'is serializable using YAML' do
8
8
  u = KDE::Url.new 'http:///xyz.org/a%20file%20with%20spaces.txt'
9
9
  res = YAML.load(YAML.dump(u))
10
10
  res.should == u
11
11
  res.should_not equal(u)
12
12
  end
13
13
 
14
- it 'should be marshallable' do
14
+ it 'is marshallable' do
15
15
  u = KDE::Url.new 'http:///xyz.org/a%20file%20with%20spaces.txt'
16
16
  res = Marshal.load(Marshal.dump(u))
17
17
  res.should == u
18
18
  res.should_not equal(u)
19
19
  end
20
20
 
21
+ describe '.file_url?' do
22
+
23
+ it 'returns false if the first argument doesn\'t start with a scheme followed by //' do
24
+ KDE::Url.file_url?('http:xyz/abc', true).should be_false
25
+ KDE::Url.file_url?('http:xyz/abc', false).should be_false
26
+ KDE::Url.file_url?('http:/xyz/abc', true).should be_false
27
+ KDE::Url.file_url?('http:/xyz/abc', false).should be_false
28
+ end
29
+
30
+ context 'when the second argument is true' do
31
+
32
+ it 'returns true if the first argument looks like an absolute URL with authority' do
33
+ KDE::Url.file_url?('http:///xyz/abc', true).should be_true
34
+ end
35
+
36
+ it 'returns false if the path isn\'t absolute' do
37
+ KDE::Url.file_url?('http://xyz/abc', true).should be_false
38
+ end
39
+
40
+ end
41
+
42
+ context 'when the second argument is false or missing' do
43
+
44
+ it 'returns true if the first argument looks like an absolute URL with authority' do
45
+ KDE::Url.file_url?('http:///xyz/abc', false).should be_true
46
+ KDE::Url.file_url?('http:///xyz/abc').should be_true
47
+ end
48
+
49
+ it 'returns true if the first argument looks like a relative URL with authority' do
50
+ KDE::Url.file_url?('http://xyz/abc', false).should be_true
51
+ KDE::Url.file_url?('http://xyz/abc').should be_true
52
+ end
53
+
54
+
55
+ end
56
+
57
+ end
58
+
21
59
  describe '#local_file?' do
22
- it "calls is_local_file" do
23
- u = KDE::Url.new 'http://www.kde.org'
24
- flexmock(u).should_receive(:is_local_file).once
25
- u.local_file?
60
+
61
+ it 'returns true for urls with file: scheme representing absolute paths' do
62
+ KDE::Url.new('file:///xyz').should be_local_file
26
63
  end
64
+
65
+ it 'returns true for urls with file: scheme representing relative paths' do
66
+ KDE::Url.new('file://xyz').should be_local_file
67
+ end
68
+
69
+ it 'returns false for urls without scheme' do
70
+ KDE::Url.new('xyz').should_not be_local_file
71
+ end
72
+
73
+ it 'returns false for urls whose scheme is different from file:' do
74
+ KDE::Url.new('http://xyz').should_not be_local_file
75
+ end
76
+
77
+ end
78
+
79
+ describe '#remote_file?' do
80
+
81
+ it 'returns false if the url has file: scheme' do
82
+ KDE::Url.new('file:///xyz').should_not be_remote_file
83
+ KDE::Url.new('file://xyz').should_not be_remote_file
84
+ end
85
+
86
+ it 'returns false if the url has no scheme' do
87
+ KDE::Url.new('xyz').should_not be_remote_file
88
+ end
89
+
90
+ it 'returns true for urls whose scheme is different from file:' do
91
+ KDE::Url.new('http://yxz').should be_remote_file
92
+ end
93
+
27
94
  end
28
95
 
29
96
  end
@@ -1,4 +1,4 @@
1
- require 'spec/common'
1
+ require './spec/common'
2
2
  require 'ruber/output_widget'
3
3
 
4
4
  describe Ruber::OutputWidget::ActionList do
@@ -1039,25 +1039,33 @@ describe Ruber::OutputWidget do
1039
1039
  @ow.send :find_filename_in_index, @mod.index(0,0)
1040
1040
  end
1041
1041
 
1042
- describe ', when the string or the first element of the array returned by find_filename_in_string is not an absolute path' do
1042
+ describe ', when the string or the first element of the array returned by find_filename_in_string is not an absolute path and not an url' do
1043
1043
 
1044
1044
  it 'considers the path relative to the working_dir and transforms it into an absolute path' do
1045
1045
  @ow.working_dir = File.dirname(__FILE__)
1046
1046
  flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [File.basename(__FILE__), 6]
1047
1047
  flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [File.basename(__FILE__)]
1048
1048
  flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return File.basename(__FILE__)
1049
+ url = 'http:///xyz/abc.rb'
1050
+ flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return [url]
1049
1051
  @ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 6]
1050
1052
  @ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
1051
1053
  @ow.send(:find_filename_in_index, @mod.index(0,0)).should == [__FILE__, 0]
1054
+ @ow.send(:find_filename_in_index, @mod.index(0,0)).should == [url, 0]
1052
1055
  end
1053
1056
 
1054
1057
  end
1055
1058
 
1056
- it 'returns nil if the file doesn\'t exist' do
1059
+ it 'returns nil if the file is a local file which doesn\'t exist' do
1057
1060
  flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return '/' + random_string
1058
1061
  @ow.send(:find_filename_in_index, @mod.index(0,0)).should be_nil
1059
1062
  end
1060
1063
 
1064
+ it 'returns the pair [url, line] even if the url doesn\'t exist when it represents a remote file' do
1065
+ flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return ['http://xyz/abc', 12]
1066
+ @ow.send(:find_filename_in_index, @mod.index(0,0)).should == ['http://xyz/abc', 12]
1067
+ end
1068
+
1061
1069
  it 'returns nil if the file is a directory' do
1062
1070
  flexmock(@ow).should_receive(:find_filename_in_string).once.with('').and_return File.dirname(__FILE__)
1063
1071
  @ow.send(:find_filename_in_index, @mod.index(0,0)).should be_nil
@@ -1067,159 +1075,167 @@ describe Ruber::OutputWidget do
1067
1075
 
1068
1076
  describe '#find_filename_in_string' do
1069
1077
 
1078
+ module FindFilenameInStringMacros
1079
+
1080
+ def recognizes_file file, line = nil, exp_file = file, &blk
1081
+
1082
+ it "recognizes the file when it is the whole line" do
1083
+ instance_eval &blk if blk
1084
+ str = line ? "#{file}:#{line}" : file
1085
+ res = @ow.send :find_filename_in_string, str
1086
+ res.should == (line ? [exp_file, line] : [exp_file])
1087
+ end
1088
+
1089
+ it 'recognizes the file at the end of the line' do
1090
+ instance_eval &blk if blk
1091
+ str = "#{random_string 5} #{line ? "#{file}:#{line}" : file }"
1092
+ res = @ow.send :find_filename_in_string, str
1093
+ res.should == (line ? [exp_file, line] : [exp_file])
1094
+ end
1095
+
1096
+ it 'recognizes the file at the beginning of the line' do
1097
+ instance_eval &blk if blk
1098
+ str = "#{line ? "#{file}:#{line}" : file } #{random_string 5}"
1099
+ res = @ow.send :find_filename_in_string, str
1100
+ res.should == (line ? [exp_file, line] : [exp_file])
1101
+ end
1102
+
1103
+ it 'recognizes the file in the middle of the line' do
1104
+ instance_eval &blk if blk
1105
+ str = "#{random_string 5} #{line ? "#{file}:#{line}" : file } #{random_string 5}"
1106
+ res = @ow.send :find_filename_in_string, str
1107
+ res.should == (line ? [exp_file, line] : [exp_file])
1108
+ end
1109
+
1110
+ it 'recognizes the file when it\'s quoted' do
1111
+ instance_eval &blk if blk
1112
+ str = "#{random_string 5} <#{line ? "#{file}:#{line}" : file }> #{random_string 5}"
1113
+ res = @ow.send :find_filename_in_string, str
1114
+ res.should == (line ? [exp_file, line] : [exp_file])
1115
+ end
1116
+
1117
+ end
1118
+
1119
+ def does_not_recognize_file cond, file, line = nil
1120
+
1121
+ it "doesn't recognize the file if #{cond}" do
1122
+ str = line ? "#{file}:#{line}" : file
1123
+ res = @ow.send :find_filename_in_string, str
1124
+ res.should be_nil
1125
+ end
1126
+
1127
+ end
1128
+
1129
+ end
1130
+
1070
1131
  before do
1071
1132
  @ow = Ruber::OutputWidget.new
1072
1133
  end
1073
1134
 
1074
- it 'recognizes an absolute path without line numbers' do
1075
- str = random_string( 1 + rand(10))+ " #{__FILE__} " + random_string(1 + rand(10))
1076
- res = @ow.send :find_filename_in_string, str
1077
- res[0].should == __FILE__
1078
- str = random_string( 1 + rand(10))+ " #{__FILE__}"
1079
- res = @ow.send :find_filename_in_string, str
1080
- res[0].should == __FILE__
1081
- str = "#{__FILE__} " + random_string( 1 + rand(10))
1082
- res = @ow.send :find_filename_in_string, str
1083
- res[0].should == __FILE__
1084
- end
1085
-
1086
- it 'recognizes and expands an absolute path starting with ~/ without line numbers' do
1087
- file = '/test/yxz.rb'
1088
- exp = File.join ENV['HOME'], file
1089
- str = random_string( 1 + rand(10))+ " ~#{file} " + random_string(1 + rand(10))
1090
- res = @ow.send :find_filename_in_string, str
1091
- res[0].should == exp
1092
- str = random_string( 1 + rand(10))+ " ~#{file}"
1093
- res = @ow.send :find_filename_in_string, str
1094
- res[0].should == exp
1095
- str = "~#{file} " + random_string( 1 + rand(10))
1096
- res = @ow.send :find_filename_in_string, str
1097
- res[0].should == exp
1098
- end
1099
-
1100
- it 'recognizes and expands an absolute path starting with ~user/ without line numbers' do
1101
- file = '/test/yxz.rb'
1102
- exp = File.join ENV['HOME'], file
1103
- str = random_string( 1 + rand(10))+ " ~#{ENV['USER']}#{file} " + random_string(1 + rand(10))
1104
- res = @ow.send :find_filename_in_string, str
1105
- res[0].should == exp
1106
- str = random_string( 1 + rand(10))+ " ~#{ENV['USER']}#{file}"
1107
- res = @ow.send :find_filename_in_string, str
1108
- res[0].should == exp
1109
- str = "~#{ENV['USER']}#{file} " + random_string( 1 + rand(10))
1110
- res = @ow.send :find_filename_in_string, str
1111
- res[0].should == exp
1112
- end
1113
-
1114
- it 'recognizes a relative path starting with a single dot and doesn\'t expand it' do
1115
- str = random_string( 1 + rand(10))+ " .#{__FILE__} " + random_string(1 + rand(10))
1116
- res = @ow.send :find_filename_in_string, str
1117
- res[0].should == '.' + __FILE__
1118
- str = random_string( 1 + rand(10))+ " .#{__FILE__}"
1119
- res = @ow.send :find_filename_in_string, str
1120
- res[0].should == '.' + __FILE__
1121
- str = ".#{__FILE__} " + random_string( 1 + rand(10))
1122
- res = @ow.send :find_filename_in_string, str
1123
- res[0].should == '.' + __FILE__
1124
- end
1125
-
1126
- it 'recognizes a relative path starting with two dots and doesn\'t expand it' do
1127
- str = random_string( 1 + rand(10))+ " ..#{__FILE__} " + random_string(1 + rand(10))
1128
- res = @ow.send :find_filename_in_string, str
1129
- res[0].should == '..' + __FILE__
1130
- str = random_string( 1 + rand(10))+ " ..#{__FILE__}"
1131
- res = @ow.send :find_filename_in_string, str
1132
- res[0].should == '..' + __FILE__
1133
- str = "..#{__FILE__} " + random_string( 1 + rand(10))
1134
- res = @ow.send :find_filename_in_string, str
1135
- res[0].should == '..' + __FILE__
1136
- end
1137
-
1138
- it 'recognizes a relative path not starting with a dot but containing slashes' do
1139
- file = "test/xyz"
1140
- str = random_string( 1 + rand(10))+ " #{file} " + random_string(1 + rand(10))
1141
- res = @ow.send :find_filename_in_string, str
1142
- res[0].should == file
1143
- str = random_string( 1 + rand(10))+ " #{file}"
1144
- res = @ow.send :find_filename_in_string, str
1145
- res[0].should == file
1146
- str = "#{file} " + random_string( 1 + rand(10))
1147
- res = @ow.send :find_filename_in_string, str
1148
- res[0].should == file
1149
- end
1150
-
1151
- it 'doesn\'t recognize sequences ending with a slash' do
1152
- strs = ["#{__FILE__}/", "~#{__FILE__}/", "~#{ENV['USER']}#{__FILE__}/", ".#{__FILE__}/", "..#{__FILE__}/"]
1153
- strs.map!{|s| random_string(rand(10)) + ' ' + s + ' ' + random_string(rand(10))}
1154
- strs.each{|s| res = @ow.send(:find_filename_in_string, s).should be_nil}
1155
- end
1156
-
1157
- it 'recognizes filenames ending in a colon followd by digits, which are interpreted as line numbers' do
1158
- strs = ["#{__FILE__}", "~#{__FILE__}", "~#{ENV['USER']}#{__FILE__}", ".#{__FILE__}", "..#{__FILE__}"]
1159
- strs.map!{|s| random_string(rand(10)) + ' ' + s + ":10#{rand > 0.5 ? ' ' : ''}" + random_string(rand(10))}
1160
- @ow.send(:find_filename_in_string, strs[0]).should == [__FILE__, 10]
1161
- @ow.send(:find_filename_in_string, strs[1]).should == [File.join(ENV['HOME'], __FILE__), 10]
1162
- @ow.send(:find_filename_in_string, strs[2]).should == [File.join(ENV['HOME'], __FILE__), 10]
1163
- @ow.send(:find_filename_in_string, strs[3]).should == ['.' + __FILE__, 10]
1164
- @ow.send(:find_filename_in_string, strs[4]).should == ['..' + __FILE__, 10]
1165
- end
1166
-
1167
- it 'recognizes any string not containing spaces and ending in a slash followed by a colon and digits, which are interpreted as line numbers' do
1168
- file = 'xyz'
1169
- str = random_string( 1 + rand(10))+ " #{file}:16 " + random_string(1 + rand(10))
1170
- res = @ow.send :find_filename_in_string, str
1171
- res.should == [file, 16]
1172
- str = random_string( 1 + rand(10))+ " #{file}:16"
1173
- res = @ow.send :find_filename_in_string, str
1174
- res.should == [file, 16]
1175
- str = "#{file}:16 " + random_string( 1 + rand(10))
1176
- res = @ow.send :find_filename_in_string, str
1177
- res.should == [file, 16]
1178
- #In the following tests, there's no space between the last digit and the following character
1179
- str = random_string( 1 + rand(10))+ " #{file}:16" + random_string(1 + rand(10))
1180
- res = @ow.send :find_filename_in_string, str
1181
- res.should == [file, 16]
1182
- str = "#{file}:16" + random_string( 1 + rand(10))
1183
- res = @ow.send :find_filename_in_string, str
1184
- res.should == [file, 16]
1185
- end
1186
-
1187
- it 'recognizes the file names enclosed in quotes, double quotes, backticks, all brackets and angular brackets' do
1188
- quotes = %w|' " ` ( [ { < |
1189
- quotes.each do |q|
1190
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "#{__FILE__}").should == [__FILE__]
1191
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "~#{__FILE__}").should == [File.join(ENV['HOME'], __FILE__)]
1192
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "~#{ENV['USER']}#{__FILE__}").should == [File.join(ENV['HOME'], __FILE__)]
1193
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + ".#{__FILE__}").should == [File.join('.', __FILE__)]
1194
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "..#{__FILE__}").should == [File.join('..', __FILE__)]
1195
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "abc/xyz").should == ['abc/xyz']
1196
- @ow.send(:find_filename_in_string, random_string( 1 + rand(10))+ ' ' + q + "abc:12").should == ['abc', 12]
1197
- end
1135
+ extend FindFilenameInStringMacros
1136
+
1137
+ context 'when the line contains an absolute path without line number' do
1138
+ recognizes_file '/abc/def/ghi.rb'
1139
+ end
1140
+
1141
+ context 'when the line contains an absolute path with line number' do
1142
+ recognizes_file '/abc/def/ghi.rb', 45
1198
1143
  end
1199
1144
 
1200
- it 'only considers the first match' do
1201
- str = "#{__FILE__.upcase} #{__FILE__}"
1202
- @ow.send(:find_filename_in_string, str).should == [__FILE__.upcase]
1145
+ context 'when the line contains an absolute path referring to the user\'s home directory without line numbers' do
1146
+ recognizes_file '~/abc/def/ghi.rb', nil, "#{ENV['HOME']}/abc/def/ghi.rb"
1147
+ end
1148
+
1149
+ context 'when the line contains an absolute path referring to the user\'s home directory with line numbers' do
1150
+ recognizes_file '~/abc/def/ghi.rb', 45, "#{ENV['HOME']}/abc/def/ghi.rb"
1203
1151
  end
1204
1152
 
1205
- end
1206
-
1207
- describe '#keyReleaseEvent' do
1153
+ context 'when the line contains an absolute path referring to another user\'s home directory and no line numbers' do
1154
+ prc = proc{flexmock(File).should_receive(:expand_path).with('~xyz/abc/def/ghi.rb').and_return('/home/xyz/abc/def/ghi.rb')}
1155
+ recognizes_file '~xyz/abc/def/ghi.rb', nil, "/home/xyz/abc/def/ghi.rb", &prc
1156
+ end
1157
+
1158
+ context 'when the line contains an absolute path referring to another user\'s home directory with line numbers' do
1159
+ prc = proc{flexmock(File).should_receive(:expand_path).with('~xyz/abc/def/ghi.rb').and_return('/home/xyz/abc/def/ghi.rb')}
1160
+ recognizes_file '~xyz/abc/def/ghi.rb', 45, "/home/xyz/abc/def/ghi.rb", &prc
1161
+ end
1208
1162
 
1209
- before do
1210
- @ow = Ruber::OutputWidget.new
1211
- @mw = flexmock('main window'){|m| m.should_ignore_missing}
1212
- @ev = Qt::KeyEvent.new Qt::Event::KeyRelease, Qt::Key_A, Qt::NoModifier, 'a'
1213
- flexmock(Ruber).should_receive(:[]).with(:main_window).and_return(@mw).by_default
1163
+ context 'when the line contains a filename starting with ./ and no line numbers' do
1164
+ recognizes_file './abc/def/ghi.rb'
1165
+ end
1166
+
1167
+ context 'when the line contains a filename starting with ./ and line numbers' do
1168
+ recognizes_file './abc/def/ghi.rb', 12
1169
+ end
1170
+
1171
+ context 'when the line contains a filename starting with ../ and no line numbers' do
1172
+ recognizes_file '../abc/def/ghi.rb'
1214
1173
  end
1215
1174
 
1216
- it 'gives focus to the current editor' do
1217
- ed = flexmock('editor'){|m| m.should_receive(:set_focus).once}
1218
- ed.should_ignore_missing
1219
- @mw.should_receive(:active_editor).once.and_return ed
1220
- @ow.send :keyReleaseEvent, @ev
1175
+ context 'when the line contains a filename starting with ../ and line numbers' do
1176
+ recognizes_file '../abc/def/ghi.rb', 12
1221
1177
  end
1222
1178
 
1179
+ context 'when the line contains a filename starting with a dot not followed by a slash and no numbers' do
1180
+ recognizes_file '.abc/def/ghi.rb'
1181
+ end
1182
+
1183
+ context 'when the line contains a filename starting with a dot not followed by a slash and line numbers' do
1184
+ recognizes_file '.abc/def/ghi.rb', 34
1185
+ end
1186
+
1187
+ context 'when the line contains a relative path not starting with ./ and containing slashes with no line numbers' do
1188
+ recognizes_file 'abc/def/ghi.rb'
1189
+ end
1190
+
1191
+ context 'when the line contains a relative path not starting with ./ and containing slashes with line numbers' do
1192
+ recognizes_file 'abc/def/ghi.rb', 29
1193
+ end
1194
+
1195
+ context 'when the line contains a relative filename without slash or leading dots with line numbers' do
1196
+ recognizes_file 'abc.rb', 132
1197
+ end
1198
+
1199
+ context 'when the line contains an URL representing a relative file with no line numbers' do
1200
+ recognizes_file 'http://abc/def/ghi.rb'
1201
+ end
1202
+
1203
+ context 'when the line contains an URL representing a relative file with line numbers' do
1204
+ recognizes_file 'http://abc/def/ghi.rb', 456
1205
+ end
1206
+
1207
+
1208
+ context 'when the line contains an absolute URL with no line numbers' do
1209
+ recognizes_file 'http:///abc/def/ghi.rb'
1210
+ end
1211
+
1212
+ context 'when the line contains an absolute URL with line numbers' do
1213
+ recognizes_file 'http:///abc/def/ghi.rb', 456
1214
+ end
1215
+
1216
+ it 'only considers the first match' do
1217
+ str = "#{__FILE__.upcase} #{__FILE__}"
1218
+ @ow.send(:find_filename_in_string, str).should == [__FILE__.upcase]
1219
+ end
1220
+
1221
+ end
1222
+
1223
+ # describe '#keyReleaseEvent' do
1224
+ #
1225
+ # before do
1226
+ # @ow = Ruber::OutputWidget.new
1227
+ # @mw = flexmock('main window'){|m| m.should_ignore_missing}
1228
+ # @ev = Qt::KeyEvent.new Qt::Event::KeyRelease, Qt::Key_A, Qt::NoModifier, 'a'
1229
+ # flexmock(Ruber).should_receive(:[]).with(:main_window).and_return(@mw).by_default
1230
+ # end
1231
+ #
1232
+ # it 'gives focus to the current editor' do
1233
+ # ed = flexmock('editor'){|m| m.should_receive(:set_focus).once}
1234
+ # ed.should_ignore_missing
1235
+ # @mw.should_receive(:active_editor).once.and_return ed
1236
+ # @ow.send :keyReleaseEvent, @ev
1237
+ # end
1238
+ #
1223
1239
  # it 'inserts the text corresponding to the released key in the editor' do
1224
1240
  # ed = flexmock('editor'){|m| m.should_receive(:insert_text).once.with('a')}
1225
1241
  # ed.should_ignore_missing
@@ -1227,21 +1243,21 @@ describe Ruber::OutputWidget do
1227
1243
  # @ow.send :keyReleaseEvent, @ev
1228
1244
  # end
1229
1245
 
1230
- it 'does nothing if there\'s no active editor' do
1231
- @mw.should_receive(:active_editor).once.and_return nil
1232
- lambda{@ow.send :keyReleaseEvent, @ev}.should_not raise_error
1233
- end
1234
-
1235
- it 'returns nil' do
1246
+ # it 'does nothing if there\'s no active editor' do
1247
+ # @mw.should_receive(:active_editor).once.and_return nil
1248
+ # lambda{@ow.send :keyReleaseEvent, @ev}.should_not raise_error
1249
+ # end
1250
+ #
1251
+ # it 'returns nil' do
1236
1252
  # ed = flexmock('editor'){|m| m.should_receive(:insert_text).once.with('a')}
1237
- ed = flexmock('editor'){|m| m.should_ignore_missing}
1238
- @mw.should_receive(:active_editor).once.and_return ed
1239
- @mw.should_receive(:active_editor).once.and_return nil
1240
- @ow.send(:keyReleaseEvent, @ev).should be_nil
1241
- @ow.send(:keyReleaseEvent, @ev).should be_nil
1242
- end
1253
+ # ed = flexmock('editor'){|m| m.should_ignore_missing}
1254
+ # @mw.should_receive(:active_editor).once.and_return ed
1255
+ # @mw.should_receive(:active_editor).once.and_return nil
1256
+ # @ow.send(:keyReleaseEvent, @ev).should be_nil
1257
+ # @ow.send(:keyReleaseEvent, @ev).should be_nil
1258
+ # end
1243
1259
 
1244
- end
1260
+ # end
1245
1261
 
1246
1262
  end
1247
1263