Sha256: 53bd39519ca008c5aaf6eb6d762dfae4a5eeb442b019e44c28701b39330513b2

Contents?: true

Size: 677 Bytes

Versions: 4

Compression:

Stored size: 677 Bytes

Contents

require 'spec_helper'

describe 'Cistern::Singular' do
  class SampleSingular < Sample::Singular
    attribute :name
    attribute :count, type: :number

    def fetch_attributes
      # test that initialize waits for service to be defined
      fail 'missing service' unless service

      @counter ||= 0
      @counter += 1
      { name: 'amazing', count: @counter }
    end
  end

  it 'should work' do
    expect(Sample.new.sample_singular.name).to eq('amazing')
  end

  it 'should reload' do
    singular = Sample.new.sample_singular
    old_count = singular.count
    expect(singular.count).to eq(old_count)
    expect(singular.reload.count).to be > old_count
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cistern-2.2.7 spec/singular_spec.rb
cistern-2.2.6 spec/singular_spec.rb
cistern-2.2.5 spec/singular_spec.rb
cistern-2.2.4 spec/singular_spec.rb