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

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