Sha256: 9ffefee9951a6f029ab817313c477280303aa97cbf08d73324638c482592cbe5

Contents?: true

Size: 1.41 KB

Versions: 28

Compression:

Stored size: 1.41 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))


describe RTurk::Notification do
  before(:each) do
    @notification = RTurk::Notification.new
  end

  it "should not allow extra parameters" do
    lambda {
      @notification[:Bananas]
    }.should raise_error NameError
  end

  describe "#to_param_hash" do
    it "should not allow for empty params" do
      lambda {
        @notification.to_param_hash
      }.should raise_error RTurk::MissingParameters
    end

    it "should return a REST-friendly hash" do
      @notification.destination = 'foo'
      @notification.transport = 'bar'
      @notification.event_type = 'mumble'

      @notification.to_param_hash.should ==
        { "Notification.1.Destination" => 'foo',
          "Notification.1.Transport" => 'bar',
          "Notification.1.Version" => RTurk::OLD_API_VERSION,
          "Notification.1.EventType" => 'mumble' }
    end
    
    it "should allow multiple event types" do
      @notification.destination = 'foo'
      @notification.transport = 'bar'
      @notification.event_type = ['mumble', 'bumble']
      @notification.to_param_hash.should ==
        { "Notification.1.Destination" => 'foo',
          "Notification.1.Transport" => 'bar',
          "Notification.1.Version" => RTurk::OLD_API_VERSION,
          "Notification.1.EventType.1" => 'mumble',
          "Notification.1.EventType.2" => 'bumble' }
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rturk-2.12.1 spec/builders/notification_builder_spec.rb
rturk-2.12.0 spec/builders/notification_builder_spec.rb
rturk-2.11.3 spec/builders/notification_builder_spec.rb
rturk-2.11.2 spec/builders/notification_builder_spec.rb
rturk-2.11.1 spec/builders/notification_builder_spec.rb
rturk-2.11.0 spec/builders/notification_builder_spec.rb
rturk-2.10.3 spec/builders/notification_builder_spec.rb
rturk-2.10.2 spec/builders/notification_builder_spec.rb
rturk-2.10.1 spec/builders/notification_builder_spec.rb
rturk-2.10.0 spec/builders/notification_builder_spec.rb
rturk-2.9.0 spec/builders/notification_builder_spec.rb
rturk-2.8.0 spec/builders/notification_builder_spec.rb
rturk-2.7.0 spec/builders/notification_builder_spec.rb
rturk-2.6.0 spec/builders/notification_builder_spec.rb
rturk-2.5.2 spec/builders/notification_builder_spec.rb
rturk-2.5.0 spec/builders/notification_builder_spec.rb
rturk-2.4.1 spec/builders/notification_builder_spec.rb
rturk-2.4.0 spec/builders/notification_builder_spec.rb
rturk-2.3.6 spec/builders/notification_builder_spec.rb
rturk-2.3.5 spec/builders/notification_builder_spec.rb