Sha256: c0bfa6f7809c20846badff26667cf26ebcc7ab498286e6f95646cc348dec12ac

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

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

describe Simplabs::Excellent::Checks::Rails::SessionHashInViewCheck do

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

  describe '#evaluate' do

    it 'should accept views that do not use the session 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 session hash' do
      code = <<-END
        <div>
          <%= session[:someCount] %>
        </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     == 'Session 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/session_hash_in_view_check_spec.rb
simplabs-excellent-1.5.3 spec/checks/rails/session_hash_in_view_check_spec.rb
excellent-1.7.2 spec/checks/rails/session_hash_in_view_check_spec.rb
excellent-1.7.1 spec/checks/rails/session_hash_in_view_check_spec.rb
excellent-1.7.0 spec/checks/rails/session_hash_in_view_check_spec.rb
excellent-1.6.0 spec/checks/rails/session_hash_in_view_check_spec.rb
excellent-1.5.4 spec/checks/rails/session_hash_in_view_check_spec.rb