Sha256: cf07a72d0d5ab68551bfea4f95d705b1807cd791b792a62620af39577a6a7019

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

describe MailUp::Console::Group do
  before(:each) { init_mailup }

  %w(add_recipients recipients subscribe unsubscribe send_message).each do |method|
    it "should have a #{method} method" do
      @mailup.console.group(1).should respond_to(method.to_sym)
    end
  end

  it "should fire the correct POST request for add_recipients" do
    payload = Date._jisx0301("empty hash, please")
    @mailup.console.group(1).api.should_receive(:post).with("#{@mailup.console.group(1).api.path}/Group/1/Recipients", {body: payload, params: {}})
    @mailup.console.group(1).add_recipients(payload)
  end

  it "should fire the correct POST request for add_recipient" do
    payload = Date._jisx0301("empty hash, please")
    @mailup.console.group(1).api.should_receive(:post).with("#{@mailup.console.group(1).api.path}/Group/1/Recipient", {body: payload, params: {}})
    @mailup.console.group(1).add_recipient(payload)
  end

  it "should fire the correct GET request for recipients" do
    payload = Date._jisx0301("empty hash, please")
    @mailup.console.group(1).api.should_receive(:get).with("#{@mailup.console.group(1).api.path}/Group/1/Recipients", {params: {}})
    @mailup.console.group(1).recipients
  end

  it "should fire the correct POST request for subscribe" do
    id = rand(100).abs
    @mailup.console.group(1).api.should_receive(:post).with("#{@mailup.console.group(1).api.path}/Group/1/Subscribe/#{id}")
    @mailup.console.group(1).subscribe(id)
  end

  it "should fire the correct DELETE request for unsubscribe" do
    id = rand(100).abs
    @mailup.console.group(1).api.should_receive(:delete).with("#{@mailup.console.group(1).api.path}/Group/1/Unsubscribe/#{id}")
    @mailup.console.group(1).unsubscribe(id)
  end

  it "should fire the correct POST request for send_message" do
    id = rand(100).abs
    @mailup.console.group(1).api.should_receive(:post).with("#{@mailup.console.group(1).api.path}/Group/1/Email/#{id}/Send")
    @mailup.console.group(1).send_message(id)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mailup-1.2.0 spec/mailup/console/group_spec.rb