Sha256: 7c9a75661c07acfa4c2ba56b9c78f811952c2041f6ca3a83ec267645b351c422

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Simplabs::Excellent::Checks::Rails::ParamsHashInViewCheck do

  before do
    @excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::Rails::ParamsHashInViewCheck.new)
  end

  describe '#evaluate' do

    it 'should accept views that do not use the params hash' do
      code = <<-END
        <div>
          <%= 'some text' %>
        </div>
      END
      @excellent.check('dummy-file.html.erb', code)
      warnings = @excellent.warnings

      warnings.should be_empty
    end

    it 'should reject views that use the params hash' do
      code = <<-END
        <div>
          <%= params[:q] %>
        </div>
      END
      @excellent.check('dummy-file.html.erb', code)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == {}
      warnings[0].line_number.should == 2
      warnings[0].message.should     == 'Params hash used in view.'
    end

  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
simplabs-excellent-1.5.2 spec/checks/rails/params_hash_in_view_check_spec.rb
simplabs-excellent-1.5.3 spec/checks/rails/params_hash_in_view_check_spec.rb
excellent-1.7.2 spec/checks/rails/params_hash_in_view_check_spec.rb
excellent-1.7.1 spec/checks/rails/params_hash_in_view_check_spec.rb
excellent-1.7.0 spec/checks/rails/params_hash_in_view_check_spec.rb
excellent-1.6.0 spec/checks/rails/params_hash_in_view_check_spec.rb
excellent-1.5.4 spec/checks/rails/params_hash_in_view_check_spec.rb