<commit_before>  require File.expand_path('../../spec_helper', __FILE__)

describe Portal::PadletBookmark do
  let(:bookmark_wrapper)    { mock(:padlet_url => "http://fake_padlet.com") }
  before(:each) do
    PadletWrapper.stub!(:make_bookmark) { bookmark_wrapper }
  end

  describe "Class methods" do
    describe "#create_for_user(user)" do
      describe "the default padlet names" do

        context "when none of the existing names contain ordinal numbers" do
          let(:user) {mock_model(User, :anonymous? => false, :email=>'<EMAIL>')}
          let(:found_items) do
            [ mock(:name => 'foo'), mock(:name => 'bar'), mock(:name => 'baz')]
          end

          it "shuld use a name with an ordinal found-size + 1" do
            Portal::PadletBookmark.stub!(:for_user => found_items)
            Portal::PadletBookmark.create_for_user(user).name.should match(/my 4th padlet/i)
          end
        end

        context "when some of the names contain ordinal numbers" do
          let(:user) {mock_model(User, :anonymous? => false, :email=>'<EMAIL>')}
          let(:found_items) do
            [ mock(:name => 'my 3rd padlet'), mock(:name => 'bar'), mock(:name => 'my 7th padlet')]
          end

          it "shuld use a name with existing max ordinal size + 1" do
            Portal::PadletBookmark.stub!(:for_user => found_items)
            Portal::PadletBookmark.create_for_user(user).name.should match(/my 8th padlet/i)
          end
        end<commit_msg>Fix Padlet Bookmark spec<commit_after>  require File.expand_path('../../spec_helper', __FILE__)

describe Portal::PadletBookmark do
  let(:bookmark_wrapper) { mock(:padlet_url => "http://fake_padlet.com") }
  before(:each) do
    PadletWrapper.stub!(:new) { bookmark_wrapper }
  end

  describe "Class methods" do
    describe "#create_for_user(user)" do
      describe "the default padlet names" do

        context "when none of the existing names contain ordinal numbers" do
          let(:user) {mock_model(User, :anonymous? => false, :email=>'<EMAIL>')}
          let(:found_items) do
            [ mock(:name => 'foo'), mock(:name => 'bar'), mock(:name => 'baz')]
          end

          it "shuld use a name with an ordinal found-size + 1" do
            Portal::PadletBookmark.stub!(:for_user => found_items)
            Portal::PadletBookmark.create_for_user(user).name.should match(/my 4th padlet/i)
          end
        end

        context "when some of the names contain ordinal numbers" do
          let(:user) {mock_model(User, :anonymous? => false, :email=>'<EMAIL>')}
          let(:found_items) do
            [ mock(:name => 'my 3rd padlet'), mock(:name => 'bar'), mock(:name => 'my 7th padlet')]
          end

          it "shuld use a name with existing max ordinal size + 1" do
            Portal::PadletBookmark.stub!(:for_user => found_items)
            Portal::PadletBookmark.create_for_user(user).name.should match(/my 8th padlet/i)
          end
        end
{'fraction_non_alphanumeric': 0.13364674278038952, 'fraction_numerical': 0.004029550033579583, 'mean_word_length': 2.737766624843162, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, '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': '3611499', 'n_tokens_mistral': 926, 'n_tokens_neox': 901, 'n_words': 242}