<commit_before>Feature: weird edge cases

Scenario: module with a .gitignore file
  Given a repository with following Vendorfile:
    """ruby
    vendor 'ignore', :version => 1 do
      File.open('.gitignore', 'w') { |f| f.puts 'ignored.txt' }
    end
    """
  When I successfully run `vendor sync`
  Then the following has been conjured:
    | Name      | ignore     |
    | With file | .gitignore |

  When I write to "vendor/ignore/ignored.txt" with:
    """
    whatever
    """
  Then git repository is clean

  When I change Vendorfile to:
    """ruby
    vendor 'ignore', :version => 2 do
      File.open('files.txt', 'w')  { |f| f.puts Dir.entries('.').join("\n") }
      File.open('.gitignore', 'w') { |f| f.puts 'ignored.txt' }
    end
    """
  And I successfully run `vendor sync`
  Then the file "vendor/ignore/files.txt" should not contain "ignored.txt"<commit_msg>Better spec for gitignore edge case - ignored file should be restored.<commit_after>Feature: weird edge cases

Scenario: module with a .gitignore file
  Given a repository with following Vendorfile:
    """ruby
    vendor 'ignore', :version => 1 do
      File.open('.gitignore', 'w') { |f| f.puts 'ignored.txt' }
    end
    """
  When I successfully run `vendor sync`
  Then the following has been conjured:
    | Name      | ignore     |
    | With file | .gitignore |

  When I write to "vendor/ignore/ignored.txt" with:
    """
    whatever
    """
  Then git repository is clean

  When I change Vendorfile to:
    """ruby
    vendor 'ignore', :version => 2 do
      File.open('files.txt', 'w')  { |f| f.puts Dir.entries('.').join("\n") }
      File.open('.gitignore', 'w') { |f| f.puts 'ignored.txt' }
    end
    """
  And I successfully run `vendor sync`
  Then the file "vendor/ignore/files.txt" should not contain "ignored.txt"
  And the file "vendor/ignore/ignored.txt" should contain exactly:
    """
    whatever
    """
  And git repository is clean
{'fraction_non_alphanumeric': 0.13484302624806999, 'fraction_numerical': 0.002058672156459084, 'mean_word_length': 2.782101167315175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3277607', 'n_tokens_mistral': 623, 'n_tokens_neox': 609, 'n_words': 208}