Sha256: c0f9a94008b191cd938c587a53e8423fe4f81d9b72534e7d4c92bae481a5db22

Contents?: true

Size: 1.51 KB

Versions: 21

Compression:

Stored size: 1.51 KB

Contents

require 'spec_helper'

if opal?

module Components

  module Controller
    class Component1
      include React::Component
      def render
        self.class.name.to_s
      end
    end
  end

  class Component1
    include React::Component
    def render
      self.class.name.to_s
    end
  end

  class Component2
    include React::Component
    def render
      self.class.name.to_s
    end
  end
end

module Controller
  class SomeOtherClass  # see issue #80
  end
end

class Component1
  include React::Component
  def render
    self.class.name.to_s
  end
end


def render_top_level(controller, component_name)
  React.render_to_static_markup(React.create_element(
    React::TopLevelRailsComponent, {controller: controller, component_name: component_name, render_params: {}}))
end

describe React::TopLevelRailsComponent do

  it 'uses the controller name to lookup a component' do
    expect(render_top_level("Controller", "Component1")).to eq('<span>Components::Controller::Component1</span>')
  end

  it 'can find the name without matching the controller' do
    expect(render_top_level("Controller", "Component2")).to eq('<span>Components::Component2</span>')
  end

  it 'will find the outer most matching component' do
    expect(render_top_level("OtherController", "Component1")).to eq('<span>Component1</span>')
  end

  it 'can find the correct component when the name is fully qualified' do
    expect(render_top_level("Controller", "::Components::Component1")).to eq('<span>Components::Component1</span>')
  end

end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
reactrb-0.8.8 spec/react/top_level_component_spec.rb
reactrb-0.8.7 spec/react/top_level_component_spec.rb
reactrb-0.8.6 spec/react/top_level_component_spec.rb
reactrb-0.8.5 spec/react/top_level_component_spec.rb
reactrb-0.8.4 spec/react/top_level_component_spec.rb
reactrb-0.8.3 spec/react/top_level_component_spec.rb
reactrb-0.8.1 spec/react/top_level_component_spec.rb
reactrb-0.8.0 spec/react/top_level_component_spec.rb
reactrb-0.7.42 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.41 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.40 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.39 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.38 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.36 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.35 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.34 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.33 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.32 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.31 spec/react/top_level_component_spec.rb
reactive-ruby-0.7.30 spec/react/top_level_component_spec.rb