dry-rb / dry-transaction

Business transaction DSL
http://dry-rb.org/gems/dry-transaction
MIT License
468 stars 55 forks source link

Unexpected results with inheritance #123

Open dnagir opened 5 years ago

dnagir commented 5 years ago

I was trying to abstract the common workflow using inheritance (generating new Class with Dry::Transaction included).

It was expected that it would behave just like a normal Dry::Transaction but it isn't.

TLDR: these tests are failing while I was expecting those to pass.

Full repro with tests - this gist.

Run the repro:

curl -s https://gist.githubusercontent.com/dnagir/71907e1b09e8be817d0644b5be1c29eb/raw/a6d9b8abacf873a2708bf82b9d714f82716d8ea5/example.rb | ruby
Run options: --seed 3951

# Running:

..FF

Finished in 0.002973s, 1345.4421 runs/s, 1345.4421 assertions/s.

  1) Failure:
InheritedAndHasUnexpectedBahviour#test_invalid [-:120]:
Expected: {:name=>["must be filled"]}
  Actual: {}

  2) Failure:
InheritedAndHasUnexpectedBahviour#test_valid [-:124]:
Expected: Success("yay")
  Actual: Success({:name=>"foo"})

4 runs, 4 assertions, 2 failures, 0 errors, 0 skips