Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 03 11:41
    cuilei5205189 starred dry-rb/dry-monads
  • Jul 02 11:26
    flash-gordon commented #97
  • Jul 01 09:55
    solnic opened #441
  • Jul 01 09:54
    solnic opened #242
  • Jun 30 17:02
    ahoward commented #97
  • Jun 30 17:01
    ahoward commented #97
  • Jun 30 16:58
  • Jun 30 09:01
    flash-gordon commented #97
  • Jun 30 03:07
    ahoward labeled #97
  • Jun 30 03:07
    ahoward opened #97
  • Jun 30 03:07
    ahoward labeled #97
  • Jun 28 13:44
  • Jun 28 10:17
    kroolp commented #83
  • Jun 28 07:49
    solnic commented #83
  • Jun 28 07:47
    solnic commented #84
  • Jun 27 16:07
    kroolp review_requested #84
  • Jun 27 16:07
    kroolp opened #84
  • Jun 27 16:05
    kroolp labeled #83
  • Jun 27 16:05
    kroolp labeled #83
  • Jun 27 16:05
    kroolp opened #83
Spencer Goh
@dymaxionuk
The reason I'm subbing out one of the steps (2nd step), is that the first step basically exits fast, on certain condition. So I only want my test to check that on one condition the second step is called, as other condition the second step is not called.
The downside of allowing my second step to be executed fully, is that it then pulls another operation from my container... That operation then auto injects some repos etc and the injection then forced me to pull in my db spec helper instead of just vanilla spec helper. I don't need to test such a bit surface area in this case.
Spencer Goh
@dymaxionuk
In testing that full code path for step two in my full end to end tests, as there is little value unit testing that. So bottom line is I should be able to do: ```expect(transction).to receive(:blah_step).and_return(dummy_data)
Piotr Solnica
@solnic
maybe it's using method objects, so rspec expectation can't work with it, not sure
@dymaxionuk Sounds like you’ve hit this issue? dry-rb/dry-transaction#75
Someone has promised to fix it, but they’ve taken months. I’ll see if I can do it myself sometime soon (or I’d be happy if you wanted to have a go, too!)
Jonah
@jonahx
:thumbsup: to new release!
@flash-gordon ^
Vasily Kolesnikov
@v-kolesnikov
:+1: :clap:
Nikita Shilnikov
@flash-gordon
pretty cool huh :)
Gustavo Caso
@GustavoCaso
:clap: :clap:
Spencer Goh
@dymaxionuk
Thanks @timriley wish I had time to explore, between slaving away at work and looking after baby, not much time left! I'll have a look if I get a breather.
On another note, is anyone interested in a trace/debug logging default for the dry transaction program flow? Given that the shape of the data will change significantly between each operation, and not all Failure states are necessarily triggered by Exception/Error, it can be useful in DEV deployment to have more colour over what caused failures. When one can't debug locally.
Spencer Goh
@dymaxionuk
I have an issue with an intermittent failure in a test, which doesn't manifest locally but only on the CI server. The output of roda flow driven dry transaction is returning a monad with True class as value. The only logging is the final backtrace in the router. But I would be useful to see the data and program flow along the whole execution path of the transaction, into it returns to route
70% of the time it returns my intended value object ... I can track it down but might be nice to have a trace feature. Any other use cases other people have across like this? Do you just add a ton of hand crafted logging manually?
Maybe option trace_transaction, true
Gustavo Caso
@GustavoCaso
I'm not a very experience dry-validations user but I wanted to share a question regarding some bahaviour I found for error messages
Having this schema
BusyPeriods = Dry::Validation.Schema do
  each do
    schema do
      required(:start_date).filled(:date?)
      required(:end_date).filled(:date?)
      required(:utilisation).filled(:int?)

      rule(started_before_ended: [:start_date, :end_date]) do |start_date, end_date|
        end_date.gt?(value(:start_date))
      end
    end
  end
end
If I try to validate some data if the error is related with the required attributes I will get a message with the format { index => error_message } but if the error comes from the rule I will get just the error with out the index. Is that expected?
{0=>{:utilisation=>["must be an integer"]}}
{:started_before_ended=>["must be greater than 2018-03-21"]}
Piotr Solnica
@solnic
@GustavoCaso end_date.gt?(start_date)
Gustavo Caso
@GustavoCaso
Thanks @solnic
Christian Meier
@mkristian
hi, found some in the issue of dry-validation how to reuse a Schema for nested arrays. wanted to extend the documentation a bit, is it to make a PR against: https://github.com/dry-rb/dry-rb.org ?
looks like autogenerated somehow !
Aaron Barthel
@abrthel
@mkristian from that link, then follow this folder path source > gems > dry-validation From there you just have to edit the markdown files
Christian Meier
@mkristian
ok - thanks. and I leave gz file as is ?
Aaron Barthel
@abrthel
under docs? Yeah you dont need to alter them at all. The markdown files get rendered into the actual deployable site.
Nicolas Cavigneaux
@Bounga
Hi there. I'm playing with Dry Types and I'm wondering if it is possible to do something like Types::Strict::String.constrained(filled: true) ?
Gustavo Caso
@GustavoCaso
Absolutely you can
Nicolas Cavigneaux
@Bounga
Is this the right syntax ?
Gustavo Caso
@GustavoCaso
Yes
Nicolas Cavigneaux
@Bounga
Seems like it doesn't work in my example code
Gustavo Caso
@GustavoCaso
Types::Strict::String.constrained(filled: true).('')
Dry::Types::ConstraintError: "" violates constraints (filled?("") failed)
Types::Strict::String.constrained(filled: true).(nil)
Dry::Types::ConstraintError: nil violates constraints (type?(String, nil) AND filled?(nil) failed)
Nicolas Cavigneaux
@Bounga
oh I should have said this before but I use it through Hanami, so I have attribute :ref, Types::Strict::Int.constrained(filled: true)
Gustavo Caso
@GustavoCaso
Types::Strict::String.constrained(filled: true).('helllo')
=> "helllo"
Could you provide the version is using?
Nicolas Cavigneaux
@Bounga
0.12.2
Gustavo Caso
@GustavoCaso
What error do you see? I guess is possible to do in master
Nicolas Cavigneaux
@Bounga
I don't have any error, it just doesn't constrain the attribute to be filled
User.new(uid: 1, email: "foo", role: "admin").ref
=> nil
Gustavo Caso
@GustavoCaso
I'm not an expert in Hanami, but let me see if I can help
Nicolas Cavigneaux
@Bounga
irb(main):011:0> class Testing < Hanami::Entity
irb(main):012:1> attributes do
irb(main):013:2* attribute :ref, Types::Strict::Int.constrained(filled: true)
irb(main):014:2> end
irb(main):015:1> end
=> true
irb(main):016:0> Testing.new.ref
=> nil
oh
irb(main):017:0> Testing.new(ref: nil)
TypeError: nil (NilClass) has invalid type for :ref violates constraints (type?(Integer, nil) AND filled?(nil) failed)
Gustavo Caso
@GustavoCaso
If you remove the constrained part ?
So looks like is working, just need to pass the values :smile: