test/integration/visibility_options_test.rb in inch-0.1.3 vs test/integration/visibility_options_test.rb in inch-0.1.4

- old
+ new

@@ -1,79 +1,86 @@ require File.expand_path(File.dirname(__FILE__) + '/../test_helper') -# -# Tests with the YARD specific --no-public, --no-protected and --private -# switches can't be run in one test instance. The flags seem to add up after -# being called. In combination with a random test order this resulted in ever -# different failure outputs. -# -# Therefore, here are some integration tests: -# -describe ::Inch::CLI::Command::List do +describe ::Inch::CLI::Command do before do Dir.chdir fixture_path(:visibility) - @command = "bundle exec inch list" + @command = ::Inch::CLI::Command::List end it "should run without visibility switches" do - out = %x|#{@command} --all| + out, err = capture_io do + @command.run("--all") + end refute out.empty?, "there should be some output" assert_match /\bFoo#public_method\b/, out assert_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has @private tag end it "should run with --no-protected switch" do - out = %x|#{@command} --all --no-protected| + out, err = capture_io do + @command.run("--all", "--no-protected") + end refute out.empty?, "there should be some output" assert_match /\bFoo#public_method\b/, out refute_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has @private tag end it "should run with --no-public switch" do - out = %x|#{@command} --all --no-public| + out, err = capture_io do + @command.run(*%w|--all --no-public|) + end refute out.empty?, "there should be some output" refute_match /\bFoo#public_method\b/, out assert_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has @private tag end it "should run with --no-public --no-protected switch" do - out = %x|#{@command} --all --no-public --no-protected| + out, err = capture_io do + @command.run(*%w|--all --no-public --no-protected|) + end assert out.empty?, "there should be no output" refute_match /\bFoo#public_method\b/, out refute_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has a @private tag, but is really :public end it "should run with --no-public --no-protected --private switch" do - out = %x|#{@command} --all --no-public --no-protected --private| + out, err = capture_io do + @command.run(*%w|--all --no-public --no-protected --private|) + end refute out.empty?, "there should be some output" refute_match /\bFoo#public_method\b/, out refute_match /\bFoo#protected_method\b/, out assert_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has a @private tag, but is really :public end it "should run with --no-public switch" do - out = %x|#{@command} --all --no-public| + out, err = capture_io do + @command.run(*%w|--all --no-public|) + end refute out.empty?, "there should be some output" refute_match /\bFoo#public_method\b/, out assert_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has a @private tag, but is really :public end it "should run with --no-protected switch" do - out = %x|#{@command} --all --no-protected| + out, err = capture_io do + @command.run(*%w|--all --no-protected|) + end refute out.empty?, "there should be some output" assert_match /\bFoo#public_method\b/, out refute_match /\bFoo#protected_method\b/, out refute_match /\bFoo#private_method\b/, out # has @private tag refute_match /\bFoo#method_with_private_tag\b/, out # has a @private tag, but is really :public end + end