Sha256: da0e3a6de8020880e82dca1968aeee1579af55ed67818f88141200d7159e0655

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe EasyRedis::Setters do

  before(:each) do
    @user = User.create(name: "Mehmet Emin")
  end

  context 'r_set method' do
    it 'should raise error for new records' do
      allow(EasyRedis::Redis).to receive(:raise_non_existent_object_error?) { true }
      u = User.new
      expect{u.r_set_foo "bar"}.to raise_error(NonExistentObjectError)
    end
    it 'should set value for given attribute and returns true' do
      expect(@user.r_set("foo", "bar")).to eql(true)
    end
    it 'should update value for given attribute and returns false' do
      @user.r_set("foo", "bar")
      expect(@user.r_set("foo", "baz")).to eql(false)
    end
  end

  context 'redis_set method' do
    it 'should set value for given attribute and returns true' do
      expect(@user.redis_set("foo", "bar")).to eql(true)
    end
    it 'should update value for given attribute and returns false' do
      @user.redis_set("foo", "bar")
      expect(@user.redis_set("foo", "baz")).to eql(false)
    end
  end

  context 'r_set_attribute method' do
    it 'should set value for given attribute and returns true' do
      expect(@user.r_set_boo("bar")).to eql(true)
    end
    it 'should update value for given attribute and returns false' do
      @user.r_set_foo("bar")
      expect(@user.r_set_foo("baz")).to eql(false)
    end
  end

  context 'redis_set_attribute method' do
    it 'should set value for given attribute and returns true' do
      expect(@user.redis_set_boo("bar")).to eql(true)
    end
    it 'should update value for given attribute and returns false' do
      @user.redis_set_foo("bar")
      expect(@user.redis_set_foo("baz")).to eql(false)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easy_redis-1.0.0 spec/lib/easy_redis/methods/setters_spec.rb