Sha256: 555b06fe7b4a1c53da9a981c758bd8ab0a2e1910678c62529293bcbb043e9c8b

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

describe Xcmonkey do
  let(:params) { { udid: '123', bundle_id: 'example.com.app', duration: 10, session_path: Dir.pwd } }
  let(:duration_error_msg) { 'Duration must be Integer and not less than 1 second' }

  before do
    allow(Logger).to receive(:info)
  end

  it 'verifies gestures' do
    gestures = described_class.new(params).gestures
    taps = [:precise_tap, :blind_tap] * 10
    swipes = [:precise_swipe, :blind_swipe] * 5
    presses = [:precise_press, :blind_press]
    expect(gestures) =~ presses + taps + swipes
  end

  it 'verifies required params' do
    expect(Logger).not_to receive(:error)
    described_class.new(params)
  end

  it 'verifies `udid` param is required' do
    params[:udid] = nil
    expect(Logger).to receive(:error).with('UDID should be provided')
    described_class.new(params)
  end

  it 'verifies `bundle_id` param is required' do
    params[:bundle_id] = nil
    expect(Logger).to receive(:error).with('Bundle identifier should be provided')
    described_class.new(params)
  end

  it 'verifies `duration` param is optional' do
    params[:duration] = nil
    expect(Logger).not_to receive(:error)
    described_class.new(params)
  end

  it 'verifies `duration` param cannot be equal to zero' do
    params[:duration] = 0
    expect(Logger).to receive(:error).with(duration_error_msg)
    described_class.new(params)
  end

  it 'verifies `duration` param cannot be negative' do
    params[:duration] = -1
    expect(Logger).to receive(:error).with(duration_error_msg)
    described_class.new(params)
  end

  it 'verifies version' do
    current_version = Gem::Version.new(Xcmonkey::VERSION)
    expect(current_version).to be > Gem::Version.new('0.1.0')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xcmonkey-1.2.0 spec/xcmonkey_spec.rb