merrol 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/.autotest +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/LICENSE +23 -0
  5. data/README.md +58 -0
  6. data/ROADMAP.md +22 -0
  7. data/Rakefile +63 -0
  8. data/autotest/discover.rb +2 -0
  9. data/bin/m +9 -0
  10. data/config/commands.yml +150 -0
  11. data/config/language.yml +47 -0
  12. data/config/messages.yml +3 -0
  13. data/config/settings.yml +3 -0
  14. data/config/snippets/rails.yml +22 -0
  15. data/config/snippets/rspec.yml +35 -0
  16. data/config/snippets/ruby.yml +97 -0
  17. data/config/styles/Railscasts.xml +121 -0
  18. data/config/templates/rails.yml +21 -0
  19. data/config/templates/rspec.yml +6 -0
  20. data/data/images/merrol.svg +412 -0
  21. data/data/images/merrol2.svg +531 -0
  22. data/data/images/modified.svg +156 -0
  23. data/data/images/saved.svg +156 -0
  24. data/lib/merrol/controllers/controller.rb +26 -0
  25. data/lib/merrol/controllers/edit_controller.rb +24 -0
  26. data/lib/merrol/controllers/file_controller.rb +61 -0
  27. data/lib/merrol/controllers/help_controller.rb +6 -0
  28. data/lib/merrol/controllers/main_controller.rb +26 -0
  29. data/lib/merrol/controllers/search_controller.rb +5 -0
  30. data/lib/merrol/controllers/tools_controller.rb +28 -0
  31. data/lib/merrol/gtk/bin.rb +11 -0
  32. data/lib/merrol/gtk/image.rb +8 -0
  33. data/lib/merrol/gtk/list_view.rb +43 -0
  34. data/lib/merrol/gtk/source_view.rb +22 -0
  35. data/lib/merrol/gtk/widget.rb +12 -0
  36. data/lib/merrol/gtk/window.rb +18 -0
  37. data/lib/merrol/keyboard_map.rb +136 -0
  38. data/lib/merrol/lib/application.rb +29 -0
  39. data/lib/merrol/lib/commands.rb +40 -0
  40. data/lib/merrol/lib/file.rb +6 -0
  41. data/lib/merrol/lib/shortcut.rb +35 -0
  42. data/lib/merrol/lib/widget_builder.rb +49 -0
  43. data/lib/merrol/lib/yaml.rb +10 -0
  44. data/lib/merrol/models/source_model.rb +44 -0
  45. data/lib/merrol/views/edit.yml +50 -0
  46. data/lib/merrol/views/file_list.yml +11 -0
  47. data/lib/merrol/views/file_path.yml +8 -0
  48. data/lib/merrol/views/file_status.yml +6 -0
  49. data/lib/merrol/views/hbox.yml +6 -0
  50. data/lib/merrol/views/main.yml +9 -0
  51. data/lib/merrol/views/scroll_bars.yml +15 -0
  52. data/lib/merrol/views/status_bar.yml +7 -0
  53. data/lib/merrol.rb +16 -0
  54. data/lib/prerequisites.rb +54 -0
  55. data/merrol.gemspec +24 -0
  56. data/spec/controllers/controller_spec.rb +27 -0
  57. data/spec/controllers/edit_controller_spec.rb +38 -0
  58. data/spec/controllers/file_controller_spec.rb +209 -0
  59. data/spec/controllers/main_controller_spec.rb +20 -0
  60. data/spec/gtk/bin_spec.rb +13 -0
  61. data/spec/gtk/list_view_spec.rb +114 -0
  62. data/spec/gtk/source_view_spec.rb +41 -0
  63. data/spec/gtk/widget_spec.rb +37 -0
  64. data/spec/gtk/window_spec.rb +28 -0
  65. data/spec/integration/000_startup_spec.rb +14 -0
  66. data/spec/integration/001_load_from_commandline_spec.rb +25 -0
  67. data/spec/integration/002_loading_and_saving_spec.rb +35 -0
  68. data/spec/integration/003_tab_file_switching_spec.rb +49 -0
  69. data/spec/integration/ideas_spec.rb +23 -0
  70. data/spec/integration_helper.rb +11 -0
  71. data/spec/lib/application_spec.rb +57 -0
  72. data/spec/lib/commands_spec.rb +63 -0
  73. data/spec/lib/file_spec.rb +9 -0
  74. data/spec/lib/shortcut_spec.rb +59 -0
  75. data/spec/lib/widget_builder_spec.rb +77 -0
  76. data/spec/lib/yaml_spec.rb +26 -0
  77. data/spec/models/source_model_spec.rb +80 -0
  78. data/spec/spec_helper.rb +18 -0
  79. data/spec/support/actions.rb +28 -0
  80. data/spec/support/expectations.rb +46 -0
  81. data/spec/support/setup.rb +32 -0
  82. metadata +224 -0
