Sha256: 46ed62245292ad3e4e2be83d078b37adde6c09bb8bad3946f84a2e9b0622136e
Contents?: true
Size: 1.59 KB
Versions: 5
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true RSpec.describe Fear::Utils do describe ".assert_arg_or_block!" do def assert_arg_or_block!(*args, &block) described_class.assert_arg_or_block!(:the_method, *args, &block) end context "block given, argument does not given" do subject { proc { assert_arg_or_block! {} } } it { is_expected.not_to raise_error } end context "argument given, block does not given" do subject { proc { assert_arg_or_block!(42) } } it { is_expected.not_to raise_error } end context "argument and block given at the same time" do subject { proc { assert_arg_or_block!(42) {} } } it "fails with argument error" do is_expected.to raise_error( ArgumentError, "#the_method accepts either one argument or block", ) end end context "no argument and no block given" do subject { proc { assert_arg_or_block! } } it "fails with argument error" do is_expected.to raise_error( ArgumentError, "#the_method accepts either one argument or block", ) end end end describe "assert_type!" do context "value is of the given type" do subject { proc { described_class.assert_type!(24, Integer) } } it { is_expected.not_to raise_error } end context "value is not of the given type" do subject { proc { described_class.assert_type!(24, String) } } it "raises TypeError" do is_expected.to raise_error( TypeError, "expected `24` to be of String class", ) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
fear-3.0.0 | spec/fear/utils_spec.rb |
fear-2.0.1 | spec/fear/utils_spec.rb |
fear-2.0.0 | spec/fear/utils_spec.rb |
fear-1.2.0 | spec/fear/utils_spec.rb |
fear-1.1.0 | spec/fear/utils_spec.rb |