Sha256: fbc94a2e5b47524c419af3b3a1f5a985c320dea4490afc1f1ac5d5825957db67

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe 'component helpers', js: true do

  it "can mount" do

    mount "MyComponent" do
      class MyComponent < React::Component::Base
        class << self
          attr_accessor :foo
        end
        after_mount do
          self.class.foo = 12
        end
        render do
          "hello"
        end
      end
    end
    page.evaluate_ruby("MyComponent.foo").should eq(12)
    page.evaluate_ruby("TestModel").should eq("TestModel")
  end

  it "can instrument some methods" do
    mount "MyComponent" do
      class MyComponent < React::Component::Base
        def some_method
          "fact(5) = #{SomeClass.new.fact(5)}"
        end
        def render
          some_method
        end
      end
      class SomeClass
        def fact(n)
          n == 1 ? n : fact(n-1) * n
        end
      end
      SomeClass.hypertrace do
        instrument :all
        break_on_exit? :fact do |_r, n|
          puts "self = #{self}"; n == 1
        end
      end
      MyComponent.hypertrace instrument: :all, break_on_exit: [:some_method, :render]
    end
    pause
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyper-mesh-0.6.0 spec/component_helpers_xspec.rb
hyper-mesh-0.5.4 spec/component_helpers_xspec.rb
hyper-mesh-0.5.3 spec/component_helpers_xspec.rb
hyper-mesh-0.5.2 spec/component_helpers_xspec.rb
hyper-mesh-0.5.1 spec/component_helpers_xspec.rb
hyper-mesh-0.5.0 spec/component_helpers_xspec.rb
hyper-mesh-0.4.0 spec/component_helpers_xspec.rb