Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mutations/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def message_list
# state: ErrorAtom(:in)
# }
# }
class ErrorHash < Hash
class ErrorHash < HashWithIndifferentAccess

# Returns a nested HashWithIndifferentAccess where the values are symbols. Eg:
# {
Expand Down
16 changes: 16 additions & 0 deletions spec/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ def execute
end
end

describe "errors can be accessed as strings and symbolicly" do
class Foo < Mutations::Command
def execute
add_error(:foo, :bar, "baz")
end
end
let(:outcome){ Foo.run }

it{ assert(outcome.errors["foo"]) }
it{ assert(outcome.errors[:foo]) }
it{ assert_equal(outcome.errors["foo"].message, "baz") }
it{ assert_equal(outcome.errors[:foo].message, "baz") }

end


describe "Bunch o errors" do
before do
@outcome = GivesErrors.run(:str1 => "", :str2 => "opt9", :int1 => "zero", :hash1 => {:bool1 => "bob"}, :arr1 => ["bob", 1, "sally"])
Expand Down