Sha256: 69539440b4a359721167011b84d0fc0e20228146e35ce1c6287023addc1db619

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

if opal?
  RSpec.describe 'react/test/rspec', type: :component do
    before do
      stub_const 'Greeter', Class.new
      Greeter.class_eval do
        include React::Component
        params do
          optional :message
          optional :from
        end

        def render
          span { "Hello #{params.message}" }
        end
      end
    end

    it 'should include react/test in rspec' do
      comp = mount(Greeter)
      expect(component.instance).to eq(comp)
    end

    it 'includes rspec matchers' do
      expect(Greeter).to render_static_html(
        '<span>Hello world</span>'
      ).with_params(message: 'world')
    end

    describe 'resetting the session' do
      it 'creates an instance of the mounted component in one example' do
        mount(Greeter)
      end

      it '...then is not availalbe in the next' do
        expect { component.instance }.to raise_error
      end
    end
  end

  RSpec.describe 'react/test/rspec', type: :other do
    before do
      stub_const 'Greeter', Class.new
      Greeter.class_eval do
        include React::Component
        params do
          optional :message
          optional :from
        end

        def render
          span { "Hello #{params.message}" }
        end
      end
    end

    it 'should not include react/test in rspec' do
      expect { mount(Greeter) }.to raise_error
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyper-react-0.12.7 spec/react/test/rspec_spec.rb
hyper-react-0.12.6 spec/react/test/rspec_spec.rb
hyper-react-0.12.5 spec/react/test/rspec_spec.rb
hyper-react-0.12.4 spec/react/test/rspec_spec.rb
hyper-react-0.12.3 spec/react/test/rspec_spec.rb
hyper-react-0.12.2 spec/react/test/rspec_spec.rb
hyper-react-0.12.1 spec/react/test/rspec_spec.rb
hyper-react-0.12.0 spec/react/test/rspec_spec.rb
hyper-react-0.11.0 spec/react/test/rspec_spec.rb