为什么将我的Rails数据库从SQLite更改为MySQL后,这个RSpec文本会中断?
第二个示例用于传入SQLite,现在在MySQL下失败为什么将我的Rails数据库从SQLite更改为MySQL后,这个RSpec文本会中断?,mysql,ruby-on-rails,sqlite,rspec,Mysql,Ruby On Rails,Sqlite,Rspec,第二个示例用于传入SQLite,现在在MySQL下失败 require 'spec_helper' shared_examples_for "anything that caches its model" do factory = self.described_class.table_name.singularize.to_sym klass = self.described_class it "maintains a cache key based on the curr
require 'spec_helper'
shared_examples_for "anything that caches its model" do
factory = self.described_class.table_name.singularize.to_sym
klass = self.described_class
it "maintains a cache key based on the current #{self.described_class.name.downcase} count" do
klass.cache_key.should == "#{self.described_class.table_name}-0-"
end
context "when there are #{self.described_class.table_name} in the database" do
it "includes the last updated #{self.described_class.name.downcase} in the cache key" do
e1 = Factory factory
e2 = Factory factory
klass.cache_key.should == "#{self.described_class.table_name}-#{self.described_class.count}-#{e2.cache_key}"
end
end
end
我得到的错误是:
Failure/Error: klass.cache_key.should == "#{self.described_class.table_name}-{self.described_class.count}-#{e2.cache_key}"
expected: "deliveries-2-deliveries/2-20120315152232"
got: "deliveries-2-deliveries/1-20120315152232" (using ==)
我认为这样做共享示例的枯燥好处实际上被这个规范奇怪的可读性所抵消。我只是想让一个缓存键像Rails实例缓存键那样适用于整个类。如果你不能回答我的问题,但也知道一个更好的方法,那么我也很感谢你的推荐
谢谢