rspec

RSpec and Machinist error: Too many open files

不羁的心 提交于 2020-01-12 19:05:26
问题 This morning I am having the following error: 14) Deal on creation sets frozen to false or nil Failure/Error: Unable to find matching line from backtrace Errno::EMFILE: Too many open files - identify -format %wx%h '/var/folders/BJ/BJcTANEBFxWcan28U2YEKE+++TI/-Tmp-/stream20120229-36866-4l1sa8.gif[0]' # ./spec/support/blueprints.rb:29:in `block in <top (required)>' Specs are so damn slow (even with spork) so they are useless. It takes 9 minutes to run 20 examples in a model. Line 29 in

Stub authentication in request specs

我怕爱的太早我们不能终老 提交于 2020-01-12 14:28:49
问题 I'm looking for the way to do this but in request specs. I need to log in and log out a double or instance_double to Devise instead of an actual ActiveModel/ActiveRecord. By using the code in the wiki page: module RequestSpecHelpers def sign_in(user = double('user')) if user.nil? allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user}) allow(controller).to receive(:current_user).and_return(nil) else allow(request.env['warden']).to receive(:authenticate!)

zeus rspec fails include required files, but rspec alone does fine

北慕城南 提交于 2020-01-12 07:20:11
问题 It's weird issue, zeus start running smoothly. rspec spec/ does it's job flawless. My spec_helper config is # encoding: UTF-8 require 'rubygems' # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'email_spec' require 'rspec/autorun' require 'capybara/rspec' require 'shoulda-matchers' require 'shoulda/matchers/integrations/rspec' Dir["./spec/support/*

How can I tell Rails to use RSpec instead of test-unit when creating a new Rails app?

我是研究僧i 提交于 2020-01-11 14:50:09
问题 I have test-unit installed and rspec installed (along with -core , -expectations , -mocks and -rails version 2.6.x). When I run the command rails new foo , it uses test-unit to generate the test stub files instead of rspec . Is there an option where I can tell rails to use rspec to generate the tests instead? 回答1: The following should work: at command line: rails new MYAPP -T # The -T option tells rails not to include Test::Unit in Gemfile: gem 'rspec-rails' at command line: bundle install

Capybara, Devise, CanCan and RSpec integration tests: valid sign in 302 redirects to example.com

你离开我真会死。 提交于 2020-01-11 06:21:56
问题 Update: see end of post for how the specs now work now that I have my specs in spec/requests instead of spec/controllers. Still wondering how to get a valid signed in user for integration tests with my controllers. I'm working with Devise and CanCan for the first time and am having difficulty doing the most basic of integration tests whereby I'm verifying that a logged in user is...well...logged in. I have read countless posts and answers dealing with Devise and RSpec integration tests (i.e.

How to stub carrierwave in Rspec?

人盡茶涼 提交于 2020-01-11 00:07:28
问题 I want to stub carrierwave to prevent it from fetch images on the web during my tests. How would I stub things to achieve this? My crawler parses a remote web page, and saves one image url into the model. Carrierwave will fetch that image automatically during the save operation. It works well. However I have a test about the parsing of pages, and every-time it will download the file, which slows down the testing. UPDATE: I mount the uploader as the following (in the pre-existing paperclip

Tests do not run when file changes with Guard and rspec on windows

隐身守侯 提交于 2020-01-10 04:54:08
问题 I've installed the guard-rspec gem for use in my rails application. When I start up guard from the command line via bundle exec guard , it runs my entire test suite the first time with no problem. However, any time I make any changes to a spec file or any watched files as specified in my Guardfile, Guard doesn't seem to recognize the changes and no tests are rerun. I even tried putting something every explicit in my Guardfile like this: watch("app/views/orders/new.html.erb") { "spec/requests

How to test custom types using Rspec-puppet?

流过昼夜 提交于 2020-01-10 04:31:32
问题 I am trying to test a custom_type using rspec-puppet. Puppet Code class vim::ubuntu::config { custom_multiple_files { 'line_numbers': ensure => 'present', parent_dir => '/home', file_name => '.vimrc', line => 'set number'; } } Rspec-puppet code require 'spec_helper' describe "vim::ubuntu::config" do it do should contain_custom_multiple_files('line_numbers').with({ 'ensure' => 'present', 'parent_dir' => '/home', 'file_name' => '.vimrc', 'line' => 'set number', }) end end Result 2) vim::ubuntu:

Why not use shared ActiveRecord connections for Rspec + Selenium?

扶醉桌前 提交于 2020-01-09 03:01:06
问题 It seems the most commonly accepted way to deal with Selenium and tests is to avoid using transactional fixtures and then using something like database_cleaner between tests/scenarios. I recently ran into the following article which suggested doing the following: spec_helper.rb class ActiveRecord::Base mattr_accessor :shared_connection @@shared_connection = nil def self.connection @@shared_connection || retrieve_connection end end # Forces all threads to share the same connection. This works

Rspec: How to capture the examples, Failures and pending Count

不想你离开。 提交于 2020-01-07 04:41:09
问题 Well i am trying to achieve one thing. Something fancy but worth trying.. When i run bundle exec rspec spec/ My test cases pass and i get Finished in 5.12 seconds 38 examples, 0 failures, 1 pending I want to use the MAC OS say command (Read here about it). Which will say after the test suite has completed, that you have 38 examples, 0 failures and 1 pending example . eg command say you have example_count examples, failures_count failures and pending_count pending examples The requirement is,