草庐IT

add_spec

全部标签

ruby-on-rails - RSpec:无法加载此类文件——teamcity/spec/runner/formatter/teamcity/formatter (LoadError)

这个解决方案对我不起作用:RunningaspecinRubyMineresultsin"cannotloadsuchfile--teamcity/spec/runner/formatter/teamcity/formatter(LoadError)"还有这篇文章:https://www.jetbrains.com/ruby/help/using-rspec-in-rails-applications.html我正在使用Ubuntu15.10、RubyMine7.1、Ruby2.2.3、Rails4.2.5当我尝试使用Run'spec:project启动RSpec时,它返回了一个错误:

ruby-on-rails - RSpec 中 spec 目录的 Before 和 After 钩子(Hook)

我们的RSpec测试套件中有相当多的测试。目录结构看起来像-spec/truncation/example1_spec.rbexample2_spec.rb...transaction/example1_spec.rbexample2_spec.rb...我想在transaction/文件夹中的所有规范文件运行之前恢复测试数据库转储,并在所有测试完成后将其清空。有办法吗?有before(:suite)和after(:suite)Hook,但它们适用于单个规范文件。有没有办法在RSpec中为目录提供前后Hook? 最佳答案 你在使用R

ruby-on-rails - 对于新的 ActiveRecord 模型,为什么有些 has_many :through associations add a (1=0) predicate and distinct clause to the sql query?

每当我实例化一个新的ActiveRecord模型(一个尚未持久化到数据库中的模型)并尝试访问构建模型上的一些各种关联时,Rails查询构建器有时会:将(1=0)谓词添加到查询的where子句。在select语句中添加“distinct”子句。我认为这只会在has_many:through关联连接两个或多个表时发生。我想知道为什么它添加了(1=0)谓词以及distinct子句。对于(1=0)谓词,新模型是否已保存到数据库应该无关紧要(对吧?)。我不知道为什么要添加distinct子句。我在下面有一个简单的例子。classAssignment#s.assignment_attachment

ruby - 如何在 rails_admin 的编辑表单中隐藏 "Save and Add Another"按钮?

我在我的Rails应用程序中应用了rails_admingem。我想删除特定模型编辑表单中一些不必要的按钮,并添加我自己的自定义按钮。请查看屏幕截图,了解我要删除的内容。 最佳答案 @montells复制https://github.com/sferik/rails_admin/blob/master/app/views/rails_admin/main/_submit_buttons.html.haml这个页面在你的repo中,位于“views/rails_admin/main/_submit_buttons.html.haml”

ruby - Capybara + RSpec, spec/features 目录被 rspec 忽略。命令?

我正在按照位于here的简短指南使用带有rspec的新CapybaraDSL添加到spec/features目录的测试单独运行良好,即。rails_project$rspecspec/features/my_first_feature.rb然而,当我尝试像这样对整个spec/目录运行测试时,spec/features目录被完全忽略:rails_project$rspec.指南中没有提及如何包含此目录(或其他目录)以完成我想要的包含。我真的需要这个来持续集成我的项目。有人能告诉我怎么做吗?谢谢! 最佳答案 您需要确保所有规范都以_sp

ruby - 运行 dependency.rb :247:in `to_specs' : Could not find bundler

当我运行bundle时,出现以下错误~/rails_apps/redmine]#bundle/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in`to_specs':Couldnotfindbundler(>=0)amongst[RedCloth-4.2.9,ZenTest-4.8.2,actionmailer-2.3.14,actionpack-2.3.14,activerecord-2.3.14,activeresource-2.3.14,activesupport-2.3.14,cgi_multipart_eof_fi

ruby-on-rails - Rails 4 + Rspec + 设计 : undefined method 'env' in controller specs for sign_in a user

在我的spec_helper.rb中我添加了config.includeDevise::TestHelpers,:type=>:controller在:allhook之前的Controller规范中,我正在尝试使用此代码登录用户@request.env["devise.mapping"]=Devise.mappings[:user]user=FactoryGirl.create(:confirmed_user)sign_inuser并得到NoMethodError:undefinedmethod`env'fornil:NilClass。有什么想法吗? 最佳答

ruby - `require' : cannot load such file -- spec_helper (LoadError)

我在创作bundlergem--test=rspecMyGem.我在其中获取存储库结构。当我尝试运行rspec代码时,出现以下错误:`require':cannotloadsuchfile--spec_helper(LoadError)然后我尝试应用requirerelative但我仍然收到错误:sheetal@ubuntu:~/sheetal/spec$rspecsheetal_spec.rb\/home/sheetal/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in`re

ruby - bundle exec rspec spec/=> RUBYOPT : -F (RuntimeError) 中的无效开关

当我在Windows764位系统上运行bundleexecrspecspec/时,我收到以下错误:invalidswitchinRUBYOPT:-F(RuntimeError)我正在运行ruby​​1.9.2p136(2010-12-25)[i386-mingw32](安装在c:\ProgramFiles(x86)\Ruby192)和bundler1.0.15(作为ruby​​gem安装).关于如何解决这个问题的任何线索?谢谢,本 最佳答案 Bundler不喜欢Ruby的路径包含空格这一事实。为了解决这个问题,我编辑了runtime

ruby-on-rails - Hartl 教程中的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用

我正在按照MichaelHartl的ruby​​onrails教程测试示例应用程序(3.2.1测试驱动开发),但在键入bundleexecrspecspec/requests/static_pages_spec.rb后出现以下错误/home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in`require':cannotloadsuchfile--zip/zip(LoadErr