These are chat archives for dry-rb/chat

3rd
Oct 2016
Rafael George
@cored
Oct 03 2016 00:18
do you guys know about a good article on manipulating the ast in Ruby ?
Piotr Solnica
@solnic
Oct 03 2016 00:59
@cored what ast?
Maciej Mensfeld
@mensfeld
Oct 03 2016 09:00

Hey @solnic I've updated to 0.10 (great job btw) and it brreaks when I have a subschema and it does not exist. Am I doing something wrong or is there an api change?

# define subschema:
required(:raw).schema(Raw)

and the spec:

    context 'when it is not valid' do
      before { input[:raw] = rand }

      it { expect { schema_result }.to raise_error(OffendingEngine::Errors::InvalidAttributes) }
    end

instead I get this:

  1) #<#<Class:0x00000003cb1af8>:0x00000003b6e420> #raw when it is not present should raise OffendingEngine::Errors::InvalidAttributes
     Failure/Error: it { expect { schema_result }.to raise_error(OffendingEngine::Errors::InvalidAttributes) }

       expected OffendingEngine::Errors::InvalidAttributes, got #<TypeError: no implicit conversion of Symbol into Integer> with backtrace:
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:111:in `[]'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:111:in `block in initialize_placeholders!'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:104:in `each'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:104:in `reduce'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:104:in `initialize_placeholders!'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:25:in `initialize'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:14:in `new'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_set.rb:14:in `[]'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/message_compiler.rb:39:in `call'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/result.rb:54:in `message_set'
         # /home/mencio/.rvm/gems/ruby-2.3.1@enjin/gems/dry-validation-0.10.3/lib/dry/validation/result.rb:42:in `messages'
         # ./lib/offending_engine/schemas/base.rb:30:in `call'
         # ./spec/lib/offending_engine/schemas/result_spec.rb:3:in `block (2 levels) in <top (required)>'
         # ./spec/lib/offending_engine/schemas/result_spec.rb:25:in `block (5 levels) in <top (required)>'
         # ./spec/lib/offending_engine/schemas/result_spec.rb:25:in `block (4 levels) in <top (required)>'
     # ./spec/lib/offending_engine/schemas/result_spec.rb:25:in `block (4 levels) in <top (required)>'
ah and the raw schema looks like that (but I think it is irrelevant):
# frozen_string_literal: true
module OffendingEngine
  module Schemas
    # Schema that is used to validate the raw validation result information that by default
    # should be equal or similar to the OffendingEngine::Shell execution result
    Raw = Dry::Validation.Schema(Base) do
      required(:stdout) { str? | array? | type?(Hash) }
      required(:stderr) { str? | array? | type?(Hash) }
      required(:exit_code) { int? & gteq?(0) & lteq?(255) }
    end
  end
end
Rafael George
@cored
Oct 03 2016 10:47
@solnic manipulating the source code. I want to do some sort of anlysis
Piotr Solnica
@solnic
Oct 03 2016 15:21
@mensfeld pls report an issue
Maciej Mensfeld
@mensfeld
Oct 03 2016 21:44
@solnic ok