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
13
votes
1 answer

rspec not_to change from not behaving as expected

I am experiencing some baffling behavior in rspec and rspec-rails 2.11.0. I have reproduced the behavior on a co-worker's app running 2.7.1 (both on ruby 1.9.3) These tests work as expected (fails): it "should not change i" do i = 0 expect…
Johnny C
  • 1,799
  • 1
  • 16
  • 27
13
votes
2 answers

Factory Girl sequences not incrementing

I'm trying to get FactoryGirl to generate some names for me, but the sequence doesn't seem to increment. # spec/factories/vessel.rb require 'factory_girl' FactoryGirl.define do sequence :vessel_name do |n| "TK42#{n}" end factory :vessel…
Dean Brundage
  • 2,038
  • 18
  • 31
13
votes
5 answers

Organizing rspec 2 tests into 'unit' and 'integration' categories in rails

How to organize rspec 2 tests into 'unit' (fast) and 'integration' (slow) categories? I want to be able to run all unit tests with just rspec command, but not the 'integration' tests. I want to be able to run only 'integration' tests.
Evgenii
  • 36,389
  • 27
  • 134
  • 170
12
votes
2 answers

How to mix a module into an rspec context

How can I mix a module into an rspec context (aka describe), such that the module's constants are available to the spec? module Foo FOO = 1 end describe 'constants in rspec' do include Foo p const_get(:FOO) # => 1 p FOO …
Wayne Conrad
  • 103,207
  • 26
  • 155
  • 191
12
votes
3 answers

Speeding up rspec controllers test: using before all fails?

I have a simple controller test, containing a.o. the following code: context "POST :create" do before (:each) do post :create, :user_id => @user.id, :account => { .. some data ... } end it { response.status.should == 201 } it {…
nathanvda
  • 49,707
  • 13
  • 117
  • 139
12
votes
2 answers

rspec 2: detect call to method but still have it perform its function

I want to check if a method was called exactly(n) times, but I still want that method to perform its original function. Consider a simple thumbnailing system that caches the thumbnail file and make sure ImageMagick's "convert" executable that…
joao
  • 3,517
  • 1
  • 31
  • 43
12
votes
4 answers

Application Controller helper methods not available for Views Specs

I have a helper method called current_user in my Application Controller (used with Authlogic). Spec for views using that helper fail (but the view is working when i use the browser) ActionView::Template::Error: undefined local variable or method…
Dorian
  • 2,571
  • 23
  • 33
12
votes
3 answers

RSpec response.body is still empty even with config.render_views

In my spec_helper.rb file I have specifically set it to config.render_views but the response.body I get back is still empty. Here is my basic spec describe "#index" do it "should list all rooms" do get 'index' stub(Person).all …
CountCet
  • 4,545
  • 7
  • 30
  • 39
12
votes
2 answers

Rails 3, RSpec 2.5: Using should_receive or stub_chain with named scopes

I use Rails 3.0.4 and RSpec 2.5. In my controllers I use named scopes heavily, for example @collection = GuestbookEntry.nonreplies.bydate.inclusive.paginate( :page => params[:page], :conditions => { ... }) In my tests, I want to be able…
Jens
  • 1,386
  • 14
  • 31
12
votes
1 answer

RSpec 2: NoMethodError on 'route_to' with rspec-rails?

I'm trying to run this test... require 'spec_helper' describe HomeController do describe 'boilerplate routes' do it "should route to '/about'" do { :get => "/about" }.should route_to(:controller => 'home', :action => 'show') end …
neezer
  • 19,720
  • 33
  • 121
  • 220
12
votes
2 answers

Rspec test in ruby on rails, cannot load such file webmock/rspec

when I run rspec test in my ruby on rails application.. git@ruby-rails:~/gitlab$ sudo bundle exec rspec spec/controllers/public_spec.rb No DRb server is running. Running in local process instead…
Qinghao
  • 274
  • 2
  • 11
12
votes
4 answers

How to force run all RSpec specs ignoring :focus tag

Given the following RSpec configuration (v2.12.0): RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.filter_run :focus => true config.run_all_when_everything_filtered = true end Sometimes people…
prashantrajan
  • 123
  • 1
  • 6
12
votes
2 answers

How can you get rspec to print failed test backtraces *as* it is running?

Our test quite takes a while to run, and there is always this 5-10 minute period where we know which test has failed, but we can't see the failure message or backtrace until the suite finishes. It would be more efficient to see the backtraces as…
Brian Armstrong
  • 19,707
  • 17
  • 115
  • 144
11
votes
4 answers

rspec returns "PG::Error: ERROR: relation "table_name" does not exist"

Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error. 1) ApiController articles OK Failure/Error: Unable to find…
inohiro
  • 285
  • 1
  • 3
  • 17
11
votes
1 answer

Rspec with rails 3.1 gives DEPRECATION WARNING ActiveRecord::Associations::AssociationCollection is deprecated?

I upgraded to rails 3.1 and I have some problems with my tests now that worked perfectly before. I get the following warning before the tests: DEPRECATION WARNING: ActiveRecord::Associations::AssociationCollection is deprecated! Use…
user929062
  • 807
  • 4
  • 12
  • 33