Skip to content

Commit 04658f1

Browse files
chrisseatoneregon
authored andcommitted
Improve specs for -C and -X
1 parent d082eea commit 04658f1

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

command_line/dash_upper_c_spec.rb

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
require_relative '../spec_helper'
2+
require_relative 'shared/change_directory'
23

3-
describe 'The -C command line option' do
4-
before :all do
5-
@script = fixture(__FILE__, 'dash_upper_c_script.rb')
6-
@tempdir = File.dirname(@script)
7-
end
8-
9-
it 'changes the PWD when using a file' do
10-
output = ruby_exe(@script, options: "-C #{@tempdir}")
11-
output.should == @tempdir
12-
end
13-
14-
it 'does not need a space after -C for the argument' do
15-
output = ruby_exe(@script, options: "-C#{@tempdir}")
16-
output.should == @tempdir
17-
end
18-
19-
it 'changes the PWD when using -e' do
20-
output = ruby_exe(nil, options: "-C #{@tempdir} -e 'print Dir.pwd'")
21-
output.should == @tempdir
22-
end
4+
describe "The -C command line option" do
5+
it_behaves_like :command_line_change_directory, "-C"
236
end

command_line/dash_upper_x_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require_relative '../spec_helper'
2+
require_relative 'shared/change_directory'
3+
4+
describe "The -X command line option" do
5+
it_behaves_like :command_line_change_directory, "-X"
6+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
describe :command_line_change_directory, shared: true do
2+
before :all do
3+
@script = fixture(__FILE__, 'change_directory_script.rb')
4+
@tempdir = File.dirname(@script)
5+
end
6+
7+
it 'changes the PWD when using a file' do
8+
output = ruby_exe(@script, options: "#{@method} #{@tempdir}")
9+
output.should == @tempdir
10+
end
11+
12+
it 'does not need a space after -C for the argument' do
13+
output = ruby_exe(@script, options: "#{@method}#{@tempdir}")
14+
output.should == @tempdir
15+
end
16+
17+
it 'changes the PWD when using -e' do
18+
output = ruby_exe(nil, options: "#{@method} #{@tempdir} -e 'print Dir.pwd'")
19+
output.should == @tempdir
20+
end
21+
end

0 commit comments

Comments
 (0)