spec/lib/jasmine/headless/cacheable_action_spec.rb in jasmine-headless-webkit-0.7.1 vs spec/lib/jasmine/headless/cacheable_action_spec.rb in jasmine-headless-webkit-0.7.2
- old
+ new
@@ -17,23 +17,27 @@
described_class.any_instance.expects(:action).returns(compiled)
end
let(:cache_type) { 'action' }
let(:cache_dir) { 'cache' }
- let(:cache_file) { File.join(cache_dir, cache_type, Digest::SHA1.hexdigest(file)) }
+ let(:cache_file) { File.join(cache_dir, cache_type, Digest::SHA1.hexdigest(file)) + '.js' }
let(:cache_file_data) { YAML.load(File.read(cache_file)) }
+ let(:cache_object) { described_class.new(file) }
+
describe '.for' do
context 'cache disabled' do
before do
described_class.enabled = false
end
it 'should compile' do
action_runs!
described_class.for(file).should == compiled
cache_file.should_not be_a_file
+
+ cache_object.should_not be_cached
end
end
context 'cache enabled' do
before do
@@ -50,10 +54,11 @@
it 'should compile' do
action_runs!
described_class.for(file).should == compiled
cache_file_data.should == compiled
+ cache_object.should be_cached
end
end
context 'cache fresh' do
let(:cache_file_mtime) { 15 }
@@ -67,10 +72,11 @@
action_runs!.never
described_class.for(file).should == compiled
cache_file_data.should == compiled
+ cache_object.should be_cached
end
end
context 'cache stale' do
let(:cache_file_mtime) { 5 }
@@ -79,9 +85,10 @@
action_runs!
described_class.for(file).should == compiled
cache_file_data.should == compiled
+ cache_object.should be_cached
end
end
end
end
end