test/test_helper.rb in inch-0.1.3 vs test/test_helper.rb in inch-0.1.4

- old
+ new

@@ -23,5 +23,85 @@ old_dir = Dir.pwd Dir.chdir fixture_path(name) yield Dir.chdir old_dir end + + +module BaseListTests + def self.included(other) + other.instance_eval do + # these tests are added when BaseListTests is included inside a + # `describe` block + + it "should give error when run with --unknown-switch" do + out, err = capture_io do + assert_raises(SystemExit) { @command.run("lib/foo.rb", "--unknown-switch") } + end + end + + it "should run with --depth switch" do + out, err = capture_io do + @command.run("lib/foo.rb", "--depth=2") + end + refute out.empty?, "there should be some output" + assert err.empty?, "there should be no errors" + assert_match /\bFoo\b/, out + assert_match /\bFoo::Bar\b/, out + refute_match /\bFoo::Bar#method_with_full_doc\b/, out + refute_match /\bFoo::Bar#method_with_code_example\b/, out + end + + it "should run with --only-namespaces switch" do + out, err = capture_io do + @command.run("lib/foo.rb", "--only-namespaces") + end + refute out.empty?, "there should be some output" + assert err.empty?, "there should be no errors" + assert_match /\bFoo\s/, out + assert_match /\bFoo::Bar\s/, out + refute_match /\bFoo::Bar\./, out + refute_match /\bFoo::Bar#/, out + end + + it "should run with --no-namespaces switch" do + out, err = capture_io do + @command.run("lib/foo.rb", "--no-namespaces") + end + refute out.empty?, "there should be some output" + assert err.empty?, "there should be no errors" + refute_match /\bFoo\s/, out + refute_match /\bFoo::Bar\s/, out + assert_match /\bFoo::Bar#/, out + end + + + it "should run with --only-undocumented switch" do + skip + out, err = capture_io do + @command.run("lib/foo.rb", "--all", "--only-undocumented") + end + refute out.empty?, "there should be some output" + assert err.empty?, "there should be no errors" + refute_match /\bFoo\s/, out + refute_match /\bFoo::Bar#method_with_full_doc\b/, out + assert_match /\bFoo::Bar\s/, out + assert_match /\bFoo::Bar#method_without_doc\b/, out + end + + it "should run with --no-undocumented switch" do + skip + out, err = capture_io do + @command.run("lib/foo.rb", "--all", "--no-undocumented") + end + refute out.empty?, "there should be some output" + assert err.empty?, "there should be no errors" + assert_match /\bFoo\s/, out + assert_match /\bFoo::Bar#method_with_full_doc\b/, out + refute_match /\bFoo::Bar\s/, out + refute_match /\bFoo::Bar#method_without_doc\b/, out + end + + + end + end +end \ No newline at end of file