diff --git a/lib/active_interaction/base.rb b/lib/active_interaction/base.rb index 04386179..f3d5b2e0 100644 --- a/lib/active_interaction/base.rb +++ b/lib/active_interaction/base.rb @@ -147,6 +147,8 @@ def initialize_filter(filter) attr_accessor attribute + alias_method "#{attribute}?", attribute if filter.is_a?(BooleanFilter) + eagerly_evaluate_default(filter) end diff --git a/spec/active_interaction/integration/boolean_interaction_spec.rb b/spec/active_interaction/integration/boolean_interaction_spec.rb index 35078a0f..1ec891d1 100644 --- a/spec/active_interaction/integration/boolean_interaction_spec.rb +++ b/spec/active_interaction/integration/boolean_interaction_spec.rb @@ -1,3 +1,11 @@ -RSpec.describe 'BooleanInteraction' do +BooleanInteraction = Class.new(TestInteraction) do + boolean :x +end + +RSpec.describe BooleanInteraction do it_behaves_like 'an interaction', :boolean, -> { [false, true].sample } + + it 'responds to #x?' do + expect(described_class.new).to respond_to(:x?) + end end