Sha256: 464a4d8a3ef016f52bd066279e224e5d9787c5f2f1147030915a7a11a19be1b1

Contents?: true

Size: 1.94 KB

Versions: 26

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'
require 'mailgun'

vcr_opts = { :cassette_name => "mailing_list" }

describe 'For the Mailing Lists endpoint', vcr: vcr_opts do
  before(:all) do
    @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
    @domain = TESTDOMAIN
    @ml_address = "integration_test_list@#{@domain}"
  end

  it 'creates a list' do
    result = @mg_obj.post("lists", {:address => @ml_address,
                                    :name => 'Integration Test List',
                                    :description => 'This list should be deleted automatically.',
                                    :access_level => 'members'})

    result.to_h!
    expect(result.body["message"]).to eq("Mailing list has been created")
    expect(result.body["list"]["address"]).to eq(@ml_address)
    expect(result.body["list"]["name"]).to eq('Integration Test List')
  end

  it 'gets a list.' do
    result = @mg_obj.get("lists/#{@ml_address}")

    result.to_h!
    expect(result.body["list"]["address"]).to eq(@ml_address)
    expect(result.body["list"]["name"]).to eq('Integration Test List')
  end

  it 'gets a list of all lists.' do
    result = @mg_obj.get("lists", {:limit => 50})

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

  it 'updates a list.' do
    result = @mg_obj.put("lists/#{@ml_address}",
                         {:address => @ml_address,
                          :name => 'Integration Test List Update',
                          :description => 'This list should be deleted automatically.',
                          :access_level => 'readonly'})

    result.to_h!
    expect(result.body["message"]).to eq("Mailing list has been updated")
    expect(result.body["list"]["address"]).to eq(@ml_address)
    expect(result.body["list"]["name"]).to eq('Integration Test List Update')
    expect(result.body["list"]["access_level"]).to eq('readonly')
  end

  it 'deletes a list' do
    @mg_obj.delete("lists/#{@ml_address}")
  end

end

Version data entries

26 entries across 26 versions & 2 rubygems

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