Sha256: fe01816f3093794ae3bda5367b4a3eec090b2caa1e7a0c48f3a607260824fd31

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

class ScreenFactoryScreen
  include TE3270
end

class WorldSuper
  attr_reader :super_called
  def on(screen_class, &block)
    @super_called = true
  end
end

class World < WorldSuper
  include TE3270::ScreenFactory
end

describe TE3270::ScreenFactory do

  let(:world) { World.new }

  it 'should create a new screen object' do
    emulator = double('platform')
    world.instance_variable_set('@emulator', emulator)
    world.on(ScreenFactoryScreen).should be_instance_of ScreenFactoryScreen
  end

  it 'should create a new screen object and execute a block' do
    emulator = double('platform')
    world.instance_variable_set('@emulator', emulator)
    world.on(ScreenFactoryScreen) do |page|
      page.should be_instance_of ScreenFactoryScreen
    end
  end

  it 'should raise an error when an @emulator instance variable does not exist' do
    expect { world.on(ScreenFactoryScreen) }.to raise_error("@emulator instance variable must be available to use the ScreenFactory methods")
  end

  it 'should pass control to super if passed a class that does not include TE3270' do
    class NoTE
    end
    emulator = double('platform')
    world.instance_variable_set('@emulator', emulator)
    world.on(NoTE)
    world.super_called.should be true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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