spec/cukedep/cli/cmd-line_spec.rb in cukedep-0.1.10 vs spec/cukedep/cli/cmd-line_spec.rb in cukedep-0.1.11
- old
+ new
@@ -1,50 +1,49 @@
# File: cmd-line_spec.rb
require 'stringio'
+require 'English'
require_relative '../../spec_helper'
# Load the class under testing
require_relative '../../../lib/cukedep/cli/cmd-line'
module Cukedep # Open module to get rid of long qualified names
-
describe CLI::CmdLine do
-
context 'Creation & initialization:' do
subject { CLI::CmdLine.new }
it 'should be created without argument' do
expect { CLI::CmdLine.new }.not_to raise_error
end
end # context
context 'Provided services:' do
def capture_output()
- @output = $>
+ @output = $DEFAULT_OUTPUT
ostream = StringIO.new('rw')
- $> = ostream
+ $DEFAULT_OUTPUT = ostream
end
def release_output()
- $> = @output
+ $DEFAULT_OUTPUT = @output
end
it 'should accept an empty command-line' do
expect { subject.parse!([]) }.not_to raise_error
expect(subject.options).to be_empty
end
it 'should accept the dry-run option' do
expect { subject.parse!(['--dry-run']) }.not_to raise_error
- expect(subject.options).to eq({ :dryrun => true })
+ expect(subject.options).to eq(dryrun: true)
end
it 'should accept the setup option' do
expect { subject.parse!(['--setup']) }.not_to raise_error
- expect(subject.options).to eq({ :setup => true })
+ expect(subject.options).to eq(setup: true)
end
it 'should validate the project option argument' do
# Case 1: missing project dir argument
cmd_opts = ['--project']
@@ -60,32 +59,30 @@
cmd_opts = ['--project', 'nowhere']
err_msg = "Cannot find the directory 'nowhere'."
expect { subject.parse!(cmd_opts) }.to raise_error(err_type, err_msg)
# Case 3: project dir exists
- #cmd_opts = ['--project', '../../../sample']
- #expect { subject.parse!(cmd_opts) }.not_to raise_error
- #expect(subject.options).to eq({ :project => '../../../sample' })
+ # cmd_opts = ['--project', '../../../sample']
+ # expect { subject.parse!(cmd_opts) }.not_to raise_error
+ # expect(subject.options).to eq({ :project => '../../../sample' })
end
it 'should handle the version option' do
capture_output
cmd_opts = ['--version']
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
- expect($>.string).to eq(Cukedep::Version + "\n")
+ expect($DEFAULT_OUTPUT.string).to eq(Cukedep::Version + "\n")
release_output
end
it 'should handle the help option' do
capture_output
cmd_opts = ['--help']
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
- expect($>.string).to eq(subject.parser.to_s)
+ expect($DEFAULT_OUTPUT.string).to eq(subject.parser.to_s)
release_output
end
end # context
-
-
-
end # describe
+end # module
-end # module
\ No newline at end of file
+# End of file