# frozen_string_literal: true
require "em-hiredis"
require "test_helper"
require "btc_sell_prices"
class BTCSellPricesTest < Minitest::Test
def setup
@redis = Minitest::Mock.new
@subject = BTCSellPrices.new(@redis, "")
end
def test_cad
stub_request(:get, "https://www.canadianbitcoins.com").to_return(
body: "
" \
"Bitcoin | | $123.00 | "
)
assert_equal BigDecimal.new(123), @subject.cad.sync
end
em :test_cad
def test_usd
stub_request(:get, "https://www.canadianbitcoins.com").to_return(
body: "" \
"Bitcoin | | $123.00 | "
)
@redis.expect(:get, EMPromise.resolve("0.5"), ["cad_to_usd"])
assert_equal BigDecimal.new(123) / 2, @subject.usd.sync
end
em :test_usd
end