Sha256: 95a19b05e5da120fd90cbd88daaf188d506d471a48d178512a0e466d7108aef0
Contents?: true
Size: 939 Bytes
Versions: 21
Compression:
Stored size: 939 Bytes
Contents
require 'spec_helper' if opal? class HelloMessage include React::Component def render div { "Hello World!" } end end describe 'An Example from the react.rb doc' do it 'produces the correct result' do expect(React.render_to_static_markup(React.create_element(HelloMessage))).to eq('<div>Hello World!</div>') end end class HelloMessage2 include React::Component define_state(:user_name) { '@catmando' } def render div { "Hello #{user_name}" } end end describe 'Adding state to a component (second tutorial example)' do it "produces the correct result" do expect(React.render_to_static_markup(React.create_element(HelloMessage2))).to eq('<div>Hello @catmando</div>') end it 'renders to the document' do React.render(React.create_element(HelloMessage2), `document.getElementById('render_here')`) expect(`document.getElementById('render_here').innerHTML`) =~ 'Hello @catmando' end end end
Version data entries
21 entries across 21 versions & 2 rubygems