spec/shoes/swt/input_box_spec.rb in shoes-swt-4.0.0.pre6 vs spec/shoes/swt/input_box_spec.rb in shoes-swt-4.0.0.pre7

- old
+ new

@@ -1,20 +1,25 @@ require 'spec_helper' describe Shoes::Swt::InputBox do include_context "swt app" - let(:dsl) { double('dsl', app: shoes_app, visible?: true, element_width: 80, - element_height: 22, initial_text: 'Jay', - secret?: secret, - call_change_listeners: true).as_null_object } - let(:real) { double('real', disposed?: false, text: text, - add_modify_listener: true).as_null_object } - let(:styles) {::Swt::SWT::SINGLE | ::Swt::SWT::BORDER} - let(:secret) {false} - let(:text) {'Some text...'} + let(:dsl) do + double('dsl', app: shoes_app, visible?: true, element_width: 80, + element_height: 22, initial_text: 'Jay', + secret?: secret, call_change_listeners: true).as_null_object + end + let(:real) do + double('real', disposed?: false, text: text, add_modify_listener: true) + .as_null_object + end + + let(:styles) { ::Swt::SWT::SINGLE | ::Swt::SWT::BORDER } + let(:secret) { false } + let(:text) { 'Some text...' } + subject { Shoes::Swt::InputBox.new dsl, swt_app, styles } before :each do allow(::Swt::Widgets::Text).to receive(:new) { real } allow(::Swt::Widgets::Text).to receive(:text=) { real } @@ -23,12 +28,12 @@ it_behaves_like "movable element" it_behaves_like "removable native element" it_behaves_like "updating visibility" describe "#initialize" do - let(:event) {double 'Event', source: source} - let(:source) {double 'Source'} + let(:event) { double 'Event', source: source } + let(:source) { double 'Source' } it "sets text on real element" do subject.text = "some text" expect(real).to have_received(:text=).with("some text") end @@ -55,13 +60,13 @@ expect(dsl).to have_received :call_change_listeners end describe 'with the same text' do - let(:event) {double 'Bad Event', source: source} - let(:source) {double 'Our source', text: text} - let(:text) {'Double call'} + let(:event) { double 'Bad Event', source: source } + let(:source) { double 'Our source', text: text } + let(:text) { 'Double call' } it 'does not call the change listeners' do subject.text = text allow(event).to receive(:instance_of?) do |klazz| klazz == Java::OrgEclipseSwtEvents::ModifyEvent @@ -88,10 +93,10 @@ expect(real).to have_received(:set_selection).with(42) end end describe Shoes::Swt::EditLine do - subject {Shoes::Swt::EditLine.new dsl, swt_app} + subject { Shoes::Swt::EditLine.new dsl, swt_app } describe ":secret option" do context "when NOT set" do it "does NOT set PASSWORD style" do options = Shoes::Swt::EditLine::DEFAULT_STYLES allow(dsl).to receive(:secret?) { false }