Sha256: 69fcb9323b1fdf61b3b66ccd8f4fec8aea6ddda3f151aa78af8207bd53cc3f38

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

describe Ferver::FileIdRequest do
  describe 'creating new instance' do
    context 'when valid Integer is passed' do
      subject { Ferver::FileIdRequest.new(1) }

      it 'should return expected value' do
        expect(subject.value).to eq(1)
      end
    end

    context 'when nil argument is passed' do
      it 'should be invalid' do
        id_request = Ferver::FileIdRequest.new(nil)

        expect(id_request.valid?).to be_falsey
      end
    end
  end

  describe '#value= method' do
    subject { Ferver::FileIdRequest.new }

    context 'when valid Integer is passed' do
      before { subject.value = 1 }

      it 'should be valid' do
        expect(subject.valid?).to be_truthy
      end

      it 'should return expected value' do
        expect(subject.value).to eq(1)
      end
    end

    context 'when valid String as Integer is passed' do
      before { subject.value = '1' }

      it 'should be valid' do
        expect(subject.valid?).to be_truthy
      end

      it 'should return expected value' do
        expect(subject.value).to eq(1)
      end
    end

    context 'when a string is passed' do
      before { subject.value = 'foo' }

      it 'should be invalid' do
        expect(subject.valid?).to be_falsey
      end
    end

    context 'when an empty string is passed' do
      it 'should be invalid' do
        subject.value = ''

        expect(subject.valid?).to be_falsey
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ferver-1.3.0 spec/file_id_request_spec.rb
ferver-1.2.1 spec/file_id_request_spec.rb
ferver-1.2.0 spec/file_id_request_spec.rb