GithubHelp home page GithubHelp logo

Comments (9)

wied03 avatar wied03 commented on July 18, 2024

stub_const has always had lingering issues. I've never been a fan of it in my tests though so it hasn't been a problem for me. Frankly, I can't imagine it becoming much of a priority as long as Opal's underlying constant issue is there.

If I get some time I'll try and see what's going on. Most of my energy right now though has to go towards getting RSpec 3.4 working.

from opal-rspec.

catmando avatar catmando commented on July 18, 2024

no big deal but do you have any recommendation for fixing that spec? What I am doing now is to just declare TestMod123::Bar outside the spec, and let it sit there... These test structures go back to @zetachang, so perhaps there is a better way?

from opal-rspec.

wied03 avatar wied03 commented on July 18, 2024

Any reason they have to be assigned a constant? Why not do it like this?

  it "can add class names by the haml .class notation" do
    mod123 = Class.new(React::Component::Base) do
      collect_other_params_as :attributes
      def render
        "a man walks into a bar".span(attributes)
      end
    end
    foo = Class.new(React::Component::Base) do
      def render
        mod123().the_class
      end
    end

    expect(React.render_to_static_markup(React.create_element(foo))).to eq('<span class="the-class">a man walks into a bar</span>')
  end

from opal-rspec.

catmando avatar catmando commented on July 18, 2024

Most cases yes, but specifically I need to test that TestMod123::Bar works... so I need at least one test that I do assign to a constant...

from opal-rspec.

wied03 avatar wied03 commented on July 18, 2024

Why though? Is this to test the React display name stuff?

from opal-rspec.

catmando avatar catmando commented on July 18, 2024

No because in the dsl you can do this:

def render
TestMod123::Bar()
end

from opal-rspec.

wied03 avatar wied03 commented on July 18, 2024

OK I see. You're testing the equivalent of this: http://ruby-doc.org/core-2.2.3/Kernel.html#method-i-String

from opal-rspec.

wied03 avatar wied03 commented on July 18, 2024

I think doing this with any type of anonymous class will be difficult. Even in MRI, included doesn't know the name of the class yet. Getting opal and opal-rspec to do something different could be quite tricky and probably not desirable.

code:

module Foo
  def self.included(base)
    puts "we are #{base}"
  end
end

class Bar
  include Foo
end

Toodles = Class.new do
  include Foo
end

MRI output:

we are Bar
we are #<Class:0x007fc08b886a78>

I think even with vanilla RSpec on MRI, you wouldn't get this to work without hacking/calling included again, etc.

I think creating a normal fixture class outside of the test might be your best option. Might want to make the behavior fail gracefully in case someone wants to use an anonymous class for a React component.

from opal-rspec.

elia avatar elia commented on July 18, 2024

missing/broken features are now tracked by spec filters on master

from opal-rspec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.