Sha256: f6f54e5873cc4ecd3973ca9f0f2589e494e7e01af8ffbb81e2739a6ae9ca1f0c

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'stringio'

def capture(*streams)
  streams.map! { |stream| stream.to_s }
  begin
    result = StringIO.new
    streams.each { |stream| eval "$#{stream} = result" }
    yield
  ensure
    streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
  end
  result.string
end

describe Capybara::Driver::RackTest do
  before do
    @driver = TestSessions::RackTest.driver
  end

  it "should throw an error when no rack app is given" do
    running do
      Capybara::Driver::RackTest.new(nil)
    end.should raise_error(ArgumentError)
  end

  if '1.9'.respond_to?(:encode)
    describe "with non-binary parameters" do

      it "should convert attribute values to binary" do
        output = capture(:stderr) {
          @driver.visit('/mypage', :param => 'µ')
        }.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
      end

      it "should convert attribute with Array to binary" do
        output = capture(:stderr) {
          @driver.visit('/mypage', :param => ['µ'])
        }.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
      end

      it "should convert path to binary" do
        output = capture(:stderr) {
          @driver.visit('/mypage'.encode('utf-8'))
        }.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
      end
    end
  end

  it_should_behave_like "driver"
  it_should_behave_like "driver with header support"
  it_should_behave_like "driver with status code support"
  it_should_behave_like "driver with cookies support"
  it_should_behave_like "driver with infinite redirect detection"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capybara-0.4.1.rc spec/driver/rack_test_driver_spec.rb
capybara-0.4.0 spec/driver/rack_test_driver_spec.rb
capybara-0.4.0.rc spec/driver/rack_test_driver_spec.rb