hyper-react 0.12.7 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +48 -34
  3. data/CODE_OF_CONDUCT.md +49 -0
  4. data/Gemfile +5 -6
  5. data/README.md +47 -98
  6. data/Rakefile +6 -28
  7. data/hyper-react.gemspec +36 -43
  8. data/lib/hyper-react.rb +4 -73
  9. data/lib/react/version.rb +3 -0
  10. metadata +91 -249
  11. data/.codeclimate.yml +0 -27
  12. data/.rubocop.yml +0 -1159
  13. data/.travis.yml +0 -62
  14. data/Appraisals +0 -31
  15. data/CHANGELOG.md +0 -143
  16. data/LICENSE +0 -19
  17. data/UPGRADING.md +0 -24
  18. data/component-name-lookup.md +0 -145
  19. data/config.ru +0 -26
  20. data/gemfiles/opal_0.10_react_13.gemfile +0 -15
  21. data/gemfiles/opal_0.10_react_14.gemfile +0 -15
  22. data/gemfiles/opal_0.10_react_15.gemfile +0 -15
  23. data/gemfiles/opal_0.8_react_13.gemfile +0 -15
  24. data/gemfiles/opal_0.8_react_14.gemfile +0 -15
  25. data/gemfiles/opal_0.8_react_15.gemfile +0 -15
  26. data/gemfiles/opal_0.9_react_13.gemfile +0 -15
  27. data/gemfiles/opal_0.9_react_14.gemfile +0 -15
  28. data/gemfiles/opal_0.9_react_15.gemfile +0 -15
  29. data/gemfiles/opal_master_react_15.gemfile +0 -16
  30. data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/components.rb +0 -3
  31. data/lib/generators/reactive_ruby/test_app/templates/assets/javascripts/test_application.rb +0 -2
  32. data/lib/generators/reactive_ruby/test_app/templates/boot.rb.erb +0 -6
  33. data/lib/generators/reactive_ruby/test_app/templates/script/rails +0 -5
  34. data/lib/generators/reactive_ruby/test_app/templates/test_application.rb.erb +0 -13
  35. data/lib/generators/reactive_ruby/test_app/templates/views/components/hello_world.rb +0 -11
  36. data/lib/generators/reactive_ruby/test_app/templates/views/components/todo.rb +0 -14
  37. data/lib/generators/reactive_ruby/test_app/templates/views/layouts/test_layout.html.erb +0 -0
  38. data/lib/generators/reactive_ruby/test_app/test_app_generator.rb +0 -111
  39. data/lib/rails-helpers/top_level_rails_component.rb +0 -54
  40. data/lib/react-sources/react-server.js +0 -2
  41. data/lib/react/api.rb +0 -173
  42. data/lib/react/callbacks.rb +0 -41
  43. data/lib/react/children.rb +0 -30
  44. data/lib/react/component.rb +0 -168
  45. data/lib/react/component/api.rb +0 -50
  46. data/lib/react/component/base.rb +0 -13
  47. data/lib/react/component/class_methods.rb +0 -189
  48. data/lib/react/component/dsl_instance_methods.rb +0 -23
  49. data/lib/react/component/params.rb +0 -6
  50. data/lib/react/component/props_wrapper.rb +0 -78
  51. data/lib/react/component/should_component_update.rb +0 -94
  52. data/lib/react/component/tags.rb +0 -129
  53. data/lib/react/config.rb +0 -5
  54. data/lib/react/config/client.rb.erb +0 -19
  55. data/lib/react/config/server.rb +0 -23
  56. data/lib/react/element.rb +0 -169
  57. data/lib/react/event.rb +0 -76
  58. data/lib/react/ext/hash.rb +0 -9
  59. data/lib/react/ext/opal-jquery/element.rb +0 -26
  60. data/lib/react/ext/string.rb +0 -8
  61. data/lib/react/hash.rb +0 -13
  62. data/lib/react/native_library.rb +0 -87
  63. data/lib/react/object.rb +0 -15
  64. data/lib/react/react-source-browser.rb +0 -3
  65. data/lib/react/react-source-server.rb +0 -3
  66. data/lib/react/react-source.rb +0 -20
  67. data/lib/react/ref_callback.rb +0 -31
  68. data/lib/react/rendering_context.rb +0 -144
  69. data/lib/react/server.rb +0 -23
  70. data/lib/react/state_wrapper.rb +0 -23
  71. data/lib/react/test.rb +0 -16
  72. data/lib/react/test/dsl.rb +0 -17
  73. data/lib/react/test/matchers/render_html_matcher.rb +0 -56
  74. data/lib/react/test/rspec.rb +0 -15
  75. data/lib/react/test/session.rb +0 -37
  76. data/lib/react/test/utils.rb +0 -25
  77. data/lib/react/top_level.rb +0 -118
  78. data/lib/react/top_level_render.rb +0 -29
  79. data/lib/react/validator.rb +0 -136
  80. data/lib/reactive-ruby/component_loader.rb +0 -50
  81. data/lib/reactive-ruby/isomorphic_helpers.rb +0 -212
  82. data/lib/reactive-ruby/rails.rb +0 -7
  83. data/lib/reactive-ruby/rails/component_mount.rb +0 -46
  84. data/lib/reactive-ruby/rails/controller_helper.rb +0 -15
  85. data/lib/reactive-ruby/rails/railtie.rb +0 -33
  86. data/lib/reactive-ruby/serializers.rb +0 -15
  87. data/lib/reactive-ruby/server_rendering/contextual_renderer.rb +0 -42
  88. data/lib/reactive-ruby/version.rb +0 -3
  89. data/lib/reactrb/auto-import.rb +0 -27
  90. data/lib/reactrb/deep-compare.rb +0 -24
  91. data/lib/reactrb/new-event-name-convention.rb +0 -11
  92. data/logo1.png +0 -0
  93. data/logo2.png +0 -0
  94. data/logo3.png +0 -0
  95. data/path_release_steps.md +0 -9
  96. data/spec/controller_helper_spec.rb +0 -34
  97. data/spec/index.html.erb +0 -11
  98. data/spec/react/callbacks_spec.rb +0 -138
  99. data/spec/react/children_spec.rb +0 -76
  100. data/spec/react/component/base_spec.rb +0 -32
  101. data/spec/react/component_spec.rb +0 -884
  102. data/spec/react/dsl_spec.rb +0 -303
  103. data/spec/react/element_spec.rb +0 -136
  104. data/spec/react/event_spec.rb +0 -24
  105. data/spec/react/native_library_spec.rb +0 -322
  106. data/spec/react/observable_spec.rb +0 -42
  107. data/spec/react/opal_jquery_extensions_spec.rb +0 -68
  108. data/spec/react/param_declaration_spec.rb +0 -269
  109. data/spec/react/react_spec.rb +0 -215
  110. data/spec/react/refs_callback_spec.rb +0 -56
  111. data/spec/react/server_spec.rb +0 -25
  112. data/spec/react/state_spec.rb +0 -55
  113. data/spec/react/test/dsl_spec.rb +0 -43
  114. data/spec/react/test/matchers/render_html_matcher_spec.rb +0 -83
  115. data/spec/react/test/rspec_spec.rb +0 -62
  116. data/spec/react/test/session_spec.rb +0 -88
  117. data/spec/react/test/utils_spec.rb +0 -28
  118. data/spec/react/top_level_component_spec.rb +0 -101
  119. data/spec/react/tutorial/tutorial_spec.rb +0 -36
  120. data/spec/react/validator_spec.rb +0 -124
  121. data/spec/reactive-ruby/component_loader_spec.rb +0 -77
  122. data/spec/reactive-ruby/isomorphic_helpers_spec.rb +0 -160
  123. data/spec/reactive-ruby/rails/asset_pipeline_spec.rb +0 -10
  124. data/spec/reactive-ruby/rails/component_mount_spec.rb +0 -66
  125. data/spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb +0 -35
  126. data/spec/spec_helper.rb +0 -149
  127. data/spec/support/react/spec_helpers.rb +0 -44
  128. data/spec/vendor/es5-shim.min.js +0 -6
  129. data/spec/vendor/jquery-2.2.4.min.js +0 -4
