Sha256: b9b894ab95bd486cd1b9c6d6da52bb754c3a91072735b83872125c234c137265
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe Simplabs::Excellent::Checks::ParameterNumberCheck do before(:each) do @excellent = Simplabs::Excellent::Core::ParseTreeRunner.new(Simplabs::Excellent::Checks::ParameterNumberCheck.new({ :threshold => 1 })) end describe '#evaluate' do it 'should accept methods with less parameters than the threshold' do content = <<-END def zero_parameter_method end END @excellent.check_content(content) @excellent.errors.should be_empty end it 'should accept methods with the same number of parameters as the threshold' do content = <<-END def one_parameter_method(first_parameter) end END @excellent.check_content(content) @excellent.errors.should be_empty end it 'should reject methods with more parameters than the threshold' do content = <<-END def two_parameter_method(first_parameter, second_parameter) end END verify_error_found(content) end it 'should cope with default values on parameters' do content = <<-END def two_parameter_method(first_parameter = 1, second_parameter = 2) end END verify_error_found(content) end end def verify_error_found(content) @excellent.check_content(content) errors = @excellent.errors errors.should_not be_empty errors[0].info.should == { :method => :two_parameter_method, :parameter_count => 2 } errors[0].line_number.should == 1 errors[0].message.should == 'Method two_parameter_method has 2 parameters.' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simplabs-excellent-1.0.0 | spec/checks/parameter_number_check_spec.rb |
simplabs-excellent-1.0.1 | spec/checks/parameter_number_check_spec.rb |