RSpec any_instance deprecation: how to fix it?

In my Rails project I’m using rspec-mocks using any_instance but I want to avoid this deprecation message: Using any_instance from rspec-mocks’ old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should instead. Here is my specs: describe (“.create”) do it ‘should return error when…’ do User.any_instance.stub(:save).and_return(false) … Read more

Executing cv::warpPerspective for a fake deskewing on a set of cv::Point

I’m trying to do a perspective transformation of a set of points in order to achieve a deskewing effect: http://nuigroup.com/?ACT=28&fid=27&aid=1892_H6eNAaign4Mrnn30Au8d I’m using the image below for tests, and the green rectangle display the area of interest. I was wondering if it’s possible to achieve the effect I’m hoping for using a simple combination of cv::getPerspectiveTransform … Read more

Using Rspec, how do I test the JSON format of my controller in Rails 3.0.11?

I’ve scoured the web, but, alas, I just can’t seem to get Rspec to correctly send content-type so I can test my JSON API. I’m using the RABL gem for templates, Rails 3.0.11, and Ruby 1.9.2-p180. My curl output, which works fine (should be a 401, I know): mrsnuggles:tmp gaahrdner$ curl -i -H “Accept: application/json” … Read more

Could not find generator rspec:install (q2)

I’m trying to follow this tutorial here: http://railstutorial.org/chapters/static-pages#top When I run: $ rails generate rspec:install I get: Could not find generator rspec:install. What could be the problem? [Rails 3, 4, 5, 6, 7] Thanks. Answer Add to your Gemfile: group :development, :test do gem ‘rspec-rails’ end and run bundle install make sure that it is … Read more

Guard with RSpec on Rails 4 giving a lot of warnings

I’m wondering how I can turn off all these warnings when running a simple test: [1] guard(main)> 16:59:46 – INFO – Run all 16:59:46 – INFO – Running all specs /Users/esjd/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:124: warning: instance variable @example not initialized /Users/esjd/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:124: warning: instance variable @example not initialized .* Pending: HomeHelper add some examples to (or delete) /Users/esjd/ruby/rails/ts3/spec/helpers/home_helper_spec.rb # … Read more

Rails rspec set subdomain

I am using rSpec for testing my application. In my application controller I have a method like so: def set_current_account @current_account ||= Account.find_by_subdomain(request.subdomains.first) end Is it possible to set the request.subdomain in my spec? Maybe in the before block? I am new to rSpec so any advice on this would be great thanks. Eef Answer … Read more

How do you test an AJAX request with RSpec/RoR?

I’m fairly new to RoR and recently started learning BDD/Rspec for testing my application. I’ve been looking for a way to spec an AJAX request, but so far I haven’t found much documentation on this at all. Anyone know how to do this? I’m using rails 2.3.8, rspec 1.3.0 and mocha 0.9.8 for my stubs … Read more

RSpec documentation…where is it hiding?

Having a terrible time finding RSpec-2 (and rspec-rails) documentation. Specifically I want to look up all available Matchers… but how? I’ve tried: RSpec.info : outdated – RSpec 1.x rdoc.info : seems useless, to me anyway. (incomplete?) RSpec-Relish : confusing. incomplete? how would one look up available Matchers? GitHub Wiki : scattered info. unorganized. incomplete? Yes, … Read more