Sha256: b33dc28abbe8ac9a214fea76b29d4ff29392f60c4abcf17c080b1156f24539c5

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

RSpec.shared_examples 'payload is correct' do |request = true|
  include_examples 'body type'
  include_examples 'evostream::event new'
  include_examples 'instance variable model'
  if request
    include_examples 'request test'
  else
    include_examples 'type stream'
  end
  it { expect(type).to eql(type_default) }
end

RSpec.shared_examples 'payload isn\'t correct' do
  include_examples 'body type'
  include_examples 'evostream::event new'
  include_examples 'instance variable model'
  it { expect(type).not_to eql(type_default) }
end

RSpec.shared_examples 'body type' do
  it { expect(body.to_json).to be_kind_of(String) }
end

RSpec.shared_examples 'evostream::event new' do
  it { expect(Evostream::Event.new(type, payload.to_json)).not_to be nil }
end

RSpec.shared_examples 'instance variable model' do
  let(:model) { type.sub(/^(\w)/, &:capitalize) }
  let(:evo) { Evostream::Event.new(type, payload.to_json) }

  it { expect(evo.instance_variable_get(:@model)).to eql(model) }
end

RSpec.shared_examples 'request test' do
  let(:response) { Evostream::Event.new(type, payload).execute_action }
  it { expect(response).to be_an_instance_of(Array) }
end

RSpec.shared_examples 'type stream' do
  let(:stream) do
    Evostream::Events::OutStreamCreated.new(1234, payload).send(:what_flux)
  end

  it { expect(stream).to eql(type_stream) }
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
evostream-event-0.2.3 spec/support/examples_events.rb
evostream-event-0.2.3.pre.27 spec/support/examples_events.rb
evostream-event-0.2.2 spec/support/examples_events.rb
evostream-event-0.2.2.pre.25 spec/support/examples_events.rb
evostream-event-0.2.1 spec/support/examples_events.rb
evostream-event-0.2.1.pre.23 spec/support/examples_events.rb
evostream-event-0.2.0.pre.22 spec/support/examples_events.rb
evostream-event-0.1.2.pre.20 spec/support/examples_events.rb