<commit_before>require 'spec_helper'

describe Emarsys::Event do
  describe ".collection" do
    it "requests all events" do
      stub_get("event") { Emarsys::Event.collection }.should have_been_requested.once
    end
  end

  describe ".trigger" do
    it "requests event trigger with parameters" do
      stub = stub_request(:post, "https://suite5.emarsys.net/api/v2/event/123/trigger").with(:body => {'key_id' => 3, 'external_id' => "<EMAIL>"}.to_json).to_return(standard_return_body)
      Emarsys::Event.trigger(123, 3, '<EMAIL>')
      stub.should have_been_requested.once
    end

    it "requests event trigger with additional data parameters" do
      stub = stub_request(:post, "https://suite5.emarsys.net/api/v2/event/123/trigger").with(:body => {'key_id' => 3, 'external_id' => "<EMAIL>", :data => {'global' => {'my_placeholder' => 'Something'}}}.to_json).to_return(standard_return_body)
      Emarsys::Event.trigger(123, 3, '<EMAIL>', {'global' => {'my_placeholder' => 'Something'}})
      stub.should have_been_requested.once
    end
  end
end<commit_msg>Add spec for new event trigger function<commit_after>require 'spec_helper'

describe Emarsys::Event do
  describe ".collection" do
    it "requests all events" do
      stub_get("event") { Emarsys::Event.collection }.should have_been_requested.once
    end
  end

  describe ".trigger" do
    it "requests event trigger with parameters" do
      stub = stub_request(:post, "https://suite5.emarsys.net/api/v2/event/123/trigger").with(:body => {'key_id' => 3, 'external_id' => "<EMAIL>"}.to_json).to_return(standard_return_body)
      Emarsys::Event.trigger(123, 3, '<EMAIL>')
      stub.should have_been_requested.once
    end

    it "requests event trigger with additional data parameters" do
      stub = stub_request(:post, "https://suite5.emarsys.net/api/v2/event/123/trigger").with(:body => {'key_id' => 3, 'external_id' => "<EMAIL>", :data => {'global' => {'my_placeholder' => 'Something'}}}.to_json).to_return(standard_return_body)
      Emarsys::Event.trigger(123, 3, '<EMAIL>', {'global' => {'my_placeholder' => 'Something'}})
      stub.should have_been_requested.once
    end
  end

  describe ".trigger_multiple" do
    it "requests event trigger with parameters" do
      stub = stub_request(:post, "https://suite5.emarsys.net/api/v2/event/123/trigger").with(:body => {'key_id' => 3, 'external_id' => "", :data => nil, :contacts => [{'external_id' => "<EMAIL>"}]}.to_json).to_return(standard_return_body)
      Emarsys::Event.trigger_multiple(123,3,[{'external_id' => '<EMAIL>'}])
      stub.should have_been_requested.once
    end
  end
end
{'fraction_non_alphanumeric': 0.16463414634146342, 'fraction_numerical': 0.019054878048780487, 'mean_word_length': 4.401234567901234, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 42, 'https://': 5, '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': '1996923', 'n_tokens_mistral': 902, 'n_tokens_neox': 872, 'n_words': 178}