@@ -1,160 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe React::IsomorphicHelpers do
4
- describe 'code execution context' do
5
- let(:klass) { Class.send(:include, described_class) }
6
-
7
- describe 'module class methods', :opal do
8
- it { expect(described_class).to_not be_on_opal_server }
9
- it { expect(described_class).to be_on_opal_client }
10
- end
11
-
12
- describe 'included class methods', :opal do
13
- it { expect(klass).to_not be_on_opal_server }
14
- it { expect(klass).to be_on_opal_client }
15
- end
16
-
17
- describe 'included instance methods', :opal do
18
- it { expect(klass.new).to_not be_on_opal_server }
19
- it { expect(klass.new).to be_on_opal_client }
20
- end
21
-
22
- describe 'module class methods', :ruby do
23
- it { is_expected.to_not be_on_opal_server }
24
- it { is_expected.to_not be_on_opal_client }
25
- end
26
-
27
- describe 'included class methods', :ruby do
28
- subject { klass }
29
- it { is_expected.to_not be_on_opal_server }
30
- it { is_expected.to_not be_on_opal_client }
31
- end
32
-
33
- describe 'included instance methods', :ruby do
34
- subject { klass.new }
35
- it { is_expected.to_not be_on_opal_server }
36
- it { is_expected.to_not be_on_opal_client }
37
- end
38
- end
39
-
40
- if ruby?
41
- describe 'load_context', :ruby do
42
- let(:v8_context) { TestV8Context.new }
43
- let(:controller) { double('controller') }
44
- let(:name) { double('name') }
45
-
46
- it 'creates a context and sets a controller' do
47
- context = described_class.load_context(v8_context, controller, name)
48
- expect(context.controller).to eq(controller)
49
- end
50
-
51
- it 'creates a context and sets a unique_id' do
52
- Timecop.freeze do
53
- stamp = Time.now.to_i
54
- context = described_class.load_context(v8_context, controller, name)
55
- expect(context.unique_id).to eq("#{ controller.object_id }-#{ stamp }")
56
- end
57
- end
58
- end
59
-
60
- describe React::IsomorphicHelpers::Context do
61
- class TestV8Context < Hash
62
- def eval(args)
63
- true
64
- end
65
- end
66
-
67
- # Need to decouple/dry up this...
68
- def test_context(files = nil)
69
- js = ReactiveRuby::ServerRendering::ContextualRenderer::CONSOLE_POLYFILL.dup
70
- js << Opal::Builder.build('opal').to_s
71
- Array(files).each do |filename|
72
- js << ::Rails.application.assets[filename].to_s
73
- end
74
- js = "#{React::ServerRendering::ExecJSRenderer::GLOBAL_WRAPPER}#{js}"
75
- ctx = ExecJS.compile(js)
76
- ctx = ReactiveRuby::ServerRendering.context_instance_for(ctx)
77
- end
78
-
79
- def react_context
80
- if ::Rails.application.assets['react-server.js'] &&
81
- !::Rails.application.assets['react-server.js'].to_s.start_with?("// A placeholder file")
82
- test_context(['components', 'react-server.js'])
83
- else
84
- test_context(['components', 'react.js'])
85
- end
86
- end
87
-
88
- let(:v8_context) { TestV8Context.new }
89
- let(:controller) { double('controller') }
90
- let(:name) { double('name') }
91
- before do
92
- described_class.instance_variable_set :@before_first_mount_blocks, nil
93
- end
94
-
95
- describe '#initialize' do
96
- it "sets the given V8 context's ServerSideIsomorphicMethods to itself" do
97
- context = described_class.new('unique-id', v8_context, controller, name)
98
- expect(v8_context['ServerSideIsomorphicMethods']).to eq(context)
99
- end
100
-
101
- it 'calls before mount callbacks' do
102
- string = instance_double(String)
103
- described_class.register_before_first_mount_block do
104
- string.inspect
105
- end
106
- expect(string).to receive(:inspect).once
107
- context = described_class.new('unique-id', v8_context, controller, name)
108
- end
109
- end
110
-
111
- describe '#eval' do
112
- it 'delegates to given context' do
113
- context = described_class.new('unique-id', v8_context, controller, name)
114
- js = 'true;'
115
- expect(v8_context).to receive(:eval).with(js).once
116
- context.eval(js)
117
- end
118
- end
119
-
120
- describe '#send_to_opal' do
121
- let(:opal_code) { Opal::Builder.new.build_str(ruby_code, __FILE__) }
122
- let(:ruby_code) { %Q[
123
- module React::IsomorphicHelpers
124
- def self.greet(name)
125
- "Hello, #\{name}!"
126
- end
127
-
128
- def self.valediction
129
- 'Goodbye'
130
- end
131
- end
132
- ]}
133
-
134
- it 'raises an error when react cannot be loaded' do
135
- context = described_class.new('unique-id', v8_context, controller, name)
136
- context.instance_variable_set(:@ctx, test_context)
137
- expect {
138
- context.send_to_opal(:foo)
139
- }.to raise_error(/No react.rb components found/)
140
- end
141
-
142
- it 'executes method with args inside opal rubyracer context' do
143
- ctx = react_context
144
- context = described_class.new('unique-id', ctx, controller, name)
145
- ctx.eval(opal_code)
146
- result = context.send_to_opal(:greet, 'world')
147
- expect(result).to eq('Hello, world!')
148
- end
149
-
150
- it 'executes the method inside opal rubyracer context' do
151
- ctx = react_context
152
- context = described_class.new('unique-id', ctx, controller, name)
153
- ctx.eval(opal_code)
154
- result = context.send_to_opal(:valediction)
155
- expect(result).to eq('Goodbye')
156
- end
157
- end
158
- end
159
- end
160
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if ruby?
4
- RSpec.describe 'test_app generator' do
5
- it "does not interfer with asset precompilation" do
6
- cmd = "cd spec/test_app; BUNDLE_GEMFILE=#{ENV['REAL_BUNDLE_GEMFILE']} bundle exec rake assets:precompile"
7
- expect(system(cmd)).to be_truthy
8
- end
9
- end
10
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if ruby?
4
- RSpec.describe ReactiveRuby::Rails::ComponentMount do
5
- let(:helper) { described_class.new }
6
-
7
- before do
8
- helper.setup(ActionView::TestCase::TestController.new)
9
- end
10
-
11
- describe '#react_component' do
12
- it 'renders a div' do
13
- html = helper.react_component('Components::HelloWorld')
14
- expect(html).to match(/<div.*><\/div>/)
15
- end
16
-
17
- it 'accepts a pre-render option' do
18
- html = helper.react_component('Components::HelloWorld', {}, prerender: true)
19
- expect(html).to match(/<div.*><span.*>Hello, World!<\/span><\/div>/)
20
- end
21
-
22
- it 'sets data-react-class to React.TopLevelRailsComponent' do
23
- html = helper.react_component('Components::HelloWorld')
24
- top_level_class = 'React.TopLevelRailsComponent'
25
- expect(attr_value(html, 'data-react-class')).to eq(top_level_class)
26
- end
27
-
28
- it 'sets component_name in data-react-props hash' do
29
- html = helper.react_component('Components::HelloWorld')
30
- props = react_props_for(html)
31
-
32
- expect(props['component_name']).to eq('Components::HelloWorld')
33
- end
34
-
35
- it 'sets render_params in data-react-props hash' do
36
- html = helper.react_component('Components::HelloWorld', {'foo' => 'bar'})
37
- props = react_props_for(html)
38
-
39
- expect(props['render_params']).to include({ 'foo' => 'bar' })
40
- end
41
-
42
- it 'sets controller in data-react-props hash' do
43
- html = helper.react_component('Components::HelloWorld')
44
- props = react_props_for(html)
45
-
46
- expect(props['controller']).to eq('ActionView::TestCase::Test')
47
- end
48
-
49
- it 'passes additional options through as html attributes' do
50
- html = helper.react_component('Components::HelloWorld', {},
51
- { 'foo-bar' => 'biz-baz' })
52
-
53
- expect(attr_value(html, 'foo-bar')).to eq('biz-baz')
54
- end
55
- end
56
-
57
- def attr_value(html, attr)
58
- matches = html.match(/#{attr}=["']((?:.(?!["']\s+(?:\S+)=|[>"']))+.)["']?/)
59
- matches.captures.first
60
- end
61
-
62
- def react_props_for(html)
63
- JSON.parse(CGI.unescapeHTML("#{attr_value(html, 'data-react-props')}"))
64
- end
65
- end
66
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if ruby?
4
- RSpec.describe ReactiveRuby::ServerRendering::ContextualRenderer do
5
- let(:renderer) { described_class.new({}) }
6
- let(:init) { Proc.new {} }
7
- let(:options) { { context_initializer: init } }
8
-
9
- describe '#render' do
10
- it 'pre-renders HTML' do
11
- result = renderer.render('Components.Todo',
12
- { todo: 'finish reactive-ruby' },
13
- options)
14
- expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
15
- expect(result).to match(/data-react-checksum/)
16
- end
17
-
18
- it 'accepts props as a string' do
19
- result = renderer.render('Components.Todo',
20
- { todo: 'finish reactive-ruby' }.to_json,
21
- options)
22
- expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
23
- expect(result).to match(/data-react-checksum/)
24
- end
25
-
26
- it 'pre-renders static content' do
27
- result = renderer.render('Components.Todo',
28
- { todo: 'finish reactive-ruby' },
29
- :static)
30
- expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
31
- expect(result).to_not match(/data-react-checksum/)
32
- end
33
- end
34
- end
35
- end
@@ -1,149 +0,0 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
-
3
- require 'opal'
4
- require 'opal-rspec'
5
- require 'opal-jquery'
6
-
7
- def opal?
8
- RUBY_ENGINE == 'opal'
9
- end
10
-
11
- def ruby?
12
- !opal?
13
- end
14
-
15
-
16
- if RUBY_ENGINE == 'opal'
17
- require File.expand_path('../vendor/jquery-2.2.4.min', __FILE__)
18
- require 'hyperloop-config'
19
- Hyperloop::Context
20
- require 'react/react-source-browser'
21
- require 'react/react-source-server'
22
- require 'hyper-react'
23
- require 'react/test/rspec'
24
- require 'react/test/utils'
25
- require 'react/top_level_render'
26
- require 'react/ref_callback'
27
- require 'react/server'
28
-
29
- require File.expand_path('../support/react/spec_helpers', __FILE__)
30
-
31
- # turn off deprecation warnings for old style name spaces during this test
32
- module React
33
- module Component
34
-
35
- def self.included(base)
36
- # deprecation_warning base, "The module name React::Component has been deprecated. Use Hyperloop::Component::Mixin instead."
37
- base.include Hyperloop::Component::Mixin
38
- end
39
-
40
- class Base
41
- def self.inherited(child)
42
- # unless child.to_s == "React::Component::HyperTestDummy"
43
- # React::Component.deprecation_warning child, "The class name React::Component::Base has been deprecated. Use Hyperloop::Component instead."
44
- # end
45
- child.include(ComponentNoNotice)
46
- end
47
- end
48
- end
49
- end
50
-
51
- module React
52
- class State
53
- # this messes with lots of tests, these tests will be retested in the new hyper-component gem tests
54
- ALWAYS_UPDATE_STATE_AFTER_RENDER = false
55
- end
56
- end
57
-
58
- module Opal
59
- module RSpec
60
- module AsyncHelpers
61
- module ClassMethods
62
- def rendering(title, &block)
63
- klass = Class.new do
64
- include React::Component
65
-
66
- def self.block
67
- @block
68
- end
69
-
70
- def self.name
71
- "dummy class"
72
- end
73
-
74
- def render
75
- instance_eval &self.class.block
76
- end
77
-
78
- def self.should_generate(opts={}, &block)
79
- sself = self
80
- @self.async(@title, opts) do
81
- expect_component_to_eventually(sself, &block)
82
- end
83
- end
84
-
85
- def self.should_immediately_generate(opts={}, &block)
86
- sself = self
87
- @self.it(@title, opts) do
88
- element = build_element sself, {}
89
- context = block.arity > 0 ? self : element
90
- expect((element and context.instance_exec(element, &block))).to be(true)
91
- end
92
- end
93
-
94
- end
95
- klass.instance_variable_set("@block", block)
96
- klass.instance_variable_set("@self", self)
97
- klass.instance_variable_set("@title", "it can render #{title}")
98
- klass
99
- end
100
- end
101
- end
102
- end
103
- end
104
-
105
-
106
- RSpec.configure do |config|
107
- config.include React::SpecHelpers
108
- config.filter_run_excluding :ruby
109
- if `(React.version.search(/^0\.13/) === -1)`
110
- config.filter_run_excluding :v13_only
111
- else
112
- config.filter_run_excluding :v13_exclude
113
- end
114
- end
115
- end
116
-
117
- if RUBY_ENGINE != 'opal'
118
- begin
119
- require File.expand_path('../test_app/config/environment', __FILE__)
120
- rescue LoadError
121
- puts 'Could not load test application. Please ensure you have run `bundle exec rake test_app`'
122
- end
123
- require 'rspec/rails'
124
- require 'timecop'
125
-
126
- Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
127
-
128
- RSpec.configure do |config|
129
- config.color = true
130
- config.fail_fast = ENV['FAIL_FAST'] || false
131
- config.fixture_path = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures")
132
- config.infer_spec_type_from_file_location!
133
- config.mock_with :rspec
134
- config.raise_errors_for_deprecations!
135
-
136
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
137
- # examples within a transaction, comment the following line or assign false
138
- # instead of true.
139
- config.use_transactional_fixtures = true
140
-
141
- config.before :each do
142
- Rails.cache.clear
143
- end
144
-
145
- config.filter_run_including focus: true
146
- config.filter_run_excluding opal: true
147
- config.run_all_when_everything_filtered = true
148
- end
149
- end
@@ -1,44 +0,0 @@
1
- if opal?
2
- module React
3
- module SpecHelpers
4
- `var ReactTestUtils = React.addons.TestUtils`
5
-
6
- def renderToDocument(type, options = {})
7
- element = React.create_element(type, options)
8
- React::Test::Utils.render_into_document(element)
9
- end
10
-
11
- def build_element(type, options)
12
- component = React.create_element(type, options)
13
- element = `ReactTestUtils.renderIntoDocument(#{component.to_n})`
14
- if `typeof React.findDOMNode === 'undefined'`
15
- `$(element.getDOMNode())` # v0.12
16
- else
17
- `$(React.findDOMNode(element))` # v0.13
18
- end
19
- end
20
-
21
- def expect_component_to_eventually(component_class, opts = {}, &block)
22
- # Calls block after each update of a component until it returns true.
23
- # When it does set the expectation to true. Uses the after_update
24
- # callback of the component_class, then instantiates an element of that
25
- # class The call back is only called on updates, so the call back is
26
- # manually called right after the element is created. Because React.rb
27
- # runs the callback inside the components context, we have to setup a
28
- # lambda to get back to correct context before executing run_async.
29
- # Because run_async can only be run once it is protected by clearing
30
- # element once the test passes.
31
- element = nil
32
- check_block = lambda do
33
- context = block.arity > 0 ? self : element
34
- run_async do
35
- element = nil; expect(true).to be(true)
36
- end if element and context.instance_exec(element, &block)
37
- end
38
- component_class.after_update { check_block.call }
39
- element = build_element component_class, opts
40
- check_block.call
41
- end
42
- end
43
- end
44
- end