Sha256: d89e09effcff755f4f74117cfe0338fbbd0819006918e904e2009f52983552dc

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'shoes/spec_helper'

describe Shoes::Image do
  include_context "dsl app"

  describe "basic" do
    let(:left) { 10 }
    let(:top) { 20 }
    let(:width) { 100 }
    let(:height) { 200 }

    let(:filename) { File.expand_path "../../../static/shoes-icon.png", __FILE__ }
    let(:updated_filename) { File.expand_path "../../../static/shoes-icon-brown.png", __FILE__ }

    subject(:image) { Shoes::Image.new(app, parent, filename, left: left, top: top, width: width, height: height) }

    it { is_expected.to be_instance_of(Shoes::Image) }

    it "should update image path" do
      subject.path = updated_filename
      expect(subject.path).to eq(updated_filename)
    end

    it_behaves_like "movable object"
    it_behaves_like "object with dimensions"
    
    it_behaves_like "object with style" do
      let(:subject_without_style) { Shoes::Image.new(app, parent, filename) }
      let(:subject_with_style) { Shoes::Image.new(app, parent, filename, arg_styles) }
    end

    describe "relative dimensions from parent" do
      subject { Shoes::Image.new(app, parent, filename, relative_opts) }
      it_behaves_like "object with relative dimensions"
    end

    describe "negative dimensions" do
      subject { Shoes::Image.new(app, parent, filename, negative_opts) }
      it_behaves_like "object with negative dimensions"
    end
  end

  describe 'accepts web URL' do
    let(:filename) { "http://is.gd/GVAGF7" }
    subject { Shoes::Image.new(app, parent, filename, input_opts) }

    its(:file_path) { should eq("http://is.gd/GVAGF7") }
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
shoes-swt-4.0.0.pre2 spec/shoes/image_spec.rb
shoes-dsl-4.0.0.pre2 spec/shoes/image_spec.rb