Sha256: 82c57447d3514d7b165db0d26b1eb2946e1b18786f52a1c9333a7bf6de71d44f

Contents?: true

Size: 1.26 KB

Versions: 17

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

module RailsBestPractices
  module Reviews
    describe UseParenthesesInMethodDefReview do
      let(:runner) { Core::Runner.new(reviews: UseParenthesesInMethodDefReview.new) }

      it "should find missing parentheses" do
        content = <<-EOF
        class PostsController < ApplicationController
          def edit foo, bar
          end
        end
        EOF
        runner.review('app/controllers/posts_controller.rb', content)
        runner.should have(1).errors
        runner.errors[0].to_s.should == "app/controllers/posts_controller.rb:2 - use parentheses around parameters in method definitions"
      end
      it "should find parentheses with no error" do
        content = <<-EOF
        class PostsController < ApplicationController
          def edit(foo, bar)
          end
        end
        EOF
        runner.review('app/controllers/posts_controller.rb', content)
        runner.should have(0).errors
      end
      it "should not throw an error without parameters" do
        content = <<-EOF
        class PostsController < ApplicationController
          def edit
          end
        end
        EOF
        runner.review('app/controllers/posts_controller.rb', content)
        runner.should have(0).errors
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rails_best_practices-1.14.4 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.14.3 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.14.2 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.14.1 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.14.0 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.8 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.5 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.4 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.3 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.2 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.1 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.13.0 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.12.0 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.11.1 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.11.0 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.10.1 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb
rails_best_practices-1.10.0 spec/rails_best_practices/reviews/use_parenthesis_in_method_def_spec.rb