Sha256: 78f16dec5cf6a6c994deb4a458b89e1773e5923a1583e87d0b406c880fe77f66

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

class AccessorsTestScreen
  include TE3270

  text_field(:method_name, 1, 2, 10, true)
  text_field(:read_only, 2, 3, 12, false)
  text_field(:default_editable, 3, 4, 14)
end

describe TE3270::Accessors do

  let(:platform) { double('platform') }
  let(:screen_object) { AccessorsTestScreen.new platform }

  before(:each) do
    screen_object.stub(:platform).and_return platform
  end

  describe "text_field accessors" do

    it 'should generate a method to retrieve the value' do
      screen_object.should respond_to :method_name
    end

    it 'should generate a method to set the value' do
      screen_object.should respond_to :method_name=
    end

    it 'should not generate a method to set the value if it is not editable' do
      screen_object.should_not respond_to :read_only=
    end

    it 'should default to being editable when it is not specified' do
      screen_object.should respond_to :default_editable=
    end

    it 'should use the platform to get the text value' do
      platform.should_receive(:get_string).with(1, 2, 10).and_return('abc')
      screen_object.method_name.should == 'abc'
    end

    it 'should use the platform to set the text value' do
      platform.should_receive(:put_string).with('abc', 1, 2)
      screen_object.method_name = 'abc'
    end

  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
te3270-0.5.1-x64-mingw32 spec/lib/te3270/accessors_spec.rb
te3270-0.4.1-x86-mingw32 spec/lib/te3270/accessors_spec.rb
te3270-0.4-x86-mingw32 spec/lib/te3270/accessors_spec.rb
te3270-0.3-x86-mingw32 spec/lib/te3270/accessors_spec.rb
te3270-jruby-0.1-universal-java-1.7 spec/lib/te3270/accessors_spec.rb
te3270-0.2-x86-mingw32 spec/lib/te3270/accessors_spec.rb
te3270-0.1-x86-mingw32 spec/lib/te3270/accessors_spec.rb