Sha256: 358b6675218e4804be04116cc464b2e8b4fd9ab8e8219d2f73d1afba6e7c83e0

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

if RUBY_ENGINE == '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

8 entries across 8 versions & 1 rubygems

Version Path
hyper-react-1.0.0.lap28 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap27 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap26 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap25 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap24 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap23 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap22 spec/react/test/rspec_spec.rb
hyper-react-1.0.0.lap21 spec/react/test/rspec_spec.rb