terminitor 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/cli_test.rb CHANGED
@@ -1,52 +1,71 @@
1
1
  require File.expand_path('../teststrap', __FILE__)
2
2
 
3
3
  context "Terminitor" do
4
- setup { @yaml = File.read(File.expand_path('../fixtures/foo.yml', __FILE__)) }
5
- setup { @template = File.read(File.expand_path('../../lib/templates/example.yml.tt', __FILE__)) }
6
- setup { FakeFS.activate! }
7
- setup { FileUtils.mkdir_p(File.join(ENV["HOME"],'.terminitor')) }
4
+ setup do
5
+ @yaml = File.read(File.expand_path('../fixtures/foo.yml', __FILE__))
6
+ @template = File.read(File.expand_path('../../lib/templates/example.yml.tt', __FILE__))
7
+ FakeFS.activate!
8
+ FileUtils.mkdir_p(File.join(ENV["HOME"],'.terminitor'))
9
+ end
8
10
  teardown { FakeFS.deactivate! }
9
11
 
10
12
  context "help" do
11
13
  setup { capture(:stdout) { Terminitor::Cli.start(['-h']) } }
12
- asserts_topic.matches %r{start PROJECT_NAME}
13
- asserts_topic.matches %r{init}
14
- asserts_topic.matches %r{edit PROJECT_NAME}
14
+ asserts_topic.matches %r{start PROJECT_NAME}
15
+ asserts_topic.matches %r{init}
16
+ asserts_topic.matches %r{edit PROJECT_NAME}
15
17
  end
16
18
 
17
19
  context "list" do
18
- setup { @path = "#{ENV['HOME']}/.terminitor/" }
19
- setup { File.open(File.join(@path,'foo.yml'),"w") { |f| f.puts @template } }
20
- setup { File.open(File.join(@path,'bar.yml'),"w") { |f| f.puts @template } }
21
- setup { capture(:stdout) { Terminitor::Cli.start(['list']) } }
20
+ setup do
21
+ @path = "#{ENV['HOME']}/.terminitor/"
22
+ File.open(File.join(@path,'foo.yml'),"w") { |f| f.puts @template }
23
+ File.open(File.join(@path,'bar.yml'),"w") { |f| f.puts @template }
24
+ capture(:stdout) { Terminitor::Cli.start(['list']) }
25
+ end
22
26
  asserts_topic.matches %r{foo - COMMENT OF SCRIPT HERE}
23
27
  asserts_topic.matches %r{bar - COMMENT OF SCRIPT HERE}
24
28
  end
25
29
 
26
- context "init" do
27
- setup { capture(:stdout) { Terminitor::Cli.start(['init']) } }
28
- asserts("creates .terminitor") { File.exists?("#{ENV['HOME']}/.terminitor") }
30
+ asserts "#init creates .terminitor" do
31
+ capture(:stdout) { Terminitor::Cli.start(['init']) }
32
+ File.exists?("#{ENV['HOME']}/.terminitor")
29
33
  end
30
34
 
31
35
  context "edit" do
32
- setup { FakeFS.deactivate! }
33
- setup { `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.yml`}
34
- setup { `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.term`}
35
- teardown { `rm -rf /tmp/sample_project` }
36
- teardown { `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.yml`}
37
- teardown { `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.term`}
36
+ setup do
37
+ FakeFS.deactivate!
38
+ `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.yml`
39
+ `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.term`
40
+ end
41
+
42
+ teardown do
43
+ `rm -rf /tmp/sample_project`
44
+ `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.yml`
45
+ `rm -rf #{ENV['HOME']}/.terminitor/test_foo_bar2.term`
46
+ end
47
+
38
48
  context "for project" do
49
+
39
50
  context "for yaml" do
