Sha256: fd7a86e46d339d7ddceac5b86a8e7545e1516b04af313245a8dcc6e739a0dc8d

Contents?: true

Size: 692 Bytes

Versions: 15

Compression:

Stored size: 692 Bytes

Contents

require 'spec_helper'

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

    def fetch_attributes
      #test that initialize waits for service to be defined
      raise "missing service" unless service

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

  it "should work" do
    expect(SampleSingular.new(service: :fake).name).to eq("amazing")
  end

  it "should reload" do
    singular = SampleSingular.new(service: :fake)
    old_count = singular.count
    expect(singular.count).to eq(old_count)
    expect(singular.reload.count).to be > old_count
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cistern-2.2.1 spec/singular_spec.rb
cistern-2.1.0 spec/singular_spec.rb
cistern-2.0.5 spec/singular_spec.rb
cistern-2.0.4 spec/singular_spec.rb
cistern-2.0.3 spec/singular_spec.rb
cistern-2.0.2 spec/singular_spec.rb
cistern-2.0.1 spec/singular_spec.rb
cistern-1.0.1.pre6 spec/singular_spec.rb
cistern-1.0.1.pre5 spec/singular_spec.rb
cistern-1.0.1.pre4 spec/singular_spec.rb
cistern-1.0.1.pre3 spec/singular_spec.rb
cistern-1.0.1.pre2 spec/singular_spec.rb
cistern-1.0.1.pre1 spec/singular_spec.rb
cistern-1.0.0.pre spec/singular_spec.rb
cistern-0.11.2.pre2 spec/singular_spec.rb