<commit_before>describe 'image' do
  before do
    @rmq = RubyMotionQuery::RMQ
  end

  it 'should return image from RMQ or an instance of rmq' do
    @rmq.image.should == RubyMotionQuery::ImageUtils

    rmq = RubyMotionQuery::RMQ.new
    rmq.image.should == RubyMotionQuery::ImageUtils
  end

  it "should convert a view to a UIImage" do
    view = UIView.alloc.initWithFrame([[0, 0], [10, 10]])
    image = @rmq.image.from_view(view)
    image.class.should == UIImage
    CGSizeEqualToSize(image.size, [10, 10]).should == true
    image.scale.should == UIScreen.mainScreen.scale
  end

  describe "resource_resizable" do
    it "should return an image with the proper cap insets" do
      opts = { top: 1, left: 1, bottom: 1, right: 1 }
      image = @rmq.image.resource_resizable('logo', opts)

      image.is_a?(UIImage).should.be.true
      image.capInsets.should == UIEdgeInsetsMake(1.0, 1.0, 1.0, 1.0)
    end

    it "should accept the shortcut labels for position as well" do
      opts = { t: 1, l: 1, b: 1, r: 1 }
      image = @rmq.image.resource_resizable('logo', opts)

      image.is_a?(UIImage).should.be.true
      image.capInsets.should == UIEdgeInsetsMake(1.0, 1.0, 1.0, 1.0)
    end
  end

  # TODO test resource with and without caching, resource_for_device
end<commit_msg>Adds resource_for_device testing<commit_after>class RubyMotionQuery::Device
  class << self
    def fake_four_inch(value)
      @_four_inch = value
    end
    def reset_fake_four_inch
      @_four_inch = (RubyMotionQuery::Device.height == 568.0)
    end
  end
end
describe 'image' do
  before do
    @rmq = RubyMotionQuery::RMQ
  end

  it 'should return image from RMQ or an instance of rmq' do
    @rmq.image.should == RubyMotionQuery::ImageUtils

    rmq = RubyMotionQuery::RMQ.new
    rmq.image.should == RubyMotionQuery::ImageUtils
  end

  it "should convert a view to a UIImage" do
    view = UIView.alloc.initWithFrame([[0, 0], [10, 10]])
    image = @rmq.image.from_view(view)
    image.class.should == UIImage
    CGSizeEqualToSize(image.size, [10, 10]).should == true
    image.scale.should == UIScreen.mainScreen.scale
  end

  describe "resource_for_device" do
    it "should return the requested file as is if we arent on a 4 inch" do
      @rmq.device.fake_four_inch(false)
      image = @rmq.image.resource_for_device('Default')
      @rmq.device.reset_fake_four_inch
      image.is_a?(UIImage).should.be.true
      image.size.height.should == 480
    end

    it "should get the -568h image on a four inch" do
      @rmq.device.fake_four_inch(true)
      image = @rmq.image.resource_for_device('Default')
      @rmq.device.reset_fake_four_inch
      image.is_a?(UIImage).should.be.true
      image.size.height.should == 568
    end
  end

  describe "resource_resizable" do
    it "should return an image with the proper cap insets" do
      opts = { top: 1, left: 1, bottom: 1, right: 1 }
      image = @rmq.image.resource_resizable('logo', opts)

      image.is_a?(UIImage).should.be.true
      image.capInsets.should == UIEdgeInsetsMake(1.0, 1.0, 1.0, 1.0)
    end

    it "should accept the shortcut labels for position as well" do
      opts = { t: 1, l: 1, b: 1, r: 1 }
      image = @rmq.image.resource_resizable('logo', opts)

      image.is_a?(UIImage).should.be.true
      image.capInsets.should == UIEdgeInsetsMake(1.0, 1.0, 1.0, 1.0)
    end
  end
  # TODO test resource with and without caching
end
{'fraction_non_alphanumeric': 0.11448598130841121, 'fraction_numerical': 0.02394859813084112, 'mean_word_length': 3.087112171837709, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2169210', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1179, 'n_words': 314}