Questions tagged [rspec2]

RSpec 2 is a version of the Behaviour-Driven Development tool for Ruby programmers. Use this tag only for RSpec 2-specific questions, and tag those questions with [rspec] too.

RSpec 2 is a version of the Behaviour-Driven Development tool for Ruby programmers.

As with all tags with version numbers, please use this tag only for questions which are actually specific to RSpec 2, and always tag such questions with the non-versioned tag as well as with this tag.

1156 questions
17
votes
2 answers

CanCan load_and_authorize_resource triggers Forbidden Attributes

I have a standard RESTful controller that uses strong parameters. class UsersController < ApplicationController respond_to :html, :js def index @users = User.all end def show @user = User.find(params[:id]) end def new …
Tiggers
  • 179
  • 1
  • 3
16
votes
2 answers

how can I test accepts_nested_attributes_for with Rspec Rails3

I have a model as follows: class Greeting < ActiveRecord::Base attr_accessible :headline, :icon, :content belongs_to :user accepts_nested_attributes_for :user, :reject_if => proc { |a| a[:name].blank? || a[:email].blank? } How can I do…
chell
  • 7,646
  • 16
  • 74
  • 140
16
votes
6 answers

Unwanted symbol to string conversion of hash key

When I assign in my controller @my_hash = { :my_key => :my_value } and test that controller by doing get 'index' assigns(:my_hash).should == { :my_key => :my_value } then I get the following error message: expected: {:my_key=>:my_value}, got:…
medihack
  • 16,045
  • 21
  • 90
  • 134
16
votes
1 answer

`require': cannot load such file -- spec_helper (LoadError)

I am creating bundler gem --test=rspec MyGem. in which I'm getting the repository structure. When I try to run the rspec code I get the following error: `require': cannot load such file -- spec_helper (LoadError) I then try to apply require…
user4443990
  • 213
  • 1
  • 3
  • 7
16
votes
2 answers

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…
keruilin
  • 16,782
  • 34
  • 108
  • 175
15
votes
2 answers

Are there any good mutation testing tools for ruby 1.9 and RSpec2?

I used to use Heckle, but it is incompatible with ruby 1.9 because of issues with ParseTree. I've looked for alternatives, but the only thing that looked promising was Chaser, and that did not have any clear documentation that I could use to see if…
Matt Van Horn
  • 1,654
  • 1
  • 11
  • 21
15
votes
3 answers

RSpec list all pending examples

I'm using Rspec to test a rails app. Is there a way to list all the pending examples without running the full test suite?
deb
  • 12,326
  • 21
  • 67
  • 86
15
votes
3 answers

cant get capybara-webkit to work

I am using capybara to do integration testing on my rails 3 app. When i add :js => true to a scenario my tests work with selenium but when i change to use the webkit driver for js i get errors for each like this…
Rick Moss
  • 926
  • 1
  • 17
  • 34
15
votes
2 answers

How to test a function which takes a block with rspec

I have a function, which accepts a block, opens a file, yields and returns: def start &block .....do some stuff File.open("filename", "w") do |f| f.write("something") ....do some more stuff yield end end I am…
constantine1
  • 427
  • 1
  • 5
  • 12
15
votes
2 answers

rspec what is the difference between be nil and be_nil

I am using rspec and for asserts like student.name should be nil student.name should be_nil Both seem to work. is there a difference between using be nil an be_nil ???
Abid
  • 7,149
  • 9
  • 44
  • 51
15
votes
3 answers

Testing ActiveAdmin with rspec

I am trying to get started in testing ActiveAdmin, in particular I need to test a member_action from one of the ActiveAdmin controllers. Do you guys know any good tutorials on this topic? Thank you,
Calin
  • 6,661
  • 7
  • 49
  • 80
15
votes
5 answers

Why after_commit not running even with use_transactional_fixtures = false

Transactional fixtures in rspec prevent after_commit from being called, but even when I disable them with RSpec.configure do |config| config.use_transactional_fixtures = false end The after_commit callback does not run. Here is a rails app with…
14
votes
3 answers

Rails 3 + Rspec 2: Testing content_for

I'm running Rails 3.1.1, RSpec 2.7.0 and HAML 3.1.3. Say I have the following view files: app/views/layouts/application.html.haml !!! %html %head %title Test = stylesheet_link_tag "application" = javascript_include_tag "application" …
Tomas Mattia
  • 371
  • 2
  • 7
14
votes
4 answers

Factory Girl / Capybara deleting records from database mid-test?

Working with RSpec & Capybara, I'm getting an interesting test failure mode which goes away with a few subtle rearrangements of lines in the test case...stuff that shouldn't matter. I'm developing my own authentication system. It is currently…
voxobscuro
  • 2,132
  • 1
  • 21
  • 45
14
votes
7 answers

Is there a good way to debug order dependent test failures in RSpec (RSpec2)?

Too often people write tests that don't clean up after themselves when they mess with state. Often this doesn't matter since objects tend to be torn down and recreated for most tests, but there are some unfortunate cases where there's global state…
mmrobins
  • 12,809
  • 7
  • 41
  • 42