Sha256: 952eb39b5d0e40f0806b9067d83c0940b808ea9928aca0b1bf1a39543e976513

Contents?: true

Size: 1.34 KB

Versions: 35

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

RSpec.describe 'Data collector', type: :helper do
  let(:methods_list) { [:foo, :bar] }
  subject { Torque::PostgreSQL::Collector.new(*methods_list) }

  it 'is a class creator' do
    expect(subject).to be_a(Class)
  end

  it 'has the requested methods' do
    instance = subject.new
    methods_list.each do |name|
      expect(instance).to respond_to(name)
      expect(instance).to respond_to("#{name}=")
    end
  end

  it 'instace values starts as nil' do
    instance = subject.new
    methods_list.each do |name|
      expect(instance.send(name)).to be_nil
    end
  end

  it 'set values on the same method' do
    instance = subject.new
    methods_list.each do |name|
      expect(instance.send(name, name)).to eql(name)
    end
  end

  it 'get value on the same method' do
    instance = subject.new
    methods_list.each do |name|
      instance.send(name, name)
      expect(instance.send(name)).to eql(name)
    end
  end

  it 'accepts any kind of value' do
    instance = subject.new

    instance.foo 123
    expect(instance.foo).to eql(123)

    instance.foo 'chars'
    expect(instance.foo).to eql('chars')

    instance.foo :test, :test
    expect(instance.foo).to eql([:test, :test])

    instance.foo test: :test
    expect(instance.foo).to eql({test: :test})

    instance.foo nil
    expect(instance.foo).to be_nil
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
torque-postgresql-3.4.1 spec/tests/collector_spec.rb
torque-postgresql-2.4.5 spec/tests/collector_spec.rb
torque-postgresql-3.4.0 spec/tests/collector_spec.rb
torque-postgresql-3.3.3 spec/tests/collector_spec.rb
torque-postgresql-2.4.4 spec/tests/collector_spec.rb
torque-postgresql-3.3.2 spec/tests/collector_spec.rb
torque-postgresql-2.4.3 spec/tests/collector_spec.rb
torque-postgresql-3.3.1 spec/tests/collector_spec.rb
torque-postgresql-3.3.0 spec/tests/collector_spec.rb
torque-postgresql-3.2.2 spec/tests/collector_spec.rb
torque-postgresql-2.4.2 spec/tests/collector_spec.rb
torque-postgresql-2.4.1 spec/tests/collector_spec.rb
torque-postgresql-3.2.1 spec/tests/collector_spec.rb
torque-postgresql-2.4.0 spec/tests/collector_spec.rb
torque-postgresql-3.2.0 spec/tests/collector_spec.rb
torque-postgresql-3.1.0 spec/tests/collector_spec.rb
torque-postgresql-2.3.0 spec/tests/collector_spec.rb
torque-postgresql-3.0.1 spec/tests/collector_spec.rb
torque-postgresql-2.2.4 spec/tests/collector_spec.rb
torque-postgresql-3.0.0 spec/tests/collector_spec.rb