Sha256: cb5b21a4d046a7a0bd39cab931b407a8783f8b616d2b41a14760956dd0488834

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'
require 'roar/representer/feature/http_verbs'

class HttpVerbsTest < MiniTest::Spec
  class Band
    include Roar::Representer::XML
    
    property :name
    property :label
    
    include Roar::Representer::Feature::HttpVerbs
  end
  
  describe "HttpVerbs" do
    before do
      @r = Band.new
    end
    
    # TODO: assert that Restfulie#post receives the correct document.
    
    it "#post deserializes the incoming representation and returns it" do
      @r.name = "Strung Out"
      rep = @r.post("http://localhost:9999/band", "application/xml")
      assert_equal "Strung Out", rep.name
      assert_equal "n/a", rep.label
    end
    
    it "#post! deserializes the incoming representation and replaces attributes" do
      @r.name = "Strung Out"
      assert_equal nil, @r.label
      @r.post!("http://localhost:9999/band", "application/xml")
      assert_equal "Strung Out", @r.name
      assert_equal "n/a", @r.label
    end
    
    
    
    it "#put deserializes the incoming representation and returns it" do
      @r.name   = "Strung Out"
      @r.label  = "Fat Wreck"
      rep = @r.put("http://localhost:9999/band/strungout", "application/xml")
      assert_equal "Strung Out", rep.name
      assert_equal "Fat Wreck", rep.label
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roar-0.8.2 test/http_verbs_feature_test.rb
roar-0.8.1 test/http_verbs_feature_test.rb