Sha256: cebe56a1f963cb468721854514bd4dde7f931a8f8ad8b98f705cbb053b12b2a7

Contents?: true

Size: 1.6 KB

Versions: 9

Compression:

Stored size: 1.6 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')

describe Jelly::Common do
  attr_reader :fixture
  before do
    @fixture = Class.new do
      include Jelly::Common
    end.new
  end

  describe "#jelly_notify_hash" do
    it "creates a hash with a method and arguments" do
      fixture.jelly_notify_hash("my_method", 1, 2, 3).should == {
        "method" => "my_method",
        "arguments" => [1, 2, 3]
      }
    end
  end

  describe "#jelly_method_call_hash" do
    it "creates a hash with a object, method, and arguments" do
      fixture.jelly_method_call_hash("MyObject", "my_method", 1, 2, 3).should == {
        "on" => "MyObject",
        "method" => "my_method",
        "arguments" => [1, 2, 3]
      }
    end
  end

  describe "#jelly_callback_attach_hash" do
    context "when passed attachments" do
      it "creates a hash with the attach param being set to the given attachments" do
        attachments = [
          fixture.jelly_attachment_hash("Foo", 1, 2),
          fixture.jelly_attachment_hash("Bar", 3),
        ]
        fixture.jelly_notify_attach_hash(attachments).should == {
          "attach" => attachments
        }
      end
    end

    context "when not passed attachments" do
      it "creates a hash with the attach param being set to #jelly_attachments" do
        attachments = [
          fixture.jelly_attachment_hash("Foo", 1, 2),
          fixture.jelly_attachment_hash("Bar", 3),
        ]
        stub(fixture).jelly_attachments {attachments}
        fixture.jelly_notify_attach_hash.should == {
          "attach" => attachments
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
honkster-jelly-0.12.0 spec/jelly/common_spec.rb
honkster-jelly-0.11.0 spec/jelly/common_spec.rb
honkster-jelly-0.10.0 spec/jelly/common_spec.rb
honkster-jelly-0.9.3 spec/jelly/common_spec.rb
honkster-jelly-0.9.2 spec/jelly/common_spec.rb
honkster-jelly-0.8.14 spec/jelly/common_spec.rb
honkster-jelly-0.8.13 spec/jelly/common_spec.rb
honkster-jelly-0.8.12 spec/jelly/common_spec.rb
honkster-jelly-0.8.11 spec/jelly/common_spec.rb