Sha256: 65627e19377e51d98b77946e6b01cd067b7710e46da6dc9d62c7b1aa79278b61

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

shared_examples_for "an Notification subclass" do
  describe "when assigning data for the device" do
    before { Rpush::Deprecation.stub(:warn) }

    it "calls MultiJson.dump when multi_json responds to :dump" do
      notification = notification_class.new
      MultiJson.stub(:respond_to?).with(:dump).and_return(true)
      MultiJson.should_receive(:dump).with(any_args)
      notification.data = { pirates: 1 }
    end

    it "calls MultiJson.encode when multi_json does not respond to :dump" do
      notification = notification_class.new
      MultiJson.stub(:respond_to?).with(:dump).and_return(false)
      MultiJson.should_receive(:encode).with(any_args)
      notification.data = { ninjas: 1 }
    end

    it "raises an ArgumentError if something other than a Hash is assigned" do
      expect do
        notification.data = Array.new
      end.to raise_error(ArgumentError, "must be a Hash")
    end

    it "encodes the given Hash as JSON" do
      notification.data = { hi: "mom" }
      notification.read_attribute(:data).should eq("{\"hi\":\"mom\"}")
    end

    it "decodes the JSON when using the reader method" do
      notification.data = { hi: "mom" }
      notification.data.should eq("hi" => "mom")
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rpush-2.3.1-java spec/unit/notification_shared.rb
rpush-2.3.1 spec/unit/notification_shared.rb
rpush-2.3.0-java spec/unit/notification_shared.rb
rpush-2.3.0 spec/unit/notification_shared.rb
rpush-2.3.0.rc1 spec/unit/notification_shared.rb
rpush-2.2.0-java spec/unit/notification_shared.rb
rpush-2.2.0 spec/unit/notification_shared.rb
rpush-2.1.0-java spec/unit/notification_shared.rb
rpush-2.1.0 spec/unit/notification_shared.rb
rpush-2.0.1-java spec/unit/notification_shared.rb
rpush-2.0.1 spec/unit/notification_shared.rb
rpush-2.0.0-java spec/unit/notification_shared.rb
rpush-2.0.0 spec/unit/notification_shared.rb
rpush-2.0.0.rc1-java spec/unit/notification_shared.rb
rpush-2.0.0.rc1 spec/unit/notification_shared.rb
rpush-2.0.0.beta2 spec/unit/notification_shared.rb
rpush-2.0.0.beta1 spec/unit/notification_shared.rb