<commit_before>require_relative './database_integration_init'

describe "The :no_stream Expected Version Number" do
  context "Events have not yet been written to the stream" do
    stream_name = EventStore::Client::HTTP::Controls::StreamName.get 'testNoStreamVersionNoEvents'

    writer = EventStore::Client::HTTP::EventWriter.build

    event_data = EventStore::Client::HTTP::Controls::EventData::Write.example

    specify "Succeeds" do
      writer.write event_data, stream_name, expected_version: :no_stream
    end
  end

  context "Events have already been written to the stream" do
    stream_name = EventStore::Client::HTTP::Controls::StreamName.get 'testNoStreamVersionWithEvents'

    writer = EventStore::Client::HTTP::EventWriter.build

    event_data_1 = EventStore::Client::HTTP::Controls::EventData::Write.example i: 1, type: 'FirstEvent'
    writer.write event_data_1, stream_name

    event_data_2 = EventStore::Client::HTTP::Controls::EventData::Write.example i: 2, type: 'SecondEvent'

    specify "Is an error" do
      assert_raises EventStore::Client::HTTP::Request::Post::ExpectedVersionError do
        writer.write event_data_2, stream_name, expected_version: :no_stream
      end
    end
  end
end
<commit_msg>Test doesn't couple to the no_stream symbol<commit_after>require_relative './database_integration_init'

describe "The :no_stream Expected Version Number" do
  context "Events have not yet been written to the stream" do
    stream_name = EventStore::Client::HTTP::Controls::StreamName.get 'testNoStreamVersionNoEvents'

    writer = EventStore::Client::HTTP::EventWriter.build

    event_data = EventStore::Client::HTTP::Controls::EventData::Write.example

    specify "Succeeds" do
      writer.write event_data, stream_name, expected_version: -1
    end
  end

  context "Events have already been written to the stream" do
    stream_name = EventStore::Client::HTTP::Controls::StreamName.get 'testNoStreamVersionWithEvents'

    writer = EventStore::Client::HTTP::EventWriter.build

    event_data_1 = EventStore::Client::HTTP::Controls::EventData::Write.example i: 1, type: 'FirstEvent'
    writer.write event_data_1, stream_name

    event_data_2 = EventStore::Client::HTTP::Controls::EventData::Write.example i: 2, type: 'SecondEvent'

    specify "Is an error" do
      assert_raises EventStore::Client::HTTP::Request::Post::ExpectedVersionError do
        writer.write event_data_2, stream_name, expected_version: -1
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10160642570281124, 'fraction_numerical': 0.005622489959839358, 'mean_word_length': 5.27455919395466, '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': '3438187', 'n_tokens_mistral': 729, 'n_tokens_neox': 707, 'n_words': 174}