Sha256: 4863c9c5bde74bf242b1c4d555de7cc630fba3ef2f2d984aafde1adb9306e8b1

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Curly do
  before do
    @curly = Curly.new
  end
  
  it "should enable cookies when cookiejar is set" do
    @curly.enable_cookies?.should == false
    @curly.cookiejar = 'foo'
    @curly.enable_cookies?.should == true
  end
  
  it "should post params hash" do
    field_arg = an_instance_of(Curl::PostField)
    @curly.should_receive(:http_post).with(field_arg, field_arg)
    @curly.post(:foo => 'bar', :baz => 'foo')
  end
  
  it "should get document" do
    @curly.should_receive(:http_get).with().and_return(true)
    @curly.stub!(:response_code).and_return(200)
    @curly.stub!(:body_str).and_return(<<-HTML)
      <html>
        <body>You are being
          <a href=\"http://localhost:3000/login\">redirected</a>.
        </body>
      </html>
    HTML
    
    doc = @curly.get('http://example.com').doc
    @curly.url.should == 'http://example.com'
    doc.class.should == Hpricot::Doc
    doc.at('a[@href]').inner_text.should == 'redirected'
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
kmayer-highrise-0.7.0 spec/highrise/curly_spec.rb
kmayer-highrise-0.7.1 spec/highrise/curly_spec.rb
tapajos-highrise-0.8.0 spec/highrise/curly_spec.rb