Skip to content

Commit

Permalink
(PDOC-37) Refactor and add additional tests
Browse files Browse the repository at this point in the history
All according to Henrik's comments on the GitHub PR.
  • Loading branch information
iankronquist committed Jul 10, 2015
1 parent 44da7e1 commit ee73970
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def max(num_a, num_b)
}.to output("#{expected_output_not_a_param}\n#{expected_output_also_not_a_param}\n").to_stdout_from_any_process
end


it "should not issue a warning if the parameter names do match the docstring" do
it "should not issue a warning when the parameter names match the docstring" do
expect {
parse <<-RUBY
# @param num_a [Integer] the first number to be compared
Expand All @@ -87,10 +86,38 @@ def max(num_a, num_b)
}.to output("").to_stdout_from_any_process
end

it "should not issue a warning when there are parametarized types and parameter names are the same" do
expect {
parse <<-RUBY
# @param num_a Integer[1,2] the first number to be compared
# @param num_b Integer[1,2] the second number to be compared
Puppet::Functions.create_function(:max) do
def max(num_a, num_b)
num_a >= num_b ? num_a : num_b
end
end
RUBY
}.to output("").to_stdout_from_any_process
end

it "should issue a warning when there are parametarized types and parameter names differ" do
expected_output_not_num_a = "[warn]: @param tag has unknown parameter" +
" name: not_num_a \n in file `(stdin)' near line 3"
expect {
parse <<-RUBY
# @param not_num_a Integer[1,2] the first number to be compared
# @param num_b Integer[1,2] the second number to be compared
Puppet::Functions.create_function(:max) do
def max(num_a, num_b)
num_a >= num_b ? num_a : num_b
end
end
RUBY
}.to output("#{expected_output_not_num_a}\n").to_stdout_from_any_process
end


it "should issue a warning if the parameter names do not match the " +
"docstring in dispatch method" do
it "should issue a warning if the parameter names do not match the docstring in dispatch method" do
expected_output_not_a_param = "[warn]: @param tag has unknown parameter" +
" name: not_a_param \n in file `(stdin)' near line 3"
expected_output_also_not_a_param = "[warn]: @param tag has unknown " +
Expand Down

0 comments on commit ee73970

Please sign in to comment.