<commit_before>require 'webrick'
RSpec.describe Mdm::WebPage, type: :model do
  it_should_behave_like 'Metasploit::Concern.run'

  context 'associations' do
    it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
  end

  context 'serialized attributes' do
    context 'cookie' do
      let(:string_cookie) do
        "test_name=test_value"
      end

      let(:hash_cookie) do
        {
            name: 'test name',
            value: 'test value'
        }
      end

      let(:webrick_cookie) do
        WEBrick::Cookie.new('test name', 'test value')
      end

      let(:web_page) { FactoryGirl.create(:mdm_web_page, cookie: cookie) }

      context 'with string cookie' do
        let(:cookie) { string_cookie }
        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns a hash' do
          expect(web_page.cookie).to be_a String
        end
      end

      context 'with Hash cookie' do
        let(:cookie) { hash_cookie }
        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns a hash' do
          expect(web_page.cookie).to be_a Hash
        end
      end

      context 'with WEBrick::Cookie' do
        let(:cookie) { webrick_cookie }
        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns as WEBrick::Cookie object' do<commit_msg>Add blank line between let/it<commit_after>require 'webrick'
RSpec.describe Mdm::WebPage, type: :model do
  it_should_behave_like 'Metasploit::Concern.run'

  context 'associations' do
    it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
  end

  context 'serialized attributes' do
    context 'cookie' do
      let(:string_cookie) do
        "test_name=test_value"
      end

      let(:hash_cookie) do
        {
            name: 'test name',
            value: 'test value'
        }
      end

      let(:webrick_cookie) do
        WEBrick::Cookie.new('test name', 'test value')
      end

      let(:web_page) { FactoryGirl.create(:mdm_web_page, cookie: cookie) }

      context 'with string cookie' do
        let(:cookie) { string_cookie }

        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns a hash' do
          expect(web_page.cookie).to be_a String
        end
      end

      context 'with Hash cookie' do
        let(:cookie) { hash_cookie }

        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns a hash' do
          expect(web_page.cookie).to be_a Hash
        end
      end

      context 'with WEBrick::Cookie' do
        let(:cookie) { webrick_cookie }
        
        it 'persists successfully' do
          expect{web_page}.to change{Mdm::WebPage.count}.by(1)
        end

        it 'reading cookie returns as WEBrick::Cookie object' do
{'fraction_non_alphanumeric': 0.09977542508822586, 'fraction_numerical': 0.0019249278152069298, 'mean_word_length': 2.2786540483701367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1195999', 'n_tokens_mistral': 985, 'n_tokens_neox': 942, 'n_words': 243}