test/unit/language/ruby/provider/yard/docstring_test.rb in inch-0.5.0.rc5 vs test/unit/language/ruby/provider/yard/docstring_test.rb in inch-0.5.0.rc6

- old
+ new

@@ -1,15 +1,15 @@ -require File.expand_path(File.dirname(__FILE__) + "/../../../../../test_helper") +require File.expand_path(File.dirname(__FILE__) + '/../../../../../test_helper') describe ::Inch::Language::Ruby::Provider::YARD::Docstring do let(:described_class) { ::Inch::Language::Ruby::Provider::YARD::Docstring } # # loose TomDoc compatibility # - it "should notice things in tomdoc style docs" do + it 'should notice things in tomdoc style docs' do text = <<-DOC Internal: Detects the Language of the blob. param1 - String filename param2 - String blob data. A block also maybe passed in for lazy @@ -30,11 +30,11 @@ refute docstring.contains_code_example? assert docstring.mentions_return? assert docstring.describes_return? end - it "should notice things in tomdoc style docs 2" do + it 'should notice things in tomdoc style docs 2' do text = <<-DOC Public: Look up Language by one of its aliases. param1 - A String alias of the Language @@ -53,11 +53,11 @@ assert docstring.contains_code_example? assert docstring.mentions_return? assert docstring.describes_return? end - it "should notice multi-line returns in tomdoc style docs" do + it 'should notice multi-line returns in tomdoc style docs' do text = <<-DOC Public: Look up Language by one of its aliases. Returns the Lexer or nil if none was found. @@ -65,11 +65,11 @@ docstring = described_class.new(text) assert docstring.mentions_return? assert docstring.describes_return? end - it "should notice multi-line returns in tomdoc style docs 2" do + it 'should notice multi-line returns in tomdoc style docs 2' do text = <<-DOC Public: Look up Language by one of its aliases. Returns the Lexer or nil if none @@ -78,11 +78,11 @@ docstring = described_class.new(text) assert docstring.mentions_return? assert docstring.describes_return? end - it "should notice things in tomdoc style docs 3" do + it 'should notice things in tomdoc style docs 3' do text = <<-DOC Public: Look up Language by one of its aliases. param1 - A String alias of the Language @@ -138,32 +138,32 @@ docstring = described_class.new(text) assert docstring.describes_return? end it "should understand 'Returns ...' with a visibility modifier in front of" \ - " it" do - text = "Public: Returns the Integer color." + ' it' do + text = 'Public: Returns the Integer color.' docstring = described_class.new(text) assert docstring.mentions_return? assert docstring.describes_return? end # # PARAMETER MENTIONS # - it "should work 2" do + it 'should work 2' do text = <<-DOC Just because format_html is mentioned here, does not mean the first parameter is mentioned. DOC docstring = described_class.new(text) refute docstring.mentions_parameter?(:format) refute docstring.contains_code_example? end - it "should work 2 if correct" do + it 'should work 2 if correct' do text = <<-DOC Just because format is mentioned here, does not mean the first parameter is meant. DOC docstring = described_class.new(text) @@ -173,11 +173,11 @@ # # CODE EXAMPLES # - it "should work 3" do + it 'should work 3' do text = <<-DOC An example of a method using RDoc rather than YARD. == Parameters: param1:: @@ -188,48 +188,52 @@ DOC docstring = described_class.new(text) refute docstring.contains_code_example? end - it "should work with code example" do + it 'should work with code example' do + # rubocop:disable Metrics/LineLength text = <<-DOC Another example. method_with_code_example() # => some value Params: +param1+:: param1 line string to be executed by the system +param2+:: +Proc+ object that takes a pipe object as first and only param (may be nil) +param3+:: +Proc+ object that takes a pipe object as first and only param (may be nil) DOC + # rubocop:enable Metrics/LineLength docstring = described_class.new(text) assert docstring.contains_code_example? assert docstring.mentions_parameter?(:param1) assert docstring.mentions_parameter?(:param2) assert docstring.mentions_parameter?(:param3) assert docstring.describes_parameter?(:param1) assert docstring.describes_parameter?(:param2) assert docstring.describes_parameter?(:param3) end - it "should recognize several parameter notations" do + it 'should recognize several parameter notations' do + # rubocop:disable Metrics/LineLength text = <<-DOC Params: +param1<String>+:: param1 line string to be executed by the system +param2<String,nil>+:: +Proc+ object that takes a pipe object as first and only param (may be nil) +param3<String|Class>+:: +Proc+ object that takes a pipe object as first and only param (may be nil) DOC + # rubocop:enable Metrics/LineLength docstring = described_class.new(text) - assert docstring.mentions_parameter?(:param1), "should mention param1" - assert docstring.mentions_parameter?(:param2), "should mention param2" - assert docstring.mentions_parameter?(:param3), "should mention param3" - assert docstring.describes_parameter?(:param1), "should describe param1" - assert docstring.describes_parameter?(:param2), "should describe param2" - assert docstring.describes_parameter?(:param3), "should describe param3" + assert docstring.mentions_parameter?(:param1), 'should mention param1' + assert docstring.mentions_parameter?(:param2), 'should mention param2' + assert docstring.mentions_parameter?(:param3), 'should mention param3' + assert docstring.describes_parameter?(:param1), 'should describe param1' + assert docstring.describes_parameter?(:param2), 'should describe param2' + assert docstring.describes_parameter?(:param3), 'should describe param3' end - it "should work with code example 2" do + it 'should work with code example 2' do text = <<-DOC Just because format_html is mentioned here, does not mean the first parameter is mentioned. method_with_code_example() # => some value @@ -238,11 +242,11 @@ docstring = described_class.new(text) assert docstring.contains_code_example? assert_equal 1, docstring.code_examples.size end - it "should work with code example 3" do + it 'should work with code example 3' do text = <<-DOC An example of a method using RDoc rather than YARD. method_with_code_example() # => some value @@ -258,11 +262,11 @@ assert_equal 1, docstring.code_examples.size assert docstring.mentions_parameter?(:param1) assert docstring.describes_parameter?(:param1) end - it "should work with multiple code examples" do + it 'should work with multiple code examples' do text = <<-DOC An example of a method using RDoc rather than YARD. method_with_code_example() # => some value @@ -279,8 +283,8 @@ A string in the specified format. DOC docstring = described_class.new(text) assert docstring.contains_code_example? assert_equal 2, docstring.code_examples.size - assert docstring.code_examples.last.index("create_index! 2") + assert docstring.code_examples.last.index('create_index! 2') end end