Sha256: c287ec0f4d296558859f64c4a66b6af6340b28819616ef43fd63b3e7df334d59

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

require 'test_helper'

class TaskTest < ActiveSupport::TestCase

  setup do
    load File.expand_path('../../lib/tasks/cachers.rake', __FILE__)
    Rake::Task.define_task :environment
  end

  test 'all' do
    users = %w(mike john).map do |name|
      User.create name: name
    end
    silence_stream(STDOUT) do
      Rake::Task['cachers:cache'].invoke
    end
    users.each do |user|
      assert_equal user.id, $redis.get("users/#{user.name}").to_i
    end

    $redis.flushall
    silence_stream(STDOUT) do
      Rake::Task['cachers:recache'].invoke
    end
    users.each do |user|
      assert_equal user.id, $redis.get("users/#{user.name}").to_i
    end

    silence_stream(STDOUT) do
      Rake::Task['cachers:uncache'].invoke
    end
    assert_equal 0, $redis.keys.size
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cachers-4.0.0.0 test/task_test.rb