Sha256: 3870852d62763dbd55d1ca6f2c8f6133981d3e8a5768f1ae1d296efbb7b9f626

Contents?: true

Size: 690 Bytes

Versions: 3

Compression:

Stored size: 690 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 connection to be defined
      raise "missing connection" unless connection

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

  it "should work" do
    SampleSingular.new(connection: :fake).name.should == "amazing"
  end

  it "should reload" do
    singular = SampleSingular.new(connection: :fake)
    old_count = singular.count
    singular.count.should == old_count
    singular.reload.count.should > old_count
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cistern-0.6.0 spec/singular_spec.rb
cistern-0.5.10 spec/singular_spec.rb
cistern-0.5.9 spec/singular_spec.rb