scide 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.rspec +0 -1
  2. data/.ruby-version +1 -0
  3. data/.screenrc +8 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile +10 -11
  6. data/Gemfile.lock +46 -39
  7. data/LICENSE.txt +1 -1
  8. data/README.md +36 -144
  9. data/Rakefile +19 -26
  10. data/VERSION +1 -1
  11. data/bin/scide +1 -2
  12. data/lib/scide/auto.rb +33 -0
  13. data/lib/scide/list.rb +33 -0
  14. data/lib/scide/open.rb +57 -0
  15. data/lib/scide/program.rb +109 -0
  16. data/lib/scide/setup.rb +16 -0
  17. data/lib/scide.rb +25 -57
  18. data/scide.gemspec +51 -59
  19. data/spec/auto_spec.rb +72 -0
  20. data/spec/cli/list_spec.rb +81 -0
  21. data/spec/cli/open_spec.rb +131 -0
  22. data/spec/cli/setup_spec.rb +82 -0
  23. data/spec/helper.rb +12 -24
  24. data/spec/list_spec.rb +113 -0
  25. data/spec/open_spec.rb +228 -0
  26. data/spec/setup_spec.rb +106 -0
  27. data/spec/version_spec.rb +3 -5
  28. metadata +150 -72
  29. data/.document +0 -5
  30. data/.rvmrc +0 -41
  31. data/TODO.md +0 -21
  32. data/lib/scide/command.rb +0 -124
  33. data/lib/scide/commands/edit.rb +0 -37
  34. data/lib/scide/commands/run.rb +0 -25
  35. data/lib/scide/commands/show.rb +0 -29
  36. data/lib/scide/commands/tail.rb +0 -37
  37. data/lib/scide/config.rb +0 -105
  38. data/lib/scide/global.rb +0 -30
  39. data/lib/scide/opts.rb +0 -35
  40. data/lib/scide/overmind.rb +0 -70
  41. data/lib/scide/project.rb +0 -93
  42. data/lib/scide/screen.rb +0 -77
  43. data/lib/scide/window.rb +0 -88
  44. data/spec/command_spec.rb +0 -86
  45. data/spec/commands/edit_spec.rb +0 -19
  46. data/spec/commands/run_spec.rb +0 -9
  47. data/spec/commands/show_spec.rb +0 -15
  48. data/spec/commands/tail_spec.rb +0 -14
  49. data/spec/config_spec.rb +0 -113
  50. data/spec/global_spec.rb +0 -38
  51. data/spec/opts_spec.rb +0 -42
  52. data/spec/project_spec.rb +0 -171
  53. data/spec/results/config1.yml +0 -14
  54. data/spec/results/malformed_config.yml +0 -2
  55. data/spec/results/project1.screen +0 -10
  56. data/spec/results/screen1.screen +0 -14
  57. data/spec/scide_spec.rb +0 -38
  58. data/spec/screen_spec.rb +0 -90
  59. data/spec/window_spec.rb +0 -122
