Sha256: e78a8b1499c2d8fe18f7671b5e73402534d04407f8c841151aaaa5d8f3229d2c

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

shared_examples_for "object with dimensions" do
  it "should initialize" do
    subject.left.should == left
    subject.top.should == top
    subject.width.should == width
    subject.height.should == height
  end
end

shared_examples_for "object with relative dimensions" do
  let(:relative_width) { 0.5 }
  let(:relative_height) { 0.5 }
  let(:relative_opts) { {left: left, top: top, width: relative_width, height: relative_height} }

  it "should initialize based on parent dimensions" do
    expect(subject.left).to eq left
    expect(subject.top).to eq top
    expect(subject.width).to be_within(1).of(parent.width / 2)
    expect(subject.height).to be_within(1).of(parent.height / 2)
  end
end

shared_examples_for "object with negative dimensions" do
  let(:negative_opts) { {left: left, top: top, width: -width, height: -height} }

  it "should initialize based on parent dimensions" do
    subject.left.should == left
    subject.top.should == top
    subject.width.should == parent.width - width
    subject.height.should == parent.height - height
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-4.0.0.pre1 spec/shoes/shared_examples/dimensions.rb