<commit_before>require 'shoes/spec_helper'

describe Shoes::InputBox do
  let(:left) { 10 }
  let(:top) { 20 }
  let(:width) { 100 }
  let(:height) { 200 }
  let(:input_block) { Proc.new {} }


  let(:app) { Shoes::App.new }
  let(:parent) { Shoes::Flow.new(app, app) }
  let(:text) { "the text" }
  let(:input_opts) {{left: left, top: top, width: width, height: height}}

  subject { Shoes::InputBox.new(app, parent, text, input_opts, input_block) }

  it_behaves_like "object with dimensions"
  it_behaves_like "movable object"
  it_behaves_like "an element that can respond to change"
  it_behaves_like "object with state"


  it { should respond_to :focus }
  it { should respond_to :text  }
  it { should respond_to :text= }

  it 'forwards calls to highlight_text to the backend' do
    expect(subject.gui).to receive(:highlight_text).with(4, 20)
    subject.highlight_text 4, 20
  end

  it 'forwards calls to caret_to to the backend' do
    expect(subject.gui).to receive(:caret_to).with(42)
    subject.caret_to 42
  end

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

  describe "negative dimensions" do
    subject { Shoes::EditBox.new(app, parent, text, negative_opts) }
    it_behaves_like "object with negative dimensions"
  end
end
<commit_msg>SWT specs fail with subject set as InputBox due to different constructors with text options<commit_after>require 'shoes/spec_helper'

describe Shoes::InputBox do
  let(:left) { 10 }
  let(:top) { 20 }
  let(:width) { 100 }
  let(:height) { 200 }
  let(:input_block) { Proc.new {} }


  let(:app) { Shoes::App.new }
  let(:parent) { Shoes::Flow.new(app, app) }
  let(:text) { "the text" }
  let(:input_opts) {{left: left, top: top, width: width, height: height}}

  # EditBox is an InputBox but InputBox is enver instantiated itself
  # And there are problems in the backend due to option settings
  subject { Shoes::EditBox.new(app, parent, text, input_opts, input_block) }

  it_behaves_like "object with dimensions"
  it_behaves_like "movable object"
  it_behaves_like "an element that can respond to change"
  it_behaves_like "object with state"


  it { should respond_to :focus }
  it { should respond_to :text  }
  it { should respond_to :text= }

  it 'forwards calls to highlight_text to the backend' do
    expect(subject.gui).to receive(:highlight_text).with(4, 20)
    subject.highlight_text 4, 20
  end

  it 'forwards calls to caret_to to the backend' do
    expect(subject.gui).to receive(:caret_to).with(42)
    subject.caret_to 42
  end

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

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

{'fraction_non_alphanumeric': 0.10832497492477432, 'fraction_numerical': 0.013373453694416584, 'mean_word_length': 4.140893470790378, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6932548', 'n_tokens_mistral': 1056, 'n_tokens_neox': 975, 'n_words': 299}