data/spec/config_spec.rb DELETED
@@ -1,113 +0,0 @@
1
- require 'helper'
2
- require 'fileutils'
3
-
4
- describe Scide::Config do
5
-
6
- it "should use the default config file if not given" do
7
- conf = Scide::Config.new
8
- conf.file.should == Scide::Config::DEFAULT_CONFIG_FILE
9
- end
10
-
11
- it "should use the given config file" do
12
- conf = Scide::Config.new '/tmp/fubar'
13
- conf.file.should == '/tmp/fubar'
14
- end
15
-
16
- it "should be empty when not loaded" do
17
- conf = Scide::Config.new
18
- conf.screen.should be_nil
19
- conf.global.should be_nil
20
- conf.projects.should be_nil
21
- end
22
-
23
- it "should be filled when loaded" do
24
- file = File.join File.dirname(__FILE__), 'results', 'config1.yml'
25
- conf = Scide::Config.new file
26
- make_load conf
27
- conf.screen.should be_a(HashWithIndifferentAccess)
28
- conf.global.should be_a(Scide::Global)
29
- conf.projects.should be_a(HashWithIndifferentAccess)
30
- conf.projects[:project1].should be_a(Scide::Project)
31
- end
32
-
33
- [ true, false ].each do |exit_on_fail|
34
- describe "Errors with exit on fail #{exit_on_fail}" do
35
- before :each do
36
- Scide.exit_on_fail = exit_on_fail
37
- end
38
-
39
- after :each do
40
- Scide.exit_on_fail = true
41
- end
42
-
43
- it SpecHelper.should_fail(exit_on_fail, :config_not_found, "when the config file does not exist") do
44
- bad_file = "/tmp/IHateYouIfYouAddedThisFileJustToMakeMyTestFail"
45
- conf = Scide::Config.new bad_file
46
- load_should_fail(conf, :config_not_found)
47
- end
48
-
49
- it SpecHelper.should_fail(exit_on_fail, :config_not_readable, "if the config file is not readable") do
50
- unreadable_file = Tempfile.new 'scide-unreadable'
51
- FileUtils.chmod 0200, unreadable_file.path
52
- conf = Scide::Config.new unreadable_file.path
53
- load_should_fail(conf, :config_not_readable)
54
- unreadable_file.unlink
55
- end
56
-
57
- it SpecHelper.should_fail(exit_on_fail, :unexpected, "if the config file cannot be read") do
58
- file = File.join File.dirname(__FILE__), 'results', 'config1.yml'
59
- conf = Scide::Config.new file
60
- conf.stub!(:load_config){ raise 'bug' }
61
- load_should_fail(conf, :unexpected)
62
- end
63
-
64
- it SpecHelper.should_fail(exit_on_fail, :malformed_config, "if the config file is not valid YAML") do
65
- file = File.join File.dirname(__FILE__), 'results', 'malformed_config.yml'
66
- conf = Scide::Config.new file
67
- load_should_fail(conf, :malformed_config)
68
- end
69
-
70
- it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the configuration is not a hash") do
71
- conf = Scide::Config.new
72
- conf.stub!(:check_config){}
73
- conf.stub!(:load_config){ "- 'a'\n- 'b'" }
74
- load_should_fail(conf, :invalid_config)
75
- end
76
-
77
- it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the screen configuration is not a hash") do
78
- conf = Scide::Config.new
79
- conf.stub!(:check_config){}
80
- conf.stub!(:load_config){ "screen:\n- 'a'\n- 'b'" }
81
- load_should_fail(conf, :invalid_config)
82
- end
83
-
84
- it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the projects configuration is not a hash") do
85
- conf = Scide::Config.new
86
- conf.stub!(:check_config){}
87
- conf.stub!(:load_config){ "projects:\n- 'a'\n- 'b'" }
88
- load_should_fail(conf, :invalid_config)
89
- end
90
-
91
- it SpecHelper.should_fail(exit_on_fail, :invalid_config, "if the configuration is otherwise invalid") do
92
- conf = Scide::Config.new
93
- conf.stub!(:check_config){}
94
- conf.stub!(:load_config){ "global:\n a: true\nprojects:\n a:\n - 'a'\n - 'b'" }
95
- load_should_fail(conf, :invalid_config)
96
- end
97
- end
98
- end
99
-
100
- private
101
-
102
- def make_load conf
103
- SpecHelper.silence{ conf.load! }
104
- end
105
-
106
- def load_should_fail conf, condition
107
- if Scide.exit_on_fail
108
- lambda{ make_load conf }.should raise_error(SystemExit){ |err| err.status.should == Scide::EXIT[condition] }
109
- else
110
- lambda{ make_load conf }.should raise_error(Scide::Error){ |err| err.condition.should == condition }
111
- end
112
- end
113
- end
data/spec/global_spec.rb DELETED
@@ -1,38 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Global do
4
-
5
- it "should take the given path if absolute" do
6
- global = Scide::Global.new :path => '/tmp'
7
- global.path.should == '/tmp'
8
- end
9
-
10
- it "should expand the given path from the home directory if relative" do
11
- global = Scide::Global.new :path => 'fubar'
12
- global.path.should == File.join(File.expand_path('~'), 'fubar')
13
- end
14
-
15
- it "should use the home directory if no path is given" do
16
- global = Scide::Global.new({})
17
- global.path.should == File.expand_path('~')
18
- end
19
-
20
- it "should duplicate the given options" do
21
- options = { :a => 1, :b => true }
22
- global = Scide::Global.new :options => options
23
- global.options.should == options
24
- global.options.should_not equal(options)
25
- end
26
-
27
- it "should raise an error if the contents are not a hash" do
28
- [ nil, ' ', [] ].each do |not_hash|
29
- lambda{ Scide::Global.new not_hash }.should raise_error(ArgumentError)
30
- end
31
- end
32
-
33
- it "should raise an error if its options are not nil and not a hash" do
34
- [ ' ', [] ].each do |not_hash|
35
- lambda{ Scide::Global.new :options => not_hash }.should raise_error(ArgumentError)
36
- end
37
- end
38
- end
data/spec/opts_spec.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Opts do
4
-
5
- before :each do
6
- @opts = Scide::Opts.new
7
- end
8
-
9
- it "should add the help flag" do
10
- [ '-h', '--help' ].each do |flag|
11
- lambda{ parse!([flag]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
12
- end
13
- end
14
-
15
- it "should add the usage flag" do
16
- [ '-u', '--usage' ].each do |flag|
17
- lambda{ parse!([flag]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
18
- end
19
- end
20
-
21
- it "should add the version flag" do
22
- expected_version = File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r').read
23
- lambda{ parse!([ '--version' ]) }.should raise_error(SystemExit){ |err| err.status.should == 0 }
24
- end
25
-
26
- it "should add the dry run flag" do
27
- parse!([ '--dry-run' ])
28
- @opts.funnel[:'dry-run'].should == true
29
- end
30
-
31
- it "should exit with status 2 for unknown arguments" do
32
- [ '-x', '--fubar', '-4' ].each do |unknown|
33
- lambda{ parse!([unknown]) }.should raise_error(SystemExit){ |err| err.status.should == 2 }
34
- end
35
- end
36
-
37
- private
38
-
39
- def parse! args
40
- silence_stream(STDOUT){ silence_stream(STDERR){ @opts.parse! args } }
41
- end
42
- end
data/spec/project_spec.rb DELETED
@@ -1,171 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Project do
4
-
5
- before :each do
6
- @path = '/tmp'
7
- @options = { :a => 1, :b => true }
8
- @global = double('global')
9
- @global.stub(:path){ @path }
10
- @global.stub(:options){ @options }
11
- end
12
-
13
- it "should add the project key to the global path by default" do
14
- pro = Scide::Project.new @global, 'fubar', :windows => []
15
- pro.path.should == File.join(@path, pro.key)
16
- end
17
-
18
- it "should add its path to the global path if relative" do
19
- pro = Scide::Project.new @global, 'fubar', :windows => [], :path => 'foo'
20
- pro.path.should == File.join(@path, 'foo')
21
- end
22
-
23
- it "should use its path if absolute" do
24
- pro = Scide::Project.new @global, 'fubar', :windows => [], :path => '/foo'
25
- pro.path.should == '/foo'
26
- end
27
-
28
- it "should use its path if there is no global path" do
29
- global_no_path = double('global')
30
- global_no_path.stub(:path){ nil }
31
- global_no_path.stub(:options){ { :a => 1, :b => true } }
32
- pro = Scide::Project.new global_no_path, 'fubar', :windows => [], :path => '/foo'
33
- pro.path.should == '/foo'
34
- end
35
-
36
- it "should expand its path if relative" do
37
- global_relative = double('global')
38
- global_relative.stub(:path){ nil }
39
- global_relative.stub(:options){ { :a => 1, :b => true } }
40
- pro = Scide::Project.new global_relative, 'fubar', :windows => []
41
- pro.path.should == File.join(File.expand_path('~'), 'fubar')
42
- end
43
-
44
- it "should duplicate global options" do
45
- @global.should_receive :path
46
- @global.should_receive :options
47
- pro = Scide::Project.new @global, 'fubar', :windows => []
48
- pro.options.should_not equal(@options)
49
- end
50
-
51
- it "should add name and path to options" do
52
- additional_options = { :name => 'fubar', :path => File.join(@path, 'fubar') }
53
- pro = Scide::Project.new @global, 'fubar', :windows => []
54
- pro.options.should == @options.merge(additional_options)
55
- end
56
-
57
- it "should override global name and path" do
58
- global_with_name_and_path = double('global')
59
- global_with_name_and_path.stub(:path){ @path }
60
- global_with_name_and_path.stub(:options){ { :name => 'global', :path => '/global' } }
61
- pro = Scide::Project.new global_with_name_and_path, 'fubar', :windows => []
62
- pro.options[:name].should_not == 'global'
63
- pro.options[:path].should_not == '/global'
64
- end
65
-
66
- it "should merge given options" do
67
- additional_options = { :name => 'fubar', :path => File.join(@path, 'fubar') }
68
- new_options = { :name => 'fubar2', :path => '/tmp2', :b => false, :c => 'foo' }
69
- pro = Scide::Project.new @global, 'fubar', :windows => [], :options => new_options
70
- pro.options.should == @options.merge(additional_options).merge(new_options)
71
- end
72
-
73
- describe 'Sample Configuration' do
74
- before :each do
75
- @contents = {
76
- :windows => [
77
- 'window1 EDIT',
78
- { :name => 'window2', :command => 'SHOW', :contents => 'ssh example.com' },
79
- 'window3 TAIL file.txt',
80
- { :string => 'window4 RUN ls -la' },
81
- 'window5'
82
- ],
83
- :default_window => :window4
84
- }
85
- @project = Scide::Project.new @global, 'fubar', @contents
86
- end
87
-
88
- it "should create five windows" do
89
- @project.windows.length.should == 5
90
- @project.windows.each{ |w| w.should be_a(Scide::Window) }
91
- end
92
-
93
- it "should create the correct commands" do
94
- @project.windows[0].command.should be_a(Scide::Commands::Edit)
95
- @project.windows[1].command.should be_a(Scide::Commands::Show)
96
- @project.windows[2].command.should be_a(Scide::Commands::Tail)
97
- @project.windows[3].command.should be_a(Scide::Commands::Run)
98
- @project.windows[4].command.should be_nil
99
- end
100
-
101
- it "should find the correct default window" do
102
- @project.default_window.should == @project.windows[3]
103
- end
104
-
105
- it "should create the correct GNU Screen configuration" do
106
- @project.to_screen.should == SpecHelper.result(:project1)
107
- end
108
-
109
- describe 'Default Window' do
110
- before :each do
111
- @default_window_contents = @contents.dup
112
- end
113
-
114
- it "should find the default window with a fixnum" do
115
- @default_window_contents[:default_window] = 0
116
- project = Scide::Project.new(@global, 'fubar', @default_window_contents)
117
- project.default_window.should == project.windows[0]
118
- end
119
-
120
- it "should find the default window with a negative fixnum" do
121
- @default_window_contents[:default_window] = -4
122
- project = Scide::Project.new(@global, 'fubar', @default_window_contents)
123
- project.default_window.should == project.windows[1]
124
- end
125
-
126
- it "should find the default window with a string" do
127
- @default_window_contents[:default_window] = 'window3'
128
- project = Scide::Project.new(@global, 'fubar', @default_window_contents)
129
- project.default_window.should == project.windows[2]
130
- end
131
-
132
- it "should find the default window with a symbol" do
133
- @default_window_contents[:default_window] = :window5
134
- project = Scide::Project.new(@global, 'fubar', @default_window_contents)
135
- project.default_window.should == project.windows[4]
136
- end
137
-
138
- it "should raise an error if the default window is not a fixnum, string or symbol" do
139
- [ [], {}, 0.4 ].each do |invalid|
140
- @default_window_contents[:default_window] = invalid
141
- lambda{ Scide::Project.new @global, 'fubar', @default_window_contents }.should raise_error(ArgumentError)
142
- end
143
- end
144
-
145
- it "should raise an error if the default window is unknown" do
146
- [ 'unknown', :unknown, -10, -6, 5, 10 ].each do |invalid|
147
- @default_window_contents[:default_window] = invalid
148
- lambda{ Scide::Project.new @global, 'fubar', @default_window_contents }.should raise_error(ArgumentError)
149
- end
150
- end
151
- end
152
- end
153
-
154
- it "should raise an error if the contents are not a hash" do
155
- [ nil, ' ', [] ].each do |not_hash|
156
- lambda{ Scide::Project.new @global, 'fubar', not_hash }.should raise_error(ArgumentError)
157
- end
158
- end
159
-
160
- it "should raise an error if its windows are nil or not an array" do
161
- [ nil, ' ', {} ].each do |not_array|
162
- lambda{ Scide::Project.new @global, 'fubar', :windows => not_array }.should raise_error(ArgumentError)
163
- end
164
- end
165
-
166
- it "should raise an error if its options are not nil and not a hash" do
167
- [ ' ', [] ].each do |not_hash|
168
- lambda{ Scide::Project.new @global, 'fubar', :windows => [], :options => not_hash }.should raise_error(ArgumentError)
169
- end
170
- end
171
- end
@@ -1,14 +0,0 @@
1
- screen:
2
- hardstatus: 'dummy'
3
- global:
4
- path: '/tmp'
5
- projects:
6
- project1:
7
- windows:
8
- - 'window1 EDIT'
9
- - name: 'window2'
10
- command: 'SHOW'
11
- contents: 'ssh example.com'
12
- - 'window3 TAIL file.txt'
13
- - string: 'window4 RUN ls -la'
14
- - 'window5'
@@ -1,2 +0,0 @@
1
- bad:
2
- - yaml
@@ -1,10 +0,0 @@
1
- screen -t window1 0
2
- stuff "$EDITOR\012"
3
- screen -t window2 1
4
- stuff "ssh example.com"
5
- screen -t window3 2
6
- stuff "tail -f file.txt\012"
7
- screen -t window4 3
8
- stuff "ls -la\012"
9
- screen -t window5 4
10
- select window4
@@ -1,14 +0,0 @@
1
- startup_message off
2
- hardstatus on
3
- hardstatus alwayslastline
4
- hardstatus string 'dummy'
5
-
6
- screen -t window1 0
7
- stuff "$EDITOR\012"
8
- screen -t window2 1
9
- stuff "ssh example.com"
10
- screen -t window3 2
11
- stuff "tail -f file.txt\012"
12
- screen -t window4 3
13
- stuff "ls -la\012"
14
- screen -t window5 4
data/spec/scide_spec.rb DELETED
@@ -1,38 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide do
4
-
5
- before :each do
6
- Scide.exit_on_fail = true
7
- end
8
-
9
- after :each do
10
- Scide.exit_on_fail = true
11
- end
12
-
13
- it "should have the correct version" do
14
- Scide::VERSION.should == File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), 'r').read
15
- end
16
-
17
- it "should exit on fail by default" do
18
- lambda{ SpecHelper.silence{ Scide.fail nil, 'fubar' } }.should raise_error(SystemExit)
19
- end
20
-
21
- it "should exit with the correct status code" do
22
- Scide::EXIT.each_pair do |condition,code|
23
- lambda{ SpecHelper.silence{ Scide.fail condition, 'fubar' } }.should raise_error(SystemExit){ |err| err.status.should == code }
24
- end
25
- end
26
-
27
- it "should raise an error on fail if configured to do so" do
28
- Scide.exit_on_fail = false
29
- lambda{ Scide.fail nil, 'fubar' }.should raise_error(Scide::Error)
30
- end
31
-
32
- it "should raise an error with the correct condition" do
33
- Scide.exit_on_fail = false
34
- Scide::EXIT.each_pair do |condition,code|
35
- lambda{ Scide.fail condition, 'fubar' }.should raise_error(Scide::Error){ |err| err.condition.should == condition }
36
- end
37
- end
38
- end
data/spec/screen_spec.rb DELETED
@@ -1,90 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Screen do
4
-
5
- before :each do
6
- @project = double('project')
7
- @project.stub(:path){ '/tmp' }
8
- @project.stub(:to_screen){ 'fubar' }
9
- end
10
-
11
- it "should generate a command to run screen at the given project's path" do
12
- screen = Scide::Screen.new(@project, {})
13
- @project.should_receive :path
14
- screen.to_command('fubar').should == 'cd /tmp && screen -c fubar'
15
- end
16
-
17
- it "should generate a command to run screen with the given options" do
18
- screen = Scide::Screen.new @project, :binary => '/usr/bin/screen', :args => '-U'
19
- @project.should_receive :path
20
- screen.to_command('fubar').should == 'cd /tmp && /usr/bin/screen -U -c fubar'
21
- end
22
-
23
- it "should generate a screen configuration file" do
24
- global = double('global')
25
- global.stub(:path){ nil }
26
- global.stub(:options){ {} }
27
- contents = {
28
- :windows => [
29
- 'window1 EDIT',
30
- { :name => 'window2', :command => 'SHOW', :contents => 'ssh example.com' },
31
- 'window3 TAIL file.txt',
32
- { :string => 'window4 RUN ls -la' },
33
- 'window5'
34
- ]
35
- }
36
- project = Scide::Project.new(global, 'fubar', contents)
37
- screen = Scide::Screen.new project, :hardstatus => 'dummy'
38
- screen.to_s.should == SpecHelper.result(:screen1)
39
- end
40
-
41
- it "should use the default hardstatus line if not given" do
42
- screen = Scide::Screen.new(@project, {})
43
- screen.hardstatus.should == Scide::Screen::DEFAULT_HARDSTATUS
44
- end
45
-
46
- it "should use the given hardstatus line" do
47
- screen = Scide::Screen.new @project, :hardstatus => 'fubar'
48
- screen.hardstatus.should == 'fubar'
49
- end
50
-
51
- it "should use the default binary if not given" do
52
- screen = Scide::Screen.new(@project, {})
53
- screen.binary.should == 'screen'
54
- end
55
-
56
- it "should use the given binary" do
57
- screen = Scide::Screen.new @project, :binary => '/usr/bin/screen'
58
- screen.binary.should == '/usr/bin/screen'
59
- end
60
-
61
- it "should use the given args" do
62
- screen = Scide::Screen.new @project, :args => '-U'
63
- screen.args.should == '-U'
64
- end
65
-
66
- it "should duplicate the given options" do
67
- options = { :a => 1, :b => true }
68
- screen = Scide::Screen.new @project, options
69
- screen.options.should == options
70
- screen.options.should_not equal(options)
71
- end
72
-
73
- it "should not raise any error if the screen binary is found" do
74
- screen = '/usr/bin/screen'
75
- Which.stub!(:which){ |name| screen } unless File.executable?(screen)
76
- lambda{ SpecHelper.silence{ Scide::Screen.new(@project, :binary => screen).check_binary } }.should_not raise_error
77
- end
78
-
79
- it "should exit with status 4 if the screen binary is not found" do
80
- bad_binary = "unknown"
81
- Which.stub!(:which){ |name| nil }
82
- lambda{ SpecHelper.silence{ Scide::Screen.new(@project, :binary => bad_binary).check_binary } }.should raise_error(SystemExit){ |err| err.status.should == 4 }
83
- end
84
-
85
- it "should raise an error if the options are not nil and not a hash" do
86
- [ ' ', [] ].each do |not_hash|
87
- lambda{ Scide::Screen.new @project, not_hash }.should raise_error(ArgumentError)
88
- end
89
- end
90
- end
data/spec/window_spec.rb DELETED
@@ -1,122 +0,0 @@
1
- require 'helper'
2
-
3
- describe Scide::Window do
4
-
5
- before :each do
6
- @options = { :a => 1, :b => true }
7
- @project = double('project')
8
- @project.stub(:options){ @options }
9
- end
10
-
11
- describe "String Initialization" do
12
- it "should take the given name" do
13
- win = Scide::Window.new @project, 'fubar'
14
- win.name.should == 'fubar'
15
- end
16
-
17
- it "should create the correct command" do
18
- win = Scide::Window.new @project, 'fubar EDIT'
19
- win.command.should be_a(Scide::Commands::Edit)
20
- end
21
-
22
- it "should be initializable with a name and a command with no contents" do
23
- lambda{ Scide::Window.new @project, 'fubar EDIT' }.should_not raise_error(ArgumentError)
24
- end
25
-
26
- it "should be initializable with a name and a command with contents" do
27
- lambda{ Scide::Window.new @project, 'fubar TAIL file.txt' }.should_not raise_error(ArgumentError)
28
- end
29
-
30
- it "should raise an error when initialized without a name" do
31
- lambda{ Scide::Window.new @project, ' ' }.should raise_error(ArgumentError)
32
- end
33
-
34
- it "should raise an error for unknown commands" do
35
- lambda{ Scide::Window.new @project, 'fubar EDT' }.should raise_error(ArgumentError)
36
- end
37
- end
38
-
39
- describe "Hash Initialization" do
40
- it "should take the given name" do
41
- win = Scide::Window.new @project, :name => 'fubar'
42
- win.name.should == 'fubar'
43
- end
44
-
45
- it "should create the correct command" do
46
- win = Scide::Window.new @project, :name => 'fubar', :command => 'EDIT'
47
- win.command.should be_a(Scide::Commands::Edit)
48
- end
49
-
50
- it "should be initializable with a name and a command with no contents" do
51
- lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDIT' }.should_not raise_error(ArgumentError)
52
- end
53
-
54
- it "should be initializable with a name and a command with contents" do
55
- lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDIT', :contents => 'file.txt' }.should_not raise_error(ArgumentError)
56
- end
57
-
58
- it "should raise an error when initialized without a name" do
59
- lambda{ Scide::Window.new @project, :fubar => true }.should raise_error(ArgumentError)
60
- end
61
-
62
- it "should raise an error for unknown commands" do
63
- lambda{ Scide::Window.new @project, :name => 'fubar', :command => 'EDT' }.should raise_error(ArgumentError)
64
- end
65
-
66
- describe "String Option" do
67
-
68
- it "should take the given name" do
69
- win = Scide::Window.new @project, :string => 'fubar'
70
- win.name.should == 'fubar'
71
- end
72
-
73
- it "should create the correct command" do
74
- win = Scide::Window.new @project, :string => 'fubar EDIT'
75
- win.command.should be_a(Scide::Commands::Edit)
76
- end
77
-
78
- it "should be initializable with a name and a command with no contents" do
79
- lambda{ Scide::Window.new @project, :string => 'fubar EDIT' }.should_not raise_error(ArgumentError)
80
- end
81
-
82
- it "should be initializable with a name and a command with contents" do
83
- lambda{ Scide::Window.new @project, :string => 'fubar EDIT file.txt' }.should_not raise_error(ArgumentError)
84
- end
85
-
86
- it "should raise an error when initialized without a name" do
87
- lambda{ Scide::Window.new @project, :string => ' ' }.should raise_error(ArgumentError)
88
- end
89
-
90
- it "should raise an error for unknown commands" do
91
- lambda{ Scide::Window.new @project, :string => 'fubar EDT' }.should raise_error(ArgumentError)
92
- end
93
- end
94
- end
95
-
96
- it "should raise an error when type of contents is unknown" do
97
- lambda{ Scide::Window.new(@project, []) }.should raise_error(ArgumentError)
98
- end
99
-
100
- it "should duplicate project options" do
101
- @project.should_receive :options
102
- win = Scide::Window.new @project, 'fubar'
103
- win.options.should == @options
104
- win.options.should_not equal(@options)
105
- end
106
-
107
- it "should merge its options to project options" do
108
- window_options = { :b => false, :c => 'foo' }
109
- @project.should_receive :options
110
- win = Scide::Window.new @project, :name => 'fubar', :options => window_options
111
- win.options.should == @options.merge(window_options)
112
- end
113
-
114
- it "should generate a GNU Screen window" do
115
- # without a command, hash initialization
116
- win = Scide::Window.new @project, :name => 'fubar'
117
- win.to_screen(0).should == 'screen -t fubar 0'
118
- # with a command, string initialization
119
- win = Scide::Window.new @project, 'fubar EDIT file.txt'
120
- win.to_screen(0).should == %|screen -t fubar 0\n#{win.command.to_screen}|
121
- end
122
- end