Ruby on rails 特殊问题:简单的Rspec规范在Linux上传递,但在MacOSX上不传递
我有以下规格:Ruby on rails 特殊问题:简单的Rspec规范在Linux上传递,但在MacOSX上不传递,ruby-on-rails,macos,ubuntu,rspec,Ruby On Rails,Macos,Ubuntu,Rspec,我有以下规格: it 'should find and associate thumbnail and video for article with an episode with the first alpha-numerically matching files it finds' do @article = FactoryGirl.create(:pending_assets_article, id: 1) @episode1 = FactoryGirl.create(:epis
it 'should find and associate thumbnail and video for article with an episode with the first alpha-numerically matching files it finds' do
@article = FactoryGirl.create(:pending_assets_article, id: 1)
@episode1 = FactoryGirl.create(:episode, topic_id: @topic.id, article_id: @article.id, position: 1)
@article.video.should be_nil
@article.thumbnail.image.should be_blank
@article.state.should == 'pending assets'
run_rake_task
Delayed::Job.count.should == 2
...
end
奇怪的是,这个规范在Ubuntu中通过得很好,但在Mac OS X Lion中它失败了,比如说expected 2,got 0
什么给
我很乐意添加更多的周边代码来提供更多的上下文。您如何调用rake任务?如果您正在使用另一个进程,则可能会触及数据存储中的事务边界 理想情况下,您应该在rspec上下文中查找/执行rake任务:
require 'rake'
Rake::Task[name].invoke
例如,如果您将postgres作为DelayedJob队列的后端运行,并在rspec中使用事务性数据回滚,那么您在测试设置的一个事务中有测试数据,将其发送到rake任务,该任务更改事务外的数据,返回到测试和原始事务,并且无法“查看”数据
此外,与查询数据存储中的队列大小相比,使用模拟和期望验证代码是否将作业排队到DelayedJob中可能更简单。您的mac上是否有rmagick设置?是的,
rmagick
包含在GEM文件中,并作为捆绑包的一部分安装。