Sha256: 30f207eabc0bca9ed2f121e88405ba9df60945a9a55d3be70fa04f4548a2a68e

Contents?: true

Size: 1.17 KB

Versions: 26

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'
require 'mailgun'

vcr_opts = { :cassette_name => "unsubscribes" }

describe 'For the Unsubscribes endpoint', order: :defined, vcr: vcr_opts do
  before(:all) do
    @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
    @domain = TESTDOMAIN
    @email = "integration-test-email@#{TESTDOMAIN}"
  end

  it 'adds an unsubscriber' do
    result = @mg_obj.post "#{@domain}/unsubscribes", address: @email, tag: '*'

    result.to_h!
    expect(result.body["message"]).to eq("Address has been added to the unsubscribes table")
    expect(result.body["address"]).to eq(@email)
  end

  it 'get an unsubscribee.' do
    result = @mg_obj.get "#{@domain}/unsubscribes/#{@email}"

    result.to_h!
    expect(result.body["address"]).to eq(@email)
  end

  it 'gets a list of unsubscribes.' do
    result = @mg_obj.get "#{@domain}/unsubscribes"

    result.to_h!
    expect(result.body["items"].length).to be > 0
  end

  it 'removes an unsubscribee' do
    result = @mg_obj.delete "#{@domain}/unsubscribes/#{@email}"

    result.to_h!
    expect(result.body['address']).to eq(@email)
    expect(result.body["message"]).to eq("Unsubscribe event has been removed")
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
mailgun-ruby-1.2.15 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.14 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.13 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.12 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.11 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.10 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.9 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.8 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.7 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.6 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.5 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.4 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.3 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.2.0 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.1.11 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.1.10 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.1.9 spec/integration/unsubscribes_spec.rb
wj-mailgun-ruby-1.1.7 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.1.8 spec/integration/unsubscribes_spec.rb
mailgun-ruby-1.1.6 spec/integration/unsubscribes_spec.rb