Sha256: a33c1569d90bb9791f976392b17221139690cd38d2e36f0704a17f997af8b8e4

Contents?: true

Size: 1.82 KB

Versions: 30

Compression:

Stored size: 1.82 KB

Contents

require File.join(File.dirname(__FILE__),'spec_helper')

describe "License" do
  it_should_behave_like "SpecBootstrapHelper"
  it_should_behave_like "SourceAdapterHelper"
  
  before(:each) do
    Store.put_value(License::CLIENT_DOCKEY,nil)
  end
  
  it "should decrypt license" do
    license = License.new
    license.rhosync_version.should == 'Version 1'
    license.licensee.should == 'Rhomobile'
    license.seats.should == 10
    license.issued.should == 'Fri Apr 23 17:20:13 -0700 2010'
  end
  
  it "should raise exception on license load error" do
    Rhosync.stub!(:get_config).and_return({Rhosync.environment.to_sym => {}})
    lambda { License.new }.should raise_error(LicenseException, "Error verifying license.")
  end
  
  it "should verify # of seats before adding" do
    License.new.check_and_use_seat
    Store.get_value(License::CLIENT_DOCKEY).to_i.should == 1
  end
   
  it "should raise exception when seats are exceeded" do
    Store.put_value(License::CLIENT_DOCKEY,10)
    lambda { License.new.check_and_use_seat }.should raise_error(
      LicenseSeatsExceededException, "WARNING: Maximum # of devices exceeded for this license."
    )
  end
  
  it "should free license seat" do
    Store.put_value(License::CLIENT_DOCKEY,5)
    License.new.free_seat
    Store.get_value(License::CLIENT_DOCKEY).to_i.should == 4
  end

  it "should get # of available seats" do
    license = License.new
    license.check_and_use_seat
    license.available.should == 9
  end
  
  it "should use RHOSYNC_LICENSE env var" do
    ENV['RHOSYNC_LICENSE'] = 'b749cbe6e029400e688360468624388e2cb7f6a1e72c91d4686a1b8c9d37b72c3e1872ec9f369d481220e10759c18e16'
    license = License.new
    license.licensee.should == 'Rhohub'
    license.seats.should == 5
    license.issued.should == 'Tue Aug 10 16:14:24 -0700 2010'
    ENV.delete('RHOSYNC_LICENSE')
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rhosync-2.1.18.beta2 spec/license_spec.rb
rhosync-2.1.18.beta1 spec/license_spec.rb
rhosync-2.1.17 spec/license_spec.rb
rhosync-2.1.17.beta7 spec/license_spec.rb
rhosync-2.1.17.beta6 spec/license_spec.rb
rhosync-2.1.17.beta5 spec/license_spec.rb
rhosync-2.1.17.beta4 spec/license_spec.rb
rhosync-2.1.17.beta3 spec/license_spec.rb
rhosync-2.1.17.beta2 spec/license_spec.rb
rhosync-2.1.17.beta1 spec/license_spec.rb
rhosync-2.1.16 spec/license_spec.rb
rhosync-2.1.15 spec/license_spec.rb
rhosync-2.1.14 spec/license_spec.rb
rhosync-2.1.13 spec/license_spec.rb
rhosync-2.1.12 spec/license_spec.rb
rhosync-2.1.11 spec/license_spec.rb
rhosync-2.1.10 spec/license_spec.rb
rhosync-2.1.7 spec/license_spec.rb
rhosync-2.1.6 spec/license_spec.rb
rhosync-2.1.3 spec/license_spec.rb