Sha256: 1b6912288fd52d3ae936c48364a66a50ac7a1826c6b3fb74a5b40843452673c8

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

def capture_stdout(&block)
  original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
end

describe R509 do
  it "prints version and feature info with ::print_debug" do
    output = capture_stdout { R509.print_debug }
    output.should match /^r509 v/
    output.should match /^OpenSSL/
    output.should match /^Ruby/
    output.should match /^Elliptic/
  end
  it "checks if ec is supported", :ec => true do
    R509.ec_supported?.should == true
  end
  it "checks if EC is unsupported" do
    ec = OpenSSL::PKey.send(:remove_const,:EC) # remove EC support for test!
    load('r509/ec-hack.rb')
    R509.ec_supported?.should == false
    expect { OpenSSL::PKey::EC.new }.to raise_error(R509::R509Error)
    OpenSSL::PKey.send(:remove_const,:EC) # remove stubbed EC
    OpenSSL::PKey::EC = ec # add the real one back
    # this pretty fragile. if the expectation fails then we don't fix the EC class assignment
    # so any spec called after this will fail improperly.
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
r509-0.10.0 spec/r509_spec.rb
r509-0.9.2 spec/r509_spec.rb
r509-0.9.1 spec/r509_spec.rb
r509-0.9 spec/r509_spec.rb