<commit_before>require 'test_helper'

module RemotePartial
  class BuilderTest < ActiveSupport::TestCase

    def setup
      @name = 'foo'
      @url = 'bar'
      @builder = Builder.new(
          name: @name,
          url: @url
      )
    end

    def test_create_or_update_partial
      assert_difference 'RemotePartial::Partial.count' do
        @builder.create_or_update_partial
      end
      assert_equal @name, Partial.last.name
    end

    def test_build
       assert_difference 'RemotePartial::Partial.count' do
         Builder.build(
           url: @url,
           name: @name
         )
       end
       assert_equal(@name, Partial.last.name)
     end
  end
end<commit_msg>Adds test that build updates existing partials<commit_after>require 'test_helper'

module RemotePartial
  class BuilderTest < ActiveSupport::TestCase

    def setup
      @name = 'foo'
      @url = 'bar'
      new_builder
    end

    def test_create_or_update_partial
      assert_difference 'RemotePartial::Partial.count' do
        @builder.create_or_update_partial
      end
      assert_equal @name, Partial.last.name
    end

    def test_create_or_update_partial_updates_if_partial_exists
      test_create_or_update_partial
      @url = 'other'
      new_builder
      assert_no_difference 'RemotePartial::Partial.count' do
        @builder.create_or_update_partial
      end
      assert_equal @url, Partial.last.url
    end

    def test_build
       assert_difference 'RemotePartial::Partial.count' do
         Builder.build(
           url: @url,
           name: @name
         )
       end
       assert_equal(@name, Partial.last.name)
    end

    def new_builder
      @builder = Builder.new(
          name: @name,
          url: @url
      )
    end
  end
end
{'fraction_non_alphanumeric': 0.0716704288939052, 'fraction_numerical': 0.0, 'mean_word_length': 2.2354014598540144, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7576510', 'n_tokens_mistral': 530, 'n_tokens_neox': 516, 'n_words': 118}