These are chat archives for opal/opal

5th
May 2015
Forrest Chang
@fkchang
May 05 2015 01:19
@elia @adambeynon so adding Template::OutputBuffer#<<() gets me most of the way, but it seems that fail_with() is still trying to do `message << etc where message is a string. Where's the right place to fix that?
Forrest Chang
@fkchang
May 05 2015 01:30
@elia @adambeynon it seems weird that I'm hitting this error at all, IMO, wouldn't I have hit hit fail_with() before? I wonder if something else is wrong.
uninitialized constant RSpec::Expectations::Differ::PP
ought to have hit that before, need more info on how you guys "fixed" rspec to work w/opal
Forrest Chang
@fkchang
May 05 2015 02:01
@elia @adambeynon hmm, my fix was pretty ugly
with this as a monkey patch, specs will run w/templates (If this is right I can try a PR or 2)
class Template
  class OutputBuffer
    def attributes
      {}
    end

    def <<(what)
      # puts "OutputBuffer#<<"
      append what
    end
  end
end

::PP = Kernel
module RSpec
  module Expectations
    class Differ
      def diff_as_string(input_data_new, input_data_old)
        # real diff and encoding code hard, get it to pass for now
        old_input = input_data_old.is_a?(Array) ? input_data_old.join("") : input_data_old.to_s
        new_input = input_data_new.is_a?(Array) ? input_data_new.join("") : input_data_new.to_s
        return new_input + ' vs ' + old_input
      end
    end
  end
end

module RSpec
  module Expectations
    class << self
      def fail_with(message, expected=nil, actual=nil)
        if !message
          raise ArgumentError, "Failure message is nil. Does your matcher define the " +
                               "appropriate failure_message_for_* method to return a string?"
        end

        if actual && expected
          if all_strings?(actual, expected)
            if any_multiline_strings?(actual, expected)
              # message << "\nDiff:" << differ.diff_as_string(coerce_to_string(actual), coerce_to_string(expected))
              message = message + "\nDiff:" + differ.diff_as_string(coerce_to_string(actual), coerce_to_string(expected))
            end
          elsif no_procs?(actual, expected) && no_numbers?(actual, expected)
            # message << "\nDiff:" << differ.diff_as_object(actual, expected)
            message = message + "\nDiff:" + differ.diff_as_object(actual, expected)
          end
        end

        raise(RSpec::Expectations::ExpectationNotMetError.new(message))
      end

    end
  end
end
Elia Schito
@elia
May 05 2015 06:18
@fkchang please send the PR, with a failing test if you can
Elia Schito
@elia
May 05 2015 08:04
@fkchang just to clarify you should open an issue on Opal-rspec as discussing there is much more convenient and easily discoverable
The way opal-rspec works is by a series of monkey patches, many of th are related to mutable strings
Elia Schito
@elia
May 05 2015 08:19
@meh speaking of throw/catch (in Ruby) I wonder if they can be implemented with labels instead of exceptions… cc @vais
Adam Beynon
@adambeynon
May 05 2015 10:40
@elia ping?
Elia Schito
@elia
May 05 2015 10:56
@adambeynon hey there
Adam Beynon
@adambeynon
May 05 2015 11:14
@elia I have fixed the pressing issues left in the 0.8 milestone, do you think the others need fixing before release? (or even before a beta/pre)
Elia Schito
@elia
May 05 2015 11:18
@adambeynon I don't think it's worth it, they're not something particularly meaningful in relation to a release, just bugs
@adambeynon I'd release as soon as possible, allowing all those projects that were orphaned by broken sourcemaps (e.g. react.rb)
Vais Salikhov
@vais
May 05 2015 11:27
@adambeynon is back!
Vais Salikhov
@vais
May 05 2015 11:45
@elia something like this (http://stackoverflow.com/a/14822502)
LABEL1: do {
  x = x + 2;
  ...
  // JUMP TO THE END OF THE DO-WHILE - A FORWARDS GOTO
  if (x < 100) break LABEL1;
  // JUMP TO THE START OF THE DO WHILE - A BACKWARDS GOTO...
  if (x < 100) continue LABEL1;
} while(0);
Elia Schito
@elia
May 05 2015 12:10
@vais that's what I meant
Vais Salikhov
@vais
May 05 2015 13:09
@elia this trick only works within a function and does not work across function boundaries, unless I'm missing something.
Elia Schito
@elia
May 05 2015 13:16
@vais super-bright :bulb: idea retired :smile:
Vais Salikhov
@vais
May 05 2015 13:19
@elia well, there's this: http://summerofgoto.com/
:)
Forrest Chang
@fkchang
May 05 2015 16:16
@elia so in my monkey patches, the 1st one for Template::OutputBuffer could/should go into opal, the others makes sense to go to opal-rspec -- should it go in the fixes.rb file? How do you coordinate across gems where 1 fix goes in 1 gem and the other. I could monkey patch it in opal-rspec, ensuring that older than master versions of opal get it and/or patch it in opal
Elia Schito
@elia
May 05 2015 16:17
@fkchang open 2 issues/PRs and just ref from one another
Forrest Chang
@fkchang
May 05 2015 16:42
@elia what if I want the fix to go into 0.7.* as well? I do need to see if we can update our app to master 0.8, last time it didn't work out well and I had to revert
Forrest Chang
@fkchang
May 05 2015 20:27
@elia @adambeynon @meh I tried to make a chrome console panel plugin, turns out Chrome won't let you do eval unless you sandbox
Elia Schito
@elia
May 05 2015 20:32
@fkchang his they do it for coffeeescript?
Forrest Chang
@fkchang
May 05 2015 20:34
trying to figure that out