Skip to content

Commit

Permalink
Use a whitelist matcher for success requirements in guards to be more…
Browse files Browse the repository at this point in the history
… explicit with the expected values
  • Loading branch information
obrie committed Aug 15, 2009
1 parent 4efa075 commit bfe51c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/state_machine/guard.rb
Expand Up @@ -43,7 +43,7 @@ def initialize(options = {}) #:nodoc:
@event_requirement = build_matcher(options, :on, :except_on)

# Build success requirement
@success_requirement = options.delete(:include_failures) ? AllMatcher.instance : BlacklistMatcher.new([false])
@success_requirement = options.delete(:include_failures) ? AllMatcher.instance : WhitelistMatcher.new([true])

if (options.keys - [:from, :to, :on, :except_from, :except_to, :except_on]).empty?
# Explicit from/to requirements specified
Expand Down
2 changes: 1 addition & 1 deletion test/unit/guard_test.rb
Expand Up @@ -411,7 +411,7 @@ def setup
end

def test_should_use_a_blacklist_matcher
assert_instance_of StateMachine::BlacklistMatcher, @guard.success_requirement
assert_instance_of StateMachine::WhitelistMatcher, @guard.success_requirement
end

def test_should_match_if_not_specified
Expand Down

0 comments on commit bfe51c1

Please sign in to comment.