Sha256: ddbb789d2142424cbb29bf26366afee9eb4cc19e724d53b1d86a128223fc192d

Contents?: true

Size: 1.49 KB

Versions: 25

Compression:

Stored size: 1.49 KB

Contents

require './spec/spec_helper'


describe Message do
  before(:each) do
    stub_auth_request
  end

  subject do
    m = Message.new
    m.attributes["Type"] = "ShowingRequest"
    m.attributes["EventDateTime"] = "2011-09-15T14:00:00"
    m.attributes["SenderId"] = "20110112234857732941000000"
    m.attributes["Subject"] = "Showing Request For 123 Main St, MLS # 12-345"
    m.attributes["Body"] = "A showing is requested for ..."
    m.attributes["ListingId"] = "20110112234857732941000000"
    m
  end

  context "/messages", :support do
    on_get_it "should get all my messages"

    on_post_it "should save a new message" do
      stub_api_post("/messages", 'messages/new.json', 'messages/post.json')
      subject.save.should be(true)
    end

    on_post_it "should save a new message with recipients" do
      stub_api_post("/messages", 'messages/new_with_recipients.json', 'messages/post.json')
      subject.attributes["Recipients"] =  ["20110112234857732941000000","20110092234857738467000000"]
      subject.save.should be(true)
    end

    on_post_it "should fail saving" do
      stub_api_post("/messages", 'messages/new_empty.json') do |request|
        request.to_return(:status => 400, :body => fixture('errors/failure.json'))
      end
      m=subject.class.new
      m.save.should be(false)
      expect{ m.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.should == 400 }
    end
  end

  context "/messages/<message_id>", :support do
    on_get_it "should get a single message"
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
spark_api-1.3.23 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.21 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.20 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.19 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.18 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.17 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.16 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.15 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.14 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.13 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.10 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.9 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.6 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.3 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.1 spec/unit/spark_api/models/message_spec.rb
spark_api-1.3.0 spec/unit/spark_api/models/message_spec.rb
spark_api-1.2.1 spec/unit/spark_api/models/message_spec.rb
spark_api-1.2.0 spec/unit/spark_api/models/message_spec.rb
spark_api-1.1.2 spec/unit/spark_api/models/message_spec.rb
spark_api-1.1.1 spec/unit/spark_api/models/message_spec.rb