40
- setup { mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.yml",nil) { true }.once }
41
- setup { capture(:stdout) { Terminitor::Cli.start(['edit','test_foo_bar2', '-s=yml']) } }
51
+ setup do
52
+ capture(:stdout) do
53
+ mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.yml",nil) { true }.once
54
+ Terminitor::Cli.start(['edit','test_foo_bar2', '-s=yml'])
55
+ end
56
+ end
42
57
  asserts_topic.matches %r{create}
43
58
  asserts_topic.matches %r{test_foo_bar2.yml}
44
- asserts("has term template") { File.read(File.join(ENV['HOME'],'.terminitor','test_foo_bar2.yml')) }.matches %r{- tab1}
59
+ asserts("has yml template") { File.read(File.join(ENV['HOME'],'.terminitor','test_foo_bar2.yml')) }.matches %r{- tab1}
45
60
  end
46
61
 
47
62
  context "for term" do
48
- setup { mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.term",nil) { true }.once }
49
- setup { capture(:stdout) { Terminitor::Cli.start(['edit','test_foo_bar2', '-s=term']) } }
63
+ setup do
64
+ capture(:stdout) do
65
+ mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.term",nil) { true }.once
66
+ Terminitor::Cli.start(['edit','test_foo_bar2', '-s=term'])
67
+ end
68
+ end
50
69
  asserts_topic.matches %r{create}
51
70
  asserts_topic.matches %r{test_foo_bar2.term}
52
71
  asserts("has term template") { File.read(File.join(ENV['HOME'],'.terminitor','test_foo_bar2.term')) }.matches %r{setup}
@@ -55,93 +74,107 @@ context "Terminitor" do
55
74
  end
56
75
 
57
76
  context "for Termfile" do
58
- setup { mock.instance_of(Terminitor::Cli).open_in_editor("/tmp/sample_project/Termfile",nil) { true }.once }
59
- setup { capture(:stdout) { Terminitor::Cli.start(['edit','-s=yml','-r=/tmp/sample_project']) } }
77
+ setup do
78
+ capture(:stdout) do
79
+ mock.instance_of(Terminitor::Cli).open_in_editor("/tmp/sample_project/Termfile",nil) { true }.once
80
+ Terminitor::Cli.start ['edit','-s=yml','-r=/tmp/sample_project']
81
+ end
82
+ end
60
83
  asserts_topic.matches %r{create}
61
84
  asserts_topic.matches %r{Termfile}
62
85
  asserts("has term template") { File.read('/tmp/sample_project/Termfile') }.matches %r{setup}
63
86
  end
64
87
 
65
- context "for editor flag" do
66
- setup { FileUtils.mkdir_p('/tmp/sample_project') }
67
- setup { mock.instance_of(Terminitor::Cli).open_in_editor('/tmp/sample_project/Termfile','nano') { true }.once }
68
- asserts("runs nano") { capture(:stdout) { Terminitor::Cli.start(['edit','-r=/tmp/sample_project','-c=nano']) } }
88
+ should "accept editor flag" do
89
+ FileUtils.mkdir_p('/tmp/sample_project')
90
+ capture(:stdout) do
91
+ mock.instance_of(Terminitor::Cli).open_in_editor('/tmp/sample_project/Termfile','nano') { true }.once
92
+ Terminitor::Cli.start(['edit','-r=/tmp/sample_project','-c=nano'])
93
+ end
69
94
  end
70
95
 
71
- context "for capture flag" do
72
- context "for yaml" do
73
- setup { capture(:stdout) { Terminitor::Cli.start(['edit','foobar', '-s=yml', '--capture']) } }
74
- asserts_topic.matches %r{Terminal settings can be captured only to DSL format.}
75
- end
96
+ context "for capture flag" do
97
+
98
+ asserts "yaml returns a message that" do
99
+ capture(:stdout) { Terminitor::Cli.start(['edit','foobar', '-s=yml', '--capture']) }
100
+ end.matches %r{Terminal settings can be captured only to DSL format.}
76
101
 
77
- context "for term" do
78
- context "with no core returned" do
79
- setup { mock.instance_of(Terminitor::Cli).capture_core(anything) { nil } }
80
- setup { FileUtils.touch("#{ENV['HOME']}/.terminitor/delete_this.term") }
81
- setup { capture(:stdout) { Terminitor::Cli.start(['edit', 'test_foo_bar2', '--capture']) } }
82
- asserts_topic.matches %r{No suitable core found!}
83
- end
102
+ context "for term" do
84
103
 
85
- context "for known core" do
86
- setup do
87
- core = Object.new
88
- mock.instance_of(Terminitor::Cli).capture_core(anything) { core }
89
- stub(core).new.stub!.capture_settings { "settings"}
90
- mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.term",nil) { true }
104
+ asserts "with no core returns a message that" do
105
+ capture(:stdout) do
106
+ mock.instance_of(Terminitor::Cli).capture_core(anything) { nil }
107
+ FileUtils.touch("#{ENV['HOME']}/.terminitor/delete_this.term")
108
+ Terminitor::Cli.start(['edit', 'test_foo_bar2', '--capture'])
91
109
  end
92
- asserts("ok") { Terminitor::Cli.start(['edit','test_foo_bar2', '--capture']) }
110
+ end.matches %r{No suitable core found!}
111
+
112
+
113
+ asserts "with core that it executes" do
114
+ mock.instance_of(Terminitor::Cli).capture_core(anything) { mock!.new.mock!.capture_settings { "settings"} }
115
+ mock.instance_of(Terminitor::Cli).open_in_editor("#{ENV['HOME']}/.terminitor/test_foo_bar2.term",nil) { true }
116
+ Terminitor::Cli.start(['edit','test_foo_bar2', '--capture'])
93
117
  end
118
+
94
119
  end
95
120
  end
96
121
 
97
122
  end
98
123
 
99
- context "create" do
100
- setup { mock.instance_of(Terminitor::Cli).invoke(:edit, [], 'root' => '/tmp/sample_project') { true }.once }
101
- asserts('calls open') { capture(:stdout) { Terminitor::Cli.start(['create','-r=/tmp/sample_project']) } }
102
- end
103
-
104
-
105
- context "open" do
106
- setup { mock.instance_of(Terminitor::Cli).invoke(:edit, [""], {'syntax' => 'term', 'root' => '/tmp/sample_project'}) { true }.once }
107
- setup { capture(:stdout) { Terminitor::Cli.start(['open','-r=/tmp/sample_project']) } }
108
- asserts_topic.matches %r{'open' is now deprecated. Please use 'edit' instead}
124
+ asserts "#create calls edit" do
125
+ capture(:stdout) do
126
+ mock.instance_of(Terminitor::Cli).invoke(:edit, [], 'root' => '/tmp/sample_project') { true }.once
127
+ Terminitor::Cli.start(['create','-r=/tmp/sample_project'])
128
+ end
109
129
  end
110
130
 
111
- context "delete" do
112
- context "directory Termfile" do
113
- setup { FileUtils.mkdir_p('/tmp/sample_project') }
114
- setup { FileUtils.touch("/tmp/sample_project/Termfile") }
115
- setup { capture(:stdout) { Terminitor::Cli.start(['delete',"-r=/tmp/sample_project"]) } }
116
- asserts("Termfile") { File.exists?("/tmp/sample_project/Termfile") }.not!
131
+ asserts "#open returns a message that" do
132
+ capture(:stdout) do
133
+ mock.instance_of(Terminitor::Cli).invoke(:edit, [""], {'syntax' => 'term', 'root' => '/tmp/sample_project'}) { true }.once
134
+ Terminitor::Cli.start(['open','-r=/tmp/sample_project'])
135
+ end
136
+ end.matches %r{'open' is now deprecated. Please use 'edit' instead}
137
+
138
+ context "#delete" do
139
+ denies "Termfile exists" do
140
+ FileUtils.mkdir_p '/tmp/sample_project'
141
+ FileUtils.touch "/tmp/sample_project/Termfile"
142
+ capture(:stdout) { Terminitor::Cli.start(['delete',"-r=/tmp/sample_project"]) }
143
+ File.exists? "/tmp/sample_project/Termfile"
117
144
  end
118
145
 
119
- context "for yaml" do
120
- setup { FileUtils.touch("#{ENV['HOME']}/.terminitor/delete_this.yml") }
121
- setup { capture(:stdout) { Terminitor::Cli.start(['delete','delete_this', '-s=yml']) } }
122
- asserts(" script") { File.exists?("#{ENV['HOME']}/.terminitor/delete_this.yml") }.not!
146
+ denies "yaml exists" do
147
+ FileUtils.touch "#{ENV['HOME']}/.terminitor/delete_this.yml"
148
+ capture(:stdout) { Terminitor::Cli.start(['delete','delete_this', '-s=yml']) }
149
+ File.exists? "#{ENV['HOME']}/.terminitor/delete_this.yml"
123
150
  end
124
151
 
125
- context "for term" do
126
- setup { FileUtils.touch("#{ENV['HOME']}/.terminitor/delete_this.term") }
127
- setup { capture(:stdout) { Terminitor::Cli.start(['delete','delete_this']) } }
128
- asserts("script") { File.exists?("#{ENV['HOME']}/.terminitor/delete_this.term") }.not!
152
+ denies "term exists" do
153
+ FileUtils.touch "#{ENV['HOME']}/.terminitor/delete_this.term"
154
+ capture(:stdout) { Terminitor::Cli.start(['delete','delete_this']) }
155
+ File.exists? "#{ENV['HOME']}/.terminitor/delete_this.term"
129
156
  end
130
157
  end
131
158
 
132
- context "setup" do
133
- setup { mock.instance_of(Terminitor::Cli).execute_core(:setup!,'project') {true } }
134
- asserts("calls execute_core") { Terminitor::Cli.start(['setup','project']) }
159
+ asserts "#setup calls #execute_core" do
160
+ capture(:stdout) do
161
+ mock.instance_of(Terminitor::Cli).execute_core(:setup!,'project') { true }
162
+ Terminitor::Cli.start(['setup','project'])
163
+ end
135
164
  end
136
165
 
137
166
 
138
- context "start" do
139
- setup { mock.instance_of(Terminitor::Cli).execute_core(:process!,'project') {true } }
140
- asserts("calls execute_core") { Terminitor::Cli.start(['start','project']) }
167
+ asserts "#start calls #execute_core" do
168
+ capture(:stdout) do
169
+ mock.instance_of(Terminitor::Cli).execute_core(:process!,'project') { true }
170
+ Terminitor::Cli.start(['start','project'])
171
+ end
141
172
  end
142
173
 
143
- context "fetch" do
144
- setup { mock.instance_of(Terminitor::Cli).github_repo('achiu','terminitor', 'root' => '.', 'setup' => true) { true } }
145
- asserts("run setup in project dir") { capture(:stdout) { Terminitor::Cli.start(['fetch','achiu','terminitor'])} }
174
+ asserts "#fetch runs setup in project diretory" do
175
+ capture(:stdout) do
176
+ mock.instance_of(Terminitor::Cli).github_repo('achiu','terminitor', 'root' => '.', 'setup' => true) { true }
177
+ Terminitor::Cli.start ['fetch','achiu','terminitor']
178
+ end
146
179
  end
147
180
  end
@@ -2,161 +2,155 @@ require File.expand_path('../../teststrap',__FILE__)
2
2
 
3
3
  if platform?("darwin") # Only run test if it's darwin
4
4
  context "MacCore" do
5
- # Stub out the initialization
6
5
  setup do
7
- terminal = Object.new
8
- stub(terminal).windows { true }
9
6
  any_instance_of(Terminitor::MacCore) do |core|
10
- stub(core).app('Terminal') { terminal }
11
- stub(core).load_termfile('/path/to') { true }
12
- end
7
+ stub(core).app('Terminal') { mock!.windows { true } }
8
+ stub(core).load_termfile('/path/to') { true }
9
+ end
10
+ @mac_core = Terminitor::MacCore.new('/path/to')
13
11
  end
14
- setup { @mac_core = Terminitor::MacCore.new('/path/to') }
15
12
 
16
- context "terminal_process" do
17
- setup do
18
- process = Object.new
19
- mock(process).application_processes { { "Terminal.app" => true } }
20
- mock(@mac_core).app('System Events') { process }
21
- end
22
- asserts("calls System Events") { @mac_core.terminal_process }
13
+ asserts "#terminal_process calls System Events" do
14
+ core = topic.dup
15
+ mock(core).app('System Events') { mock!.application_processes.returns("Terminal.app" => true) }
16
+ core.terminal_process
23
17
  end
24
18
 
25
- context "open_tab" do
26
- setup do
27
- process = Object.new
28
- mock(process).keystroke('t', :using => :command_down)
29
- mock(@mac_core).return_last_tab { true }
30
- mock(@mac_core).terminal_process { process }
19
+ context "#open_tab" do
20
+
21
+ should "return the last tab" do
22
+ core = topic.dup
23
+ mock(core).return_last_tab { true }
24
+ mock(core).terminal_process { mock!.keystroke('t', :using => :command_down) }
25
+ core.open_tab
31
26
  end
32
- asserts("returns last tab") { @mac_core.open_tab }
33
- end
34
-
35
- context "open_tab with options" do
36
- setup do
37
- process = Object.new
38
- mock(process).keystroke('t', :using => :command_down)
39
- mock(@mac_core).set_options(true, :option1 => '1', :option2 => '2')
40
- mock(@mac_core).return_last_tab.times(2) { true }
41
- mock(@mac_core).terminal_process { process }
27
+
28
+ should "return last tab with options" do
29
+ core = topic.dup
30
+ mock(core).set_options(true, :option1 => '1', :option2 => '2')
31
+ mock(core).return_last_tab.times(2) { true }
32
+ mock(core).terminal_process { mock!.keystroke('t', :using => :command_down) }
33
+ core.open_tab(:option1 => '1', :option2 => '2')
42
34
  end
43
- asserts("returns last tab") { @mac_core.open_tab(:option1 => '1', :option2 => '2') }
44
35
  end
45
36
 
46
- context "open_window" do
47
- setup do
48
- process = Object.new
49
- mock(process).keystroke('n', :using => :command_down)
50
- mock(@mac_core).return_last_tab { true }
51
- mock(@mac_core).terminal_process { process }
37
+ context "#open_window" do
38
+
39
+ should "return the last tab" do
40
+ core = topic.dup
41
+ mock(core).return_last_tab { true }
42
+ mock(core).terminal_process { mock!.keystroke('n', :using => :command_down) }
43
+ core.open_window
52
44
  end
53
- asserts("returns last tab") { @mac_core.open_window }
54
- end
55
45
 
56
- context "open_window with options" do
57
- setup do
58
- process = Object.new
59
- window = Object.new
60
- tab = Object.new
61
- mock(process).keystroke('n', :using => :command_down)
62
- mock(@mac_core).set_options(window, :bounds => '1')
63
- mock(@mac_core).set_options(tab, :settings => "2")
64
- mock(@mac_core).active_window { window }
65
- mock(@mac_core).return_last_tab { tab }.times(2)
66
- mock(@mac_core).terminal_process { process }
46
+ should "open window with options" do
47
+ core, window, tab = topic.dup, stub!, stub!
48
+ mock(core).set_options(window, :bounds => '1')
49
+ mock(core).set_options(tab, :settings => "2")
50
+ mock(core).active_window { window }
51
+ mock(core).return_last_tab { tab }.times(2)
52
+ mock(core).terminal_process { mock!.keystroke('n', :using => :command_down) }
53
+ core.open_window :bounds => '1', :settings => '2'
67
54
  end
68
- asserts("opens window with options") { @mac_core.open_window(:bounds => '1', :settings => '2')}
69
55
  end
70
-
71
- context "return_last_tab" do
72
- setup do
73
- window = Object.new
74
- tab = Object.new
75
- mock(tab).get { true }
76
- mock(window).tabs { [tab] }
77
- mock(@mac_core).active_window { window }
78
- end
79
- asserts("returns tab") { @mac_core.return_last_tab }
56
+
57
+ asserts "#return_last_tab returns the last tab" do
58
+ core, tab = topic.dup, mock!
59
+ mock(tab).get { true }
60
+ mock(core).active_window { mock!.tabs.returns([tab]) }
61
+ core.return_last_tab
80
62
  end
81
63
 
82
- context "execute_command" do
83
- setup do
84
- window = Object.new
85
- mock(window).do_script("hasta", :in => :la_vista) { true }
86
- mock(@mac_core).active_window { window }
87
- end
88
- asserts("baby") { @mac_core.execute_command('hasta', :in => :la_vista) }
64
+ asserts "#execute_command executes" do
65
+ core = topic.dup
66
+ mock(core).active_window { mock!.do_script("hasta", :in => :la_vista).returns(true) }
67
+ core.execute_command('hasta', :in => :la_vista)
89
68
  end
90
69
 
91
- context "active_window" do
92
- setup do
93
- terminal, windows, window, app_object = 4.times.collect { Object.new } # holy mother of somebody.
94
- stub(app_object).get { {:frontmost => true} }
95
- stub(window).properties_ { app_object }
96
- stub(windows).get { [window] }
97
- stub(terminal).windows { windows }
98
- any_instance_of(Terminitor::MacCore) do |core|
99
- stub(core).app('Terminal') { terminal }
100
- stub(core).load_termfile('/path/to') { true }
101
- end
70
+ asserts "#active_window gives window" do
71
+ window, app_object = Object.new, Object.new
72
+ mock(app_object).get { {:frontmost => true} }
73
+ mock(window).properties_ { app_object }
74
+ any_instance_of(Terminitor::MacCore) do |core|
75
+ stub(core).app('Terminal') { stub!.windows { stub!.get.returns([window]) } }
76
+ stub(core).load_termfile('/path/to') { true }
102
77
  end
103
- asserts("gives me window") { Terminitor::MacCore.new('/path/to').active_window }
78
+ Terminitor::MacCore.new('/path/to').active_window
104
79
  end
105
-
80
+
81
+
106
82
  context "set_options" do
107
83
  setup do
108
- @object, @terminal, @windows= 3.times.collect { Object.new }
84
+ @object, @terminal, @windows= 3.times.collect { Object.new }
85
+ stub(@terminal).windows { @windows }
109
86
  any_instance_of(Terminitor::MacCore) do |core|
110
- stub(core).app('Terminal') { @terminal }
111
- stub(core).load_termfile('/path/to') { true }
87
+ stub(core).app('Terminal') { @terminal }
88
+ stub(core).load_termfile('/path/to') { true }
112
89
  end
113
- stub(@terminal).windows { @windows }
114
90
  end
115
91
 
116
- context "valid settings set" do
117
- setup do
118
- stub(@terminal).settings_sets {{:valid_settings => true}}
119
- stub(@object).current_settings.stub!.set(anything) { true }
120
- end
121
- asserts("applies known settings set") { Terminitor::MacCore.new('/path/to').set_options(@object, :settings => :valid_settings)}
122
- end
123
-
124
- context "invalid settings set" do
125
- setup do
92
+ should "apply known valid settings" do
93
+ stub(@terminal).settings_sets { { :valid_settings => true } }
94
+ stub(@object).current_settings.stub!.set(anything) { true }
95
+ Terminitor::MacCore.new('/path/to').set_options(@object, :settings => :valid_settings)
96
+ end
97
+
98
+ context "invalid settings" do
99
+ should "return a error message that" do
126
100
  stub(@terminal).settings_sets {{:invalid_settings => true}}
127
101
  stub(Object).raise
128
102
  stub(@object).current_settings.stub!.set(anything) { raise Appscript::CommandError.new("code","error","object","reference", "command") }
129
- end
130
- setup { capture(:stdout) {Terminitor::MacCore.new('/path/to').set_options(@object, :settings => :invalid_settings)}}
131
- asserts_topic.matches %r{invalid settings set}
103
+ capture(:stdout) { Terminitor::MacCore.new('/path/to').set_options(@object, :settings => :invalid_settings) }
104
+ end.matches %r{Error: invalid settings}
132
105
  end
133
-
134
- context "bounds" do
135
- setup do
136
- setup { stub(@object).bounds.stub!.set(true) }
137
- setup { stub(@object).frame.stub!.set(true) }
138
- setup { stub(@object).position.stub!.set(true) }
139
- end
140
- asserts("sets bounds") { Terminitor::MacCore.new('/path/to').set_options(@object, :bounds => true)}
106
+
107
+ context "name option" do
108
+ should "ignore :name" do
109
+ capture(:stdout) { Terminitor::MacCore.new('/path/to').set_options(@object, :name => 'hihi') }
110
+ end.matches ""
111
+ end
112
+
113
+ context "bounds" do
114
+
115
+ should "set bounds" do
116
+ stub(@object).bounds.stub!.set(true)
117
+ stub(@object).frame.stub!.set(true)
118
+ stub(@object).position.stub!.set(true)
119
+ Terminitor::MacCore.new('/path/to').set_options(@object, :bounds => true)
120
+ end
121
+
141
122
  end
142
123
 
143
- context "unknown option" do
144
- setup do
124
+ context "unknown option" do
125
+
126
+ should "return a message" do
145
127
  stub(Object).raise
146
128
  stub(@object).unknown_option.stub!.set(anything) { raise Appscript::CommandError.new("code","error","object","reference", "command") }
147
- end
148
- setup { capture(:stdout) { Terminitor::MacCore.new('/path/to').set_options(@object, :unknown_option => true)}}
149
- asserts_topic.matches %r{Error}
129
+ capture(:stdout) { Terminitor::MacCore.new('/path/to').set_options(@object, :unknown_option => true)}
130
+ end.matches %r{Error}
131
+
150
132
  end
151
133
 
152
- context "delayed option" do
153
- setup do
154
- setup { Terminitor::MacCore.new('/path/to').set_options(@object, :selected => true) }
155
- stub(@object).selected.stub!.set(true)
134
+ context "selected" do
135
+ should "set :selected" do
136
+ mock(@object).selected.mock!.set(true)
137
+ core = Terminitor::MacCore.new('/path/to')
138
+ core.set_options(@object, :selected => true)
139
+ core.set_delayed_options
140
+ end
141
+ end
142
+
143
+ context "miniaturized" do
144
+ should "set :miniaturized" do
145
+ mock(@object).miniaturized.mock!.set(true)
146
+ core = Terminitor::MacCore.new('/path/to')
147
+ core.set_options(@object, :miniaturized => true)
148
+ core.set_delayed_options
156
149
  end
157
- asserts("sets delayed options") { @mac_core.set_delayed_options }
158
150
  end
151
+
159
152
  end
153
+
160
154
  end
161
155
  else
162
156
  context "MacCore" do