Rspec received an unexpected message: [] with

I write a mapper which matches attributes received from facebook and set them to my model. class Mapper::FacebookUser def initialize (user, facebook_user) @user = user @facebook_user = facebook_user end def name @user.name = @facebook_user['name'] if

Boolean comparison in the rspec error

In Rspec, I'm trying to test the approximative return value of a function. I defined the following : def approx_equals(val, expected, perc_error_accepted) margin = (expected * perc_error_accepted / 100) return val >= expected - margin && val &l

How to use current_user to test the serializer in rspec

I am new to rails and serializers.I am using active model serializer gem for serialization. One of the attributes uses devise helper method 'current_user'.It works fine.But While running the spec using rspec i get an error undefined local variable or

Rspec test this method has a default value for an argument

I may have missed this somewhere, but how can I test that a method that takes an argument uses a default value if an argument is not provided? Example # this method shouldn't error out # if `Post.page_results` without a parameter class Post def self.

Change the color of Rubymine Rspec

Im using Rspec for Testing, but CAN'T find how to change the grey color in to Red and Green. Im testing so much that -especially when an error occurs- im having a hard time reading the passed and failures. Any help would be nice :) I got it running b

Is there a real Rails project with RSpec?

I'm learning RSpec for a while and reading some articles, books and other resources. But I wonder if is there any complete real life Rails project, that using RSpec, with source codes available to examine. I study some gems and Ruby projects but stil

RSpec should_receive not reach the method in class

New to ruby/rspec and trying to test that a method raises an exception. I may be going about this entirely incorrectly. #require 'rspec' describe "TestClass" do it "should raise exception when my method is called" do test = Test.new te

How to test the text on the rendered view?

Here is my test: require "rspec" describe HomeController do render_views it "should renders the home" do get :home response.should render_template("home") response.should include_text("Simulate Circuits Online") end

Are there any RSpec extensions for HTML tags for sinatra?

I've been using for Rails apps I've been maintaining the hpricot_matchers and most recently rspec_tag_matchers as matcher implementations to test strings with nested tags inside (like, let's say, HTML or XML). Specially the last one is really good, s

RSpec - as_null_object?

It's not clear to me what the purpose of as_null_object is and in what scenarios you would use it? According to the documentation on Relish: Use the as_null_object method to ignore any messages that aren't explicitly set as stubs or message expectati

In RSpec I want to replace the argument with a method call

My app is using OpenURI's open() method, to fetch a web page. In my spec I want to be able to replace the URL passed in open to the path of a local file. So when calling open('http://www.google.com') I want to switch that url to /path/to/file. Is the

Problem when specifying an explicit subject?

I am using Ruby on Rails 3.0.9 and RSpect 2. I am trying to refactoring some spec file in the following way (in order to test with less code similar User class object attribute values): describe User do let(:user1) { Factory(:user, :users_attribute_a

How to test after_sign_in_path_for (resource)?

I have devise authentication and registration set up on my Rails app. I'm using after_sign_in_path_for() to customise the redirect when the user signs in based on various scenarios. What I'm asking is how to test this method? It seems hard to isolate

Rspec test using a regular database and not a test database

I am using Rspec, webrat, selenium rc for tests. I am trying to do integration test with selenium and rspec. I just looked in my development database and learned that my integration tests are using my development database and not my test database. Ho

After Rails 3 upgrade rake db: test: prepare does not work?

I have just gone through the process of upgrading a Rails 2.3.11 app that uses Test Unit to Rails 3.1.rc4 and I have now set up rspec-rails 2.6.1. I also switch the test connection in database.yml to use sqlite instead of postgres. I can run rake db:

Rspec testing redirect_to: back

How do you test redirect_to :back in rspec? I get ActionController::RedirectBackError: No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env["

Connection test with Capybara / Rspec

I am having some difficulty in testing my login procedure. Currently, I have the following request spec: describe "GET /admins" do before(:each) do @admin = Factory.create(:user, :winery => nil, :email => '[email protected]', :admin =>

rake spec gives me an error

HI guys, I am not good with gem management and having problem getting my RSpec to work properly. In my gem list I have these rspec (2.1.0) rspec-core (2.1.0) rspec-expectations (2.1.0) rspec-mocks (2.1.0) rspec-rails (2.1.0) And when I run rake spec

Reduce currency in rSpec and Rails3

How would you stub Devise in Rails 3 with rSpec. I have a UsersController and a User model. Both of which are associated with Devise at the moment, I'm writing controller specs and I really am having a hard time with my expectations as the Devise sig

Why does upgrading to Rails 3.2.1 fail several Rspec tests?

All 211 specs in my test suite were passing fine...until I upgraded from rails 3.2 to rails 3.2.1. Now 197 of my specs fail with errors. Most of these error have the "wrong number of arguments (0 for 1)" error described below. Example #1: class