Skip to content

Commit

Permalink
Write a spec that triggers the bug I'm trying to fix
Browse files Browse the repository at this point in the history
The expectation is that the code won't trigger an exception, but it
does:

    ActiveJSON::Base.create does not fail when the loaded JSON was empty
    Failure/Error: Empty.create()
    NoMethodError:
      undefined method `length' for nil:NilClass
    # ./lib/active_hash/base.rb:135:in `insert'
    # ./lib/active_hash/base.rb:497:in `save'
    # ./lib/active_hash/base.rb:174:in `create'
    # ./spec/active_json/base_spec.rb:51:in `block (3 levels) in <top (required)>'
  • Loading branch information
davidstosik committed Mar 5, 2020
1 parent 3356174 commit 49c35a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/active_json/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class Empty < ActiveJSON::Base ; end # Empty JSON
end
end

describe ".create" do
it "does not fail when the loaded JSON was empty" do
Empty.create()
end
end

describe ".delete_all" do
context "when called before .all" do
it "causes all to not load data" do
Expand Down

0 comments on commit 49c35a1

Please sign in to comment.