Sha256: 804c16533f6c2e0637fa2c43b1b31e4608a6df8058732843f20727cc09e0839b

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 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

4 entries across 4 versions & 1 rubygems

Version Path
te3270-0.7.1 spec/lib/te3270/accessors_spec.rb
te3270-0.7.0 spec/lib/te3270/accessors_spec.rb
te3270-0.6.0 spec/lib/te3270/accessors_spec.rb
te3270-0.5.0-x86_64-darwin-14 spec/lib/te3270/accessors_spec.rb