rspec

Can you expect only one type of job to be enqueued in Rspec?

喜欢而已 提交于 2020-01-06 06:48:10
问题 Using rspec-rails (3.8.0) , can you expect only one type of job to be enqueued (in case other types of jobs are also being enqueued in related activity)? The main question that sparked this question is here: How do you create parent objects for a factory using before(:create) without sparking the parents' after_create callback? Feel free to discuss both! Thanks, Kevin 来源: https://stackoverflow.com/questions/54370695/can-you-expect-only-one-type-of-job-to-be-enqueued-in-rspec

Running Nested Tags in Rspec

吃可爱长大的小学妹 提交于 2020-01-06 05:41:33
问题 I'm trying to architect my tests in such a way so I can run certain context blocks by themselves, but also need to further enforce nested tags in individual it blocks. Something like this: context 'outer context', :outer_tag do it 'inner it', :tag1 do expect(1).to eq(1) end it 'inner it 2', :tag2 do expect(2).to eq(2) end end and I want to run something along the lines of: rspec --tag outer-tag --tag tag1 in the hopes that it will only run tests within the context tagged with :outer-tag that

Rspec multiple spec folders

痴心易碎 提交于 2020-01-06 05:27:30
问题 Im currently building a project using Rspec in which I sepparated in two different folders with domain code and infrastructure code. Both folders have their own specs in a spec folder. The domain/spec folder is the one containing the spec_helper.rb file, thats required from the tests inside the other folder infrastructure/spec I'd like to know how to have a spec folder in the root of the project, including the spec_helper file and also tests, and being able to run all the tests with just one

Testing models with RSpec using devise

对着背影说爱祢 提交于 2020-01-06 04:31:22
问题 I am using devise for authentication in my rails app and I'm unable to test any model with RSpec. Controller specs work fine, but I'm unable to make model specs work. I am getting this error: Failures: 1) Group should create new group Failure/Error: Unable to find matching line from backtrace NoMethodError: undefined method `env' for nil:NilClass # /home/hrvoje/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing' # /home/hrvoje/.rvm/gems

Select Image in Selenium 2.9

∥☆過路亽.° 提交于 2020-01-06 03:33:07
问题 I'm trying to use RSpec to try and automate testing for post-maintenance weekends here where I'm interning at. I'm using Selenium WebDriver 2.9.0 to get a skelton going and then adding in personalized code. What I'm currently stuck on is trying to have the WebDriver click on an image that will then navigate to the correct HTML but I'm currently unable to do so. Here's what I have so far... it "can go to Ultratime" do @ie_driver.find_element(:link, "My Resources").click wait.until { @ie_driver

Why does Guard run ALL my RSpec specs on every change?

三世轮回 提交于 2020-01-05 10:27:22
问题 This testing stack is behaving unreliably. Sometimes when I run guard, it performs adequately with the guard-rspec gem and will only run the file that has been changed. At least, if the test fails it will stop with that single modified file. But if that test passes, all bets are off. It will continue to run ALL tests when a single file is changed. On a good-sized application, this is extremely impractical and frustrating to see all tests run every time a file is saved. My Guardfile is as

How to write integration test for complicated rails index (best practices)

僤鯓⒐⒋嵵緔 提交于 2020-01-05 10:14:28
问题 Let's say I have a page which lists articles. The code in the controller used to be # articles#index @articles = Article.paginate(page: params[:page], per_page: 10, order: :title) and my test was like # spec/requests/article_pages_spec Article.paginate(page: 1, per_page:10, order: :title).each do |a| a.should have_selector('h3', text: a.title) end Ok fine. Now my code changes a bunch. The index is like @articles = Article.find(:all, conditions: complicated_status_conditions) .sort_by { |a|

RSpec without rails not loading files in spec/support

心已入冬 提交于 2020-01-05 09:36:27
问题 In the file spec/support/factory_girl.rb I have fail "At least this file is being required" RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end and I have in some spec code require 'pmc_article' require 'pmc_article_parser' require 'factory_girl' require_relative './factories/pmc_article_factory' RSpec.describe PMCArticle do let(:pmc_article) do build(:pmc_article) end it 'parses pmid' do expect(pmc_article.article_id_pmid).to eq '123456' end end but when I run bundle

RSpec without rails not loading files in spec/support

走远了吗. 提交于 2020-01-05 09:36:25
问题 In the file spec/support/factory_girl.rb I have fail "At least this file is being required" RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end and I have in some spec code require 'pmc_article' require 'pmc_article_parser' require 'factory_girl' require_relative './factories/pmc_article_factory' RSpec.describe PMCArticle do let(:pmc_article) do build(:pmc_article) end it 'parses pmid' do expect(pmc_article.article_id_pmid).to eq '123456' end end but when I run bundle

Force HTTPS/SSL for all controller/request specs in rspec

送分小仙女□ 提交于 2020-01-05 07:27:13
问题 I'm using RSpec 3.5.0, and would like to enable HTTPS/SSL requests for all my specs. Since I added force_ssl to my ApplicationController , all my specs are failing, since they are redirecting to the secure version of the site instead of rendering, etc. 回答1: The suggestions here don't work under rails 5. If that's part of where you're stuck adding https! to your spec should work. 来源: https://stackoverflow.com/questions/40633069/force-https-ssl-for-all-controller-request-specs-in-rspec