Skip to content

Commit

Permalink
Add tests for the version command line option
Browse files Browse the repository at this point in the history
  • Loading branch information
aia committed Jan 23, 2012
1 parent 1811afc commit 961fc26
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/jeweler/generator/test_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ def self.should_exit_with_code(code)
end
end


context "when options indicate version" do
setup do
stub(Jeweler::Generator::Application).build_opts do
stub_options(:show_version => true)
end

stub(Jeweler::Generator).new { raise "Shouldn't have made this far"}

assert_nothing_raised do
@result = run_application("-v")
end
end

should_exit_with_code 1

should 'should puts option version' do
assert_match 'Version:', @stderr
end
end


context "when options indicate help usage" do
setup do
stub(Jeweler::Generator::Application).build_opts do
Expand Down
12 changes: 12 additions & 0 deletions test/jeweler/generator/test_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ def self.for_options(*options)
assert_equal 'foo', @options[:directory]
end
end

for_options '--version' do
should 'show version' do
assert @options[:show_version]
end
end

for_options '-v' do
should 'show version' do
assert @options[:show_version]
end
end

for_options '--help' do
should 'show help' do
Expand Down

0 comments on commit 961fc26

Please sign in to comment.