Sha256: e7d9c36cb536c2d3036f33292f148ce9f75163a573e15885298adabb78023dc3

Contents?: true

Size: 943 Bytes

Versions: 25

Compression:

Stored size: 943 Bytes

Contents

require "spec_helper"
  
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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
reactive-ruby-0.7.28 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.27 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.26 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.25 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.24 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.23 opal-spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.22 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.21 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.20 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.19 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.18 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.17 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.16 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.15 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.14 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.13 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.12 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.11 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.10 spec/tutorial/tutorial_spec.rb
reactive-ruby-0.7.8 spec/tutorial/tutorial_spec.rb