Sha256: 3f7a8b17ad479e47148e9c1c570c0026e1a2f7b623860f9f8db2e4ec438cec50

Contents?: true

Size: 1.28 KB

Versions: 25

Compression:

Stored size: 1.28 KB

Contents

class Viewish
  def superview
    @superview ||= Viewish.new
  end

  def bounds
    CGRect.new([0, 0,], [100, 44])
  end
end


describe 'Teacup.calculate' do

  it 'should return static numbers' do
    Teacup.calculate(nil, nil, 1).should == 1
  end

  it 'should call blocks' do
    a = 'hi!'
    Teacup.calculate(a, nil, ->{
      self.should == a
      2
    }).should == 2
  end

  it 'should return percents with :width' do
    Teacup.calculate(Viewish.new, :width, '50%').should == 50
  end

  it 'should return percents with :height' do
    Teacup.calculate(Viewish.new, :height, '50%').should == 22
  end

  describe 'should return percents with offset' do
    it ':width, 50% + 10' do
      Teacup.calculate(Viewish.new, :width, '50% + 10').should == 60
    end
    it ':width, 50% - 10' do
      Teacup.calculate(Viewish.new, :width, '50% - 10').should == 40
    end
    it ':width, 25% + 5' do
      Teacup.calculate(Viewish.new, :width, '25% + 5').should == 30
    end
    it ':height, 50% + 10' do
      Teacup.calculate(Viewish.new, :height, '50% + 10').should == 32
    end
    it ':height, 50% - 10' do
      Teacup.calculate(Viewish.new, :height, '50% - 10').should == 12
    end
    it ':height, 25% + 5' do
      Teacup.calculate(Viewish.new, :height, '25% + 5').should == 16
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
teacup-2.1.13 spec/ios/calculations_spec.rb
teacup-2.1.12 spec/ios/calculations_spec.rb
teacup-2.1.11 spec/ios/calculations_spec.rb
teacup-2.1.10 spec/ios/calculations_spec.rb
teacup-2.1.9 spec/ios/calculations_spec.rb
teacup-2.1.8 spec/ios/calculations_spec.rb
teacup-2.1.7 spec/ios/calculations_spec.rb
teacup-2.1.6 spec/ios/calculations_spec.rb
teacup-2.1.5 spec/ios/calculations_spec.rb
teacup-2.1.4 spec/ios/calculations_spec.rb
teacup-2.1.3 spec/ios/calculations_spec.rb
teacup-2.1.2 spec/ios/calculations_spec.rb
teacup-2.1.1 spec/ios/calculations_spec.rb
teacup-2.1.0 spec/ios/calculations_spec.rb
teacup-2.0.6 spec/ios/calculations_spec.rb
teacup-2.0.5 spec/ios/calculations_spec.rb
teacup-2.0.4 spec/ios/calculations_spec.rb
teacup-2.0.3 spec/ios/calculations_spec.rb
teacup-2.0.2 spec/ios/calculations_spec.rb
teacup-2.0.0 spec/ios/calculations_spec.rb