Commit 65ba05c3 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Using heredoc syntax in tests.

parent 3bbcc3dc
Loading
Loading
Loading
Loading
+122 −119
Original line number Diff line number Diff line
@@ -131,11 +131,12 @@ describe JsDuck::Aggregator do

  describe "explicit @method without @param-s" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * @method foo
         * Some function
 */")[0]
         */
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "no parameters"
@@ -144,13 +145,14 @@ describe JsDuck::Aggregator do

  describe "explicit @method with @param-s" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * @method foo
         * Some function
         * @param {String} x First parameter
         * @param {Number} y Second parameter
 */")[0]
         */
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "two parameters"
@@ -161,13 +163,14 @@ describe JsDuck::Aggregator do

  describe "explicit @method after @params-s" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @param {String} x First parameter
         * @param {Number} y Second parameter
         * @method foo
 */")[0]
         */
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "two parameters"
@@ -178,7 +181,7 @@ describe JsDuck::Aggregator do

  describe "explicit @method with @param-s overriding implicit code" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @param {String} x First parameter
@@ -186,7 +189,7 @@ describe JsDuck::Aggregator do
         * @method foo
         */
        function bar(q, z) {}
")[0]
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "two parameters"
@@ -196,13 +199,13 @@ function bar(q, z) {}

  describe "@param-s partially overriding implicit params" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @param {String} x
         */
        function foo(q, y) {}
")[0]
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "two parameters"
@@ -210,14 +213,14 @@ function foo(q, y) {}

  describe "@param-s declaring only types" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @param {String}
         * @param {Number}
         */
        function foo(x, y) {}
")[0]
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "two parameters"
@@ -226,13 +229,13 @@ function foo(x, y) {}

  describe "@return documenting return value" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @return {String} return value
         */
        function foo() {}
")[0]
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "has return"
@@ -240,13 +243,13 @@ function foo() {}

  describe "@returns being alias for @return" do
    before do
      @doc = parse("
      @doc = parse(<<-EOS)[0]
        /**
         * Some function
         * @returns {String} return value
         */
        function foo() {}
")[0]
      EOS
    end
    it_should_behave_like "method documentation"
    it_should_behave_like "has return"
@@ -254,10 +257,10 @@ function foo() {}

  describe "method without doc-comment" do
    before do
      @docs = parse("
      @docs = parse(<<-EOS)
        // My comment
        function foo(x, y) {}
")
      EOS
    end
    it "remains undocumented" do
      @docs.length.should == 0
@@ -267,17 +270,17 @@ function foo(x, y) {}
  describe "@member" do

    it "defines the class where item belongs" do
      items = parse("
      items = parse(<<-EOS)
        /**
         * @cfg foo
         * @member Bar
         */
")
      EOS
      items[0][:member].should == "Bar"
    end

    it "forces item to be moved into that class" do
      items = parse("
      items = parse(<<-EOS)
        /**
         * @class Bar
         */
@@ -288,13 +291,13 @@ function foo(x, y) {}
         * @cfg foo
         * @member Bar
         */
")
      EOS
      items[0][:cfg].length.should == 1
      items[1][:cfg].length.should == 0
    end

    it "even when @member comes before the class itself" do
      items = parse("
      items = parse(<<-EOS)
        /**
         * @cfg foo
         * @member Bar
@@ -302,14 +305,14 @@ function foo(x, y) {}
        /**
         * @class Bar
         */
")
      EOS
      items[0][:cfg].length.should == 1
    end
  end

  describe "one class many times" do
    before do
      @classes = parse("
      @classes = parse(<<-EOS)
        /**
         * @class Foo
         * @cfg c1
@@ -339,7 +342,7 @@ function foo(x, y) {}
          /** @method fun3 */
          /** @event eve3 */
          /** @property prop3 */
")
      EOS
    end

    it "results in only one class" do