Sha256: 57633cdeecb912d9d66682c830077e09778051cb2c1d49d44194ac3783d2c721

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

require 'rubygems'
gem 'rspec'
require 'spec'
require File.join(File.dirname(__FILE__), '../..', 'lib', 'weary')

describe Weary::Resource do
  before do
    @test = Weary::Resource.new("test")
  end
  
  it 'defaults to a GET request' do
    @test.via.should == :get
  end
  it 'should add requirements to the "with" array' do
    @test.requires = [:foo, :bar]
    @test.with.should == [:foo, :bar]
  end
  
  it 'with paramaters could be comma delimited strings' do
    @test.with = "foo", "bar"
    @test.with.should == [:foo, :bar]
  end
  
  it 'authenticates? should be boolean' do
    @test.authenticates = "foobar"
    @test.authenticates?.should == true
    @test.authenticates = false
    @test.authenticates?.should == false
  end
  
  it 'follows_redirects? should be boolean' do
    @test.follows = "false"
    @test.follows_redirects?.should == true
    @test.follows = false
    @test.follows_redirects?.should == false
  end
  
  it 'should be intelligent about crafting names' do
    @test.name = "foo bar \n"
    @test.name.should == "foo_bar"
  end
  
  it 'should only allow specified http methods' do
    @test.via = "Post"
    @test.via.should == :post
    lambda { @test.via = :foobar }.should raise_error
  end
  
    
    it 'format should be a symbol' do
      @test.format = "xml"
      @test.format.class.should == Symbol
    end
    
    it 'format should be an allowed format' do
      @test.format = 'text/json'
      @test.format.should == :json
      lambda { @test.format = :foobar }.should raise_error
    end
  
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mwunsch-weary-0.2.1 spec/weary/resource_spec.rb
weary-0.2.1 spec/weary/resource_spec.rb