Sha256: 0df2750fbd330abd292697725dd69d308fb24fe2e04d2f9951d57cc0d4aec8b9
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require 'spec_helper' RSpec.describe SmartPolling do describe "poll" do context "returning false" do let(:block) { -> { false } } it "raises SmartPolling::TimeoutError" do expect { SmartPolling.poll(seconds: 0.2, delay: 0.05, &block) }. to raise_error(SmartPolling::TimeoutError) end it "raises a custom error" do expect { SmartPolling.poll(seconds: 0.2, delay: 0.05, timeout_error: StandardError.new("custom_error"), &block) }. to raise_error(StandardError, "custom_error") end end context "returning true after some calls" do let(:block) do values = [false, false, "return_value", "another_return_value"] -> { values.shift } end it "returns the first non-false value" do expect(SmartPolling.poll(seconds: 0.2, delay: 0.05, &block)).to eq("return_value") end end context "returning some value" do let(:block) { -> { "return_value" } } it "returns the value" do expect(SmartPolling.poll(seconds: 0.2, delay: 0.05, &block)).to eq("return_value") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_polling-0.0.2 | spec/smart_polling_spec.rb |
smart_polling-0.0.1 | spec/smart_polling_spec.rb |