Sha256: 1f229d5385b3beb63a007b3af7e7305ae89c26a27de9574ee4ebb4ac9a078318
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require "spec_helper" RSpec.describe RSpec::Grape::Entity::Matchers::HaveConditionsMetMatcher do include RSpec::Grape::Entity::Matchers::HaveConditionsMetMatcher let(:entity) { TestEntity } let(:object) { OpenStruct.new has_date: true } context "when condition a symbol" do subject(:exposure) { entity.find_exposure :record_status } it { is_expected.to have_conditions_met(object).with_options(all: true) } it { is_expected.to_not have_conditions_met(object) } end context "when condition a hash" do subject(:exposure) { entity.find_exposure :user } it { is_expected.to have_conditions_met(object).with_options(type: :admin) } it { is_expected.to_not have_conditions_met(object).with_options(type: :user) } it { is_expected.to_not have_conditions_met(object) } end context "when condition a proc" do subject(:exposure) { entity.find_exposure :created_at } let(:false_object) { OpenStruct.new date: false } it { is_expected.to have_conditions_met(object) } it { is_expected.not_to have_conditions_met(false_object) } end context "when no conditions defined" do subject(:exposure) { entity.find_exposure :id } it { is_expected.to have_conditions_met(object) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-grape-entity-0.1.0 | spec/matchers/have_conditions_met_matcher_spec.rb |