Sha256: 67ebfb5c93b1916009af3ba4fbc64582ffc88a0fb51a66099be72083be90221f
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe Redis::Scripting::Script do let(:source_filename) { File.dirname(__FILE__) + "/scripts/test1.lua" } context "no header" do let(:subject) { Redis::Scripting::Script.new(source_filename) } its(:name) { should == "test1" } its(:source) { should == File.read(source_filename) } its(:sha) { should == OpenSSL::Digest::SHA1.hexdigest(subject.source) } end context "header" do let(:header) { "local x = 5" } let(:subject) { Redis::Scripting::Script.new(source_filename, script_header: header) } its(:source) { should == "#{header}\n\n#{File.read(source_filename)}" } its(:sha) { should == OpenSSL::Digest::SHA1.hexdigest(subject.source) } end describe "#run" do let(:subject) { Redis::Scripting::Script.new(source_filename) } it "should evalsha first" do redis = double('Redis') expect(redis).to receive(:evalsha).with(subject.sha, keys: ['a'], argv: ['b']) { 1 } subject.run(redis, ['a'], ['b']).should == 1 end it "should eval if evalsha raises NOSCRIPT" do redis = double('Redis') expect(redis).to receive(:evalsha) { raise(Redis::CommandError, "NOSCRIPT doesn't exist") } expect(redis).to receive(:eval).with(subject.source, keys: ['a'], argv: ['b']) { 1 } subject.run(redis, ['a'], ['b']).should == 1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redis-scripting-1.0.1 | spec/redis/scripting/script_spec.rb |
redis-scripting-1.0.0 | spec/redis/scripting/script_spec.rb |