@@ -0,0 +1,209 @@
1
+ require 'spec_helper'
2
+
3
+ describe FileController do
4
+ before(:each) do
5
+ @mock_commands = mock Commands, :register => nil
6
+ @mock_main = mock Gtk::Window
7
+ @mock_image = mock Gtk::Image
8
+ @mock_list = mock Gtk::ListView, :selected_to_top => nil, :prepend => nil, :empty? => false, :hide => nil
9
+ @mock_theme = mock Gtk::SourceStyleScheme
10
+ @mock_edit = mock(Gtk::SourceView, :theme => @mock_theme, :highlight_brackets => true)
11
+ @mock_views = {
12
+ :main => @mock_main,
13
+ :edit => @mock_edit,
14
+ :file_status => @mock_image,
15
+ :file_list => @mock_list
16
+ }
17
+ @mock_source_model = mock_source_model
18
+ SourceModel.stub!(:new).and_return @mock_source_model
19
+ @mock_main.stub :signal_handler_disconnect
20
+ @mock_edit.stub :scroll_to_cursor
21
+ @mock_edit.stub!(:buffer=)
22
+ end
23
+
24
+ class Gdk::EventKey
25
+ def inspect
26
+ modifiers = (state.control_mask? ? 1 : 0) |
27
+ (state.mod1_mask? ? 2 : 0) |
28
+ (state.shift_mask? ? 4 : 0)
29
+ "#<Gdk::EventKey #{event_type.name} with state: #{modifiers}, keyval: #{keyval}, keycode: #{hardware_keycode}>"
30
+ end
31
+
32
+ def == other
33
+ inspect == other.inspect
34
+ end
35
+ end
36
+
37
+ def mock_source_model
38
+ mock SourceModel, :style_scheme= => nil, :highlight_matching_brackets= => nil, :modified= => nil, :signal_connect => nil, :start_iter => nil, :place_cursor => nil
39
+ end
40
+
41
+ describe '#load_all' do
42
+ it 'creates the source models' do
43
+ SourceModel.should_receive(:new).with('path1').and_return @mock_source_model
44
+ SourceModel.should_receive(:new).with('path2').and_return @mock_source_model
45
+ @mock_edit.should_receive(:buffer=).once.with @mock_source_model
46
+ @mock_source_model.should_receive(:modified=).with false
47
+ @mock_source_model.should_receive(:style_scheme=).with @mock_theme
48
+ @mock_source_model.should_receive(:highlight_matching_brackets=).with true
49
+
50
+ file = FileController.new @mock_commands, @mock_views
51
+ file.load_all ['path1', 'path2']
52
+ end
53
+ end
54
+
55
+ describe '#load' do
56
+ it 'adds name to file list' do
57
+ @mock_list.should_receive(:prepend).with 'path'
58
+ file = FileController.new @mock_commands, @mock_views
59
+ file.load 'path'
60
+ end
61
+
62
+ it 'positions cursor at start of file' do
63
+ mock_iter = mock Gtk::TextIter
64
+ @mock_source_model.should_receive(:start_iter).and_return mock_iter
65
+ @mock_source_model.should_receive(:place_cursor).with mock_iter
66
+ file = FileController.new @mock_commands, @mock_views
67
+ file.load 'path'
68
+ end
69
+ end
70
+
71
+ it 'requests source model to save' do
72
+ @mock_edit.stub(:buffer).and_return @mock_source_model
73
+ @mock_source_model.should_receive :save
74
+
75
+ file = FileController.new @mock_commands, @mock_views
76
+ file.save
77
+ end
78
+
79
+ it 'indicate when source model has been modified' do
80
+ @mock_source_model.stub(:modified?).and_return true
81
+ @mock_source_model.should_receive(:signal_connect).with('modified_changed').and_yield
82
+ @mock_image.should_receive(:file=).with /modified.svg/
83
+
84
+ file = FileController.new @mock_commands, @mock_views
85
+ file.load_all ['path']
86
+ end
87
+
88
+ it 'indicate when source model is not modified' do
89
+ @mock_source_model.stub(:modified?).and_return false
90
+ @mock_source_model.should_receive(:signal_connect).with('modified_changed').and_yield
91
+ @mock_image.should_receive(:file=).with /saved.svg/
92
+
93
+ file = FileController.new @mock_commands, @mock_views
94
+ file.load_all ['path']
95
+ end
96
+
97
+ describe '#switch' do
98
+ before(:each) do
99
+ @mock_list.stub :show
100
+ @mock_list.stub :next
101
+ @mock_list.stub(:selected).and_return 'path1'
102
+
103
+ @mock_edit.stub :switch
104
+ end
105
+
106
+ context 'when shortcut pressed' do
107
+ before(:each) do
108
+ @mock_main.stub :signal_connect
109
+ @next_mock_source_model = mock_source_model
110
+ @file = FileController.new @mock_commands, @mock_views
111
+ @file.stub :id=
112
+ end
113
+
114
+ context 'when list has two items' do
115
+ before(:each) do
116
+ SourceModel.stub(:new).with('path1').and_return @mock_source_model
117
+ SourceModel.stub(:new).with('path2').and_return @next_mock_source_model
118
+ @file.load_all ['path1', 'path2']
119
+ end
120
+
121
+ context 'when shortcut pressed, released and pressed' do
122
+ it 'does not display file_list' do
123
+ @mock_list.should_not_receive :show
124
+ event = Shortcut.to_event('CTRL', :release)
125
+ @mock_main.stub(:signal_connect).with('key_release_event').and_yield(nil, event)
126
+ @file.switch
127
+ @file.switch
128
+ end
129
+ end
130
+
131
+ context 'when shortcut pressed the second time' do
132
+ it 'displays file_list' do
133
+ @mock_list.should_receive :show
134
+ @file.switch
135
+ @file.switch
136
+ end
137
+
138
+ it 'highlight second file in the list' do
139
+ @mock_list.should_receive(:next)
140
+ @mock_list.should_receive(:selected).and_return 'path2'
141
+ @mock_edit.should_receive(:buffer=).with(@next_mock_source_model)
142
+ @file.switch
143
+ @file.switch
144
+ end
145
+ end
146
+ end
147
+
148
+ context 'when list is empty' do
149
+ it 'list is not shown and nothing happens' do
150
+ @mock_list.stub(:empty?).and_return true
151
+ @mock_list.should_not_receive :show
152
+ @file.switch
153
+ end
154
+ end
155
+ end
156
+
157
+ context 'when releasing TAB' do
158
+ it 'does nothing' do
159
+ event = Shortcut.to_event('TAB', :release)
160
+ file = FileController.new @mock_commands, @mock_views
161
+ @mock_main.stub(:signal_connect).and_yield nil, event
162
+ @mock_list.should_not_receive :hide
163
+ @mock_main.should_not_receive :signal_handler_disconnect
164
+ file.switch
165
+ end
166
+ end
167
+
168
+ context 'when releasing modifier' do
169
+ before(:each) do
170
+ @mock_edit.stub(:scroll_to_cursor)
171
+ @event = Shortcut.to_event("CTRL", :release)
172
+ @mock_list.stub :hide
173
+ end
174
+
175
+ it 'moves selected file to the top of the list' do
176
+ file = FileController.new @mock_commands, @mock_views
177
+ @mock_main.stub(:signal_connect).and_yield nil, @event
178
+ @mock_list.should_receive :selected_to_top
179
+ file.switch
180
+ end
181
+
182
+ it 'hides file_list' do
183
+ @mock_list.should_receive :hide
184
+
185
+ @mock_main.stub!(:signal_connect).with('key_release_event').and_yield(nil, @event).and_return 1
186
+ file = FileController.new @mock_commands, @mock_views
187
+ file.should_receive(:handler_id=).with(1)
188
+ file.should_receive(:handler_id).and_return 1
189
+ file.switch
190
+ end
191
+
192
+ it 'handler_id from key release event is used to disconnect handler' do
193
+ @mock_main.should_receive(:signal_connect).with('key_release_event').and_return(1)
194
+ file = FileController.new @mock_commands, @mock_views
195
+ file.switch
196
+ file.send(:handler_id).should == 1
197
+ end
198
+
199
+ it 'disconnect handler is called with the correct handler id' do
200
+ @mock_main.stub!(:signal_connect).with('key_release_event').and_yield(nil, @event)
201
+ @mock_main.should_receive(:signal_handler_disconnect).with 1
202
+ file = FileController.new @mock_commands, @mock_views
203
+ file.send(:handler_id=, 1)
204
+ file.switch
205
+ end
206
+ end
207
+ end
208
+ end
209
+
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe MainController do
4
+ it 'sets the title' do
5
+ mock_commands = mock Commands, :register => nil
6
+ mock_view = mock Gtk::Window, :signal_connect => nil
7
+ mock_view.should_receive(:title=).with('project (working/dir)')
8
+ main = MainController.new mock_commands, {:main => mock_view}
9
+ main.working_dir = 'working/dir/project'
10
+ end
11
+
12
+ it 'quit destroys window' do
13
+ mock_commands = mock Commands, :register => nil
14
+ mock_view = mock Gtk::Window, :signal_connect => nil
15
+ mock_view.should_receive :destroy
16
+ main = MainController.new mock_commands, {:main => mock_view}
17
+ main.quit
18
+ end
19
+ end
20
+
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gtk::Bin do
4
+ it 'adds the container to the widget' do
5
+ widget = Gtk::Window.new
6
+
7
+ mock_vbox = mock Gtk::VBox
8
+ Gtk::VBox.stub!(:new).and_return mock_vbox
9
+ widget.should_receive(:add).with(mock_vbox)
10
+ widget.container = 'VBox'
11
+ end
12
+ end
13
+
@@ -0,0 +1,114 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gtk::ListView do
4
+ before(:each) do
5
+ @list_view = Gtk::ListView.new
6
+ @mock_iter = mock Gtk::TreeIter
7
+ @mock_selection = mock Gtk::TreeSelection, :selected => nil, :select_iter => nil
8
+ @mock_list_store = mock Gtk::ListStore, :append => nil, :set_value => nil, :prepend => @mock_iter
9
+ @mock_list_store.stub(:iter_first).and_return @mock_iter
10
+ @list_view.stub(:selection).and_return @mock_selection
11
+ @list_view.stub(:model).and_return @mock_list_store
12
+ end
13
+
14
+ it 'headers are not visible' do
15
+ @list_view.should_not be_headers_visible
16
+ end
17
+
18
+ it 'has one column' do
19
+ @list_view.columns.size.should == 1
20
+ end
21
+
22
+ describe '#prepend' do
23
+ it 'adds row to the start of the list' do
24
+ @mock_list_store.should_receive :prepend
25
+ @mock_list_store.should_receive(:set_value).with(@mock_iter, 0, 'Item 1')
26
+ @list_view.prepend 'Item 1'
27
+ end
28
+
29
+ it 'selects item' do
30
+ @mock_selection.should_receive(:select_iter).with @mock_iter
31
+ @list_view.prepend 'Item 1'
32
+ end
33
+ end
34
+
35
+ describe '#list=' do
36
+ before(:each) do
37
+ @list_view.stub!(:model=)
38
+ @list_view.stub!(:model).and_return @mock_list_store
39
+ Gtk::ListStore.stub!(:new).and_return @mock_list_store
40
+ end
41
+
42
+ it 'insert a number of rows' do
43
+ @mock_list_store.should_receive(:append).twice.and_return @mock_iter
44
+ @mock_list_store.should_receive(:set_value).with(@mock_iter, 0, 'Item 1')
45
+ @mock_list_store.should_receive(:set_value).with(@mock_iter, 0, 'Item 2')
46
+ @list_view.list = ['Item 1', 'Item 2']
47
+ end
48
+
49
+ it 'selects first row' do
50
+ @mock_selection.should_receive(:select_iter).with @mock_iter
51
+ @list_view.list = ['Item 1']
52
+ end
53
+
54
+ it 'does not select first row if none set' do
55
+ @list_view.should_not_receive(:selection)
56
+ @list_view.list = []
57
+ end
58
+ end
59
+
60
+ describe '#next' do
61
+ it 'selects the next row' do
62
+ mock_selection = mock Gtk::TreeSelection, :selected => @mock_iter
63
+ @mock_iter.should_receive :next!
64
+ mock_selection.should_receive(:select_iter).with @mock_iter
65
+ @list_view.stub(:selection).and_return mock_selection
66
+ @list_view.next
67
+ end
68
+
69
+ context 'when no row selected' do
70
+ it 'what should happen?'
71
+ end
72
+ end
73
+
74
+ describe '#selected' do
75
+ before(:each) do
76
+ end
77
+
78
+ it 'retrieves the text of the selected row' do
79
+ @list_view.stub(:selection).and_return @mock_selection
80
+ @mock_selection.stub(:selected).and_return @mock_iter
81
+ @mock_iter.stub(:[]).with(0).and_return 'selected row'
82
+ @list_view.selected.should == 'selected row'
83
+ end
84
+
85
+ it 'does not fail when nothing selected' do
86
+ @list_view.stub(:selection).and_return @mock_selection
87
+ @list_view.selected.should be_nil
88
+ end
89
+ end
90
+
91
+ describe '#selected_to_top' do
92
+ it 'moves the selected row to the top of the list' do
93
+ @list_view.stub(:selection).and_return @mock_selection
94
+ selected_mock_iter = mock Gtk::TreeIter
95
+ @mock_selection.stub(:selected).and_return selected_mock_iter
96
+ @list_view.stub(:model).and_return @mock_list_store
97
+ @mock_list_store.should_receive(:move_before).with(selected_mock_iter, @mock_iter)
98
+ @list_view.selected_to_top
99
+ end
100
+ end
101
+
102
+ describe '#empty?' do
103
+ it 'empty when no rows' do
104
+ @mock_list_store.stub(:iter_first).and_return nil
105
+ @list_view.should be_empty
106
+ end
107
+
108
+ it 'not empty when at least one row' do
109
+ @mock_list_store.stub(:iter_first).and_return @mock_iter
110
+ @list_view.should_not be_empty
111
+ end
112
+ end
113
+ end
114
+
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gtk::SourceView do
4
+ before(:each) do
5
+ @view = Gtk::SourceView.new
6
+ end
7
+
8
+ it 'sets font' do
9
+ mock_font = mock Pango::FontDescription
10
+ Pango::FontDescription.should_receive(:new).with('a font').and_return mock_font
11
+ @view.should_receive(:modify_font).with mock_font
12
+ @view.font = 'a font'
13
+ end
14
+
15
+ it 'sets theme' do
16
+ mock_scheme = mock(Gtk::SourceStyleScheme)
17
+ mock_style_manager = mock(Gtk::SourceStyleSchemeManager)
18
+ Gtk::SourceStyleSchemeManager.stub(:new).and_return mock_style_manager
19
+ mock_style_manager.should_receive(:prepend_search_path).with /path\/to/
20
+ mock_style_manager.should_receive(:get_scheme).with('theme').and_return mock_scheme
21
+ @view.stub :buffer
22
+ @view.theme = 'path/to/theme'
23
+ @view.theme.should == mock_scheme
24
+ end
25
+
26
+ it 'sets highlight_brackets' do
27
+ @view.highlight_matching_brackets = true
28
+ @view.highlight_brackets.should be_true
29
+ end
30
+
31
+ describe '#scroll_to_cursor' do
32
+ it 'moves visible area to cursor' do
33
+ mock_mark = Gtk::SourceMark
34
+ mock_buffer = mock Gtk::SourceBuffer, :selection_bound => mock_mark
35
+ @view.stub(:buffer).and_return mock_buffer
36
+ @view.should_receive(:scroll_mark_onscreen).with(mock_mark)
37
+ @view.scroll_to_cursor
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gtk::Widget do
4
+ it 'sets the font' do
5
+ mock_font = mock Pango::FontDescription
6
+ Pango::FontDescription.stub!(:new).with('font').and_return mock_font
7
+
8
+ window = Gtk::Window.new
9
+ window.should_receive(:modify_font).with mock_font
10
+ window.font = 'font'
11
+ end
12
+
13
+ describe 'initially_hidden' do
14
+ before(:each) do
15
+ @window = Gtk::Window.new
16
+ end
17
+
18
+ it 'ignores first show call when initially hidden' do
19
+ @window.initially_hidden = true
20
+ @window.show_all
21
+ @window.should_not be_visible
22
+ end
23
+
24
+ it 'shows when not initially hidden' do
25
+ @window.show_all
26
+ @window.should be_visible
27
+ end
28
+
29
+ it 'is made visible on subsequent calls to show' do
30
+ @window.initially_hidden = true
31
+ @window.show
32
+ @window.should be_visible
33
+ end
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gtk::Window do
4
+ subject {Gtk::Window.new}
5
+
6
+ describe '#icon' do
7
+ it 'is assigned' do
8
+ subject.should_receive(:set_icon).with(/path/)
9
+ subject.icon = 'path'
10
+ end
11
+ end
12
+
13
+ describe '#default_position=' do
14
+ it 'is assigned' do
15
+ subject.should_receive(:move).with(1, 2)
16
+ subject.default_position = '1, 2'
17
+ end
18
+ end
19
+
20
+ describe '#default_size=' do
21
+ it 'is assigned' do
22
+ subject.should_receive(:set_default_size).with(1, 2)
23
+ subject.default_size = '1, 2'
24
+ end
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,14 @@
1
+ require 'integration_helper'
2
+
3
+ describe 'Startup' do
4
+ it 'sets the working dir' do
5
+ $application.views[:main].title.should =~ /merrol \(\/home\/.*\)/
6
+ end
7
+
8
+ context 'when CTRL+Q pressed' do
9
+ it 'quits' do
10
+ quits_by_pressing 'CTRL+Q'
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,25 @@
1
+ require 'integration_helper'
2
+
3
+ describe 'Editor' do
4
+ before(:each) do
5
+ @the_contents = 'Some prewritten text. '
6
+ create_file 'the_file', :containing => @the_contents
7
+ end
8
+
9
+ after(:each) do
10
+ destroy_file 'the_file'
11
+ end
12
+
13
+ it 'loads a file from the commandline' do
14
+ application = Application.new '', ['the_file']
15
+ loads @the_contents, :into => :edit, :test_against => application
16
+ displays 'the_file', :in => :file_path, :test_against => application
17
+ displays 'saved.svg', :in => :file_status, :test_against => application
18
+ end
19
+
20
+ it 'does not fail when no files specified on commandline' do
21
+ application = Application.new '', []
22
+ displays '', :in => :edit, :test_against => application
23
+ end
24
+ end
25
+
@@ -0,0 +1,35 @@
1
+ require 'integration_helper'
2
+
3
+ describe 'Loading and saving' do
4
+ before(:each) do
5
+ @the_contents = 'Some prewritten text. '
6
+ create_file 'the_file', :containing => @the_contents
7
+ end
8
+
9
+ after(:each) do
10
+ destroy_file 'the_file'
11
+ end
12
+
13
+ it 'can load and save a file' do
14
+ pending
15
+ pressing 'CTRL+O'
16
+ shows 'open'
17
+
18
+ entering 'the_file', :into => 'open.search_field'
19
+ displays 'the_file', :in => 'open.results'
20
+
21
+ pressing 'ENTER'
22
+ loads @the_contents, :into => :edit
23
+
24
+ entering 'some text', :into => :edit
25
+ displays 'some text', :in => :edit
26
+
27
+ pressing 'CTRL+S'
28
+ saves @the_contents + 'some text', :in => 'the_file'
29
+
30
+ pressing 'CTRL+W'
31
+ closes the file
32
+ saves @the_contents + 'some text', :in => 'the_file'
33
+ end
34
+ end
35
+
@@ -0,0 +1,49 @@
1
+ require 'integration_helper'
2
+
3
+ describe 'CTRL+TAB file switching' do
4
+ before(:each) do
5
+ create_file 'a_file', :containing => some_text_in('a_file')
6
+ create_file 'another_file', :containing => some_text_in('another_file')
7
+ create_file 'a_third_file', :containing => some_text_in('a_third_file')
8
+ end
9
+
10
+ after(:each) do
11
+ destroy_file 'a_file'
12
+ destroy_file 'another_file'
13
+ destroy_file 'a_third_file'
14
+ end
15
+
16
+ it 'switches to third file after loading' do
17
+ pressing 'CTRL+TAB'
18
+ does_not_show :file_list
19
+
20
+ load_file 'a_file'
21
+ load_file 'another_file'
22
+ load_file 'a_third_file'
23
+ displays some_text_from('a_third_file'), :in => :edit
24
+
25
+ pressing 'CTRL+TAB'
26
+ does_not_show :file_list
27
+ displays some_text_from('another_file'), :in => :edit
28
+
29
+ releasing 'CTRL'
30
+ pressing 'CTRL+TAB'
31
+ does_not_show :file_list
32
+ displays some_text_from('a_third_file'), :in => :edit
33
+
34
+ pressing 'CTRL+TAB'
35
+ shows :file_list
36
+ highlights 'a_file', :in => :file_list
37
+ displays ['another_file', 'a_third_file', 'a_file'], :in => :file_list
38
+
39
+ releasing 'CTRL'
40
+ hides :file_list
41
+ displays some_text_from('a_file'), :in => :edit
42
+
43
+ pressing 'CTRL+TAB'
44
+ does_not_show :file_list
45
+ releasing 'CTRL'
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,23 @@
1
+ require 'integration_helper'
2
+
3
+ describe 'ideas' do
4
+ describe 'gedit does not' do
5
+ it 'move past quotes or brackets when TAB pressed'
6
+ it 'support nested quotes and brackets'
7
+ it 'ignore TAB completion when already in TAB completion'
8
+ it 'complete words sometimes'
9
+ it 'paste at current cursor location'
10
+ end
11
+
12
+ it 'splits screen and switches to it when ALT+RIGHT pressed'
13
+ it 'switches to existing split screen when ALT+RIGHT pressed'
14
+ it 'shortcut of the day in status bar'
15
+ it 'options to turn off shortcut of the day'
16
+ it 'Adding a new file automatically adds spec/test file'
17
+ it 'opening a previously opened directory reloads the previously open files'
18
+
19
+ describe 'snippets' do
20
+ it 'handle multi-choice parameters by TABing through and pressing ENTER on the desired option'
21
+ end
22
+ end
23
+
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+ require 'support/setup'
3
+ require 'support/actions'
4
+ require 'support/expectations'
5
+
6
+ Rspec.configure do |c|
7
+ c.before(:all) do
8
+ $application = Application.new WORKING_DIR, [] unless $application
9
+ end
10
+ end
11
+
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Application do
4
+ before(:each) do
5
+ @mock_window = mock Gtk::Window, :show_all => nil
6
+ @mock_file_list = mock Gtk::ListView, :list= => nil
7
+ @mock_file_path = mock Gtk::Label, :text= => nil
8
+ @mock_edit = mock Gtk::SourceView, :grab_focus => nil
9
+ @mock_commands = mock Commands
10
+ @mock_main = mock MainController, :working_dir= => nil
11
+ @mock_file = mock FileController, :load_all => nil
12
+
13
+ @widgets = {:main => @mock_window, :file_list => @mock_file_list, :file_path => @mock_file_path, :edit => @mock_edit}
14
+ WidgetBuilder.stub(:build).and_return(@widgets)
15
+ Commands.stub(:new).and_return @mock_commands
16
+ Dir.stub(:[]).and_return %w(main_controller.rb file_controller.rb)
17
+ MainController.stub(:new).and_return @mock_main
18
+ FileController.stub(:new).and_return @mock_file
19
+ end
20
+
21
+ it 'builds widgets' do
22
+ WidgetBuilder.should_receive :build
23
+ Application.new nil, []
24
+ end
25
+
26
+ it 'creates controllers' do
27
+ MainController.should_receive :new
28
+ FileController.should_receive :new
29
+ Application.new nil, []
30
+ end
31
+
32
+ it 'sets working dir' do
33
+ @mock_main.should_receive(:working_dir=).with 'working dir'
34
+ Application.new 'working dir', []
35
+ end
36
+
37
+ it 'loads files' do
38
+ @mock_file.should_receive(:load_all).with ['paths']
39
+ Application.new nil, ['paths']
40
+ end
41
+
42
+ it 'sets file path' do
43
+ @mock_file_path.should_receive(:text=).with 'path'
44
+ Application.new nil, ['path']
45
+ end
46
+
47
+ it 'focuses source view' do
48
+ @mock_edit.should_receive(:grab_focus)
49
+ Application.new nil, []
50
+ end
51
+
52
+ it 'shows main window' do
53
+ @mock_window.should_receive(:show_all)
54
+ Application.new nil, []
55
+ end
56
+ end
57
+