Rspec: how can I check if a call to a method of another class is called?

You should not know where the method is called, just if the method is called.. You just know if the method is call: Before RSpec 3 it “should auto populate feed after user.add_friend” do FeedItem.should_receive(:populate_from_friend_to_user).with(@friend1, @user) @user.add_friend(@friend1) end In RSpec 3 the syntax is expect(Object).to receive(:method).with(params)

Stubbing Devise in rSpec and Rails3

I found that it is now pretty easy to do this. There was a problem with rspec2 and devise, but is now solved. I guess you would need to update your gems. Then you can write require ‘spec_helper’ describe DoStuffController do include Devise::TestHelpers before (:each) do @user = Factory.create(:user) sign_in @user end describe “GET ‘index'” … Read more

mock Rails.env.development? using rspec

There is a much better way described here: https://stackoverflow.com/a/24052647/362378 it “should do something specific for production” do allow(Rails).to receive(:env) { “production”.inquiry } #other assertions end This will provide all the functions like Rails.env.test? and also works if you just compare the strings like Rails.env == ‘production’

Upgrading to devise 3.1 => getting Reset password token is invalid

You commented on my similar question a bit ago, and I found an answer that might help you as well. Upgrading to Devise 3.1.0 left some ‘cruft’ in a view that I hadn’t touched in a while. According to this blog post, you need to change your Devise mailer to use @token instead of the … Read more

Turn off transactional fixtures for one spec with RSpec 2

I usually add a helper like this: def without_transactional_fixtures(&block) self.use_transactional_fixtures = false before(:all) do DatabaseCleaner.strategy = :truncation end yield after(:all) do DatabaseCleaner.strategy = :transaction end end Which lets me turn off transactional fixtures for a specific block in the specs: describe “doing my thing” do without_transactional_fixtures do it “does something without transaction fixtures” do … … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)