Sha256: 77f2108ece9059e9e2af90e6e944334870affb016fab863e3a4a863a7c49c56e

Contents?: true

Size: 932 Bytes

Versions: 1

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

require 'mshard'

describe MShard::MShard do
  it '#try works' do
    expect(subject.try { :result }).to be(:result)
  end
  it '#try works with an error' do
    expect { subject.try(delay: 0.01) { raise } }.to raise_error(StandardError)
  end

  describe '#get' do
    before do
      expect(described_class).to receive(:get)
        .with('/v2/shards/id').and_return(double(body: :done))
    end

    it '#get works' do
      expect(subject.get(:id)).to eq(:done)
    end

    it '#get_safe works' do
      expect(subject.get_safe(:id)).to eq(:done)
    end
  end

  describe '#set' do
    before do
      expect(described_class).to receive(:post)
        .with('/v2/shards', body: :params).and_return('id' => :id)
    end

    it '#set works' do
      expect(subject.set(:params)).to eq(:id)
    end

    it '#set_safe works' do
      expect(subject.set_safe(:params)).to eq(:id)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mshard-0.8.0 spec/lib/mshard/mshard_spec.rb