Sha256: 79b6086189fb5dac72f256e6be3329d3e1e38222f770d2ad2ee0bdfd684fafe5

Contents?: true

Size: 623 Bytes

Versions: 13

Compression:

Stored size: 623 Bytes

Contents

module Clapton
  module TestHelper
    module Base
      require "execjs"

      def render_component(component, **kwargs)
        js = File.read(File.join(__dir__, "..", "javascripts", "dist", "components.js"))
        Dir.glob(Rails.root.join("app", "components", "**", "*.rb")).each do |file|
          js += Ruby2JS.convert(File.read(file), preset: true)
          js += "\n"
        end
        context = ExecJS.compile(js)
        html = context.eval("new #{component.name.camelize}(#{kwargs.to_json}).render")
        @page = Capybara.string(html)
      end

      def page
        @page
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
clapton-0.0.13 lib/clapton/test_helper/base.rb
clapton-0.0.12 lib/clapton/test_helper/base.rb
clapton-0.0.11 lib/clapton/test_helper/base.rb
clapton-0.0.10 lib/clapton/test_helper/base.rb
clapton-0.0.9 lib/clapton/test_helper/base.rb
clapton-0.0.8 lib/clapton/test_helper/base.rb
clapton-0.0.7 lib/clapton/test_helper/base.rb
clapton-0.0.6 lib/clapton/test_helper/base.rb
clapton-0.0.5 lib/clapton/test_helper/base.rb
clapton-0.0.4 lib/clapton/test_helper/base.rb
clapton-0.0.3 lib/clapton/test_helper/base.rb
clapton-0.0.2 lib/clapton/test_helper/base.rb
clapton-0.0.1 lib/clapton/test_helper/base.rb