Rspec error: undefined method 'change' for end.should change(Model, :count)
-
12-11-2019 - |
Question
This is a follow on after completing the Ruby on Rails tutorial.
I've spent quite a while trying to mix and match gems to find a solution since I really have no idea how Rspec is having trouble identifying 'change'.
Error: /spec/requests/athletes_spec.rb:20:in
block (3 levels) in ': undefined method change' for #<Class:0x00000100e715e8> (NoMethodError)
require 'spec_helper'
describe "Athletes" do
before(:each) do
@attr = { :gender => "male",
:age => 20,
:height => 120,
:weight => 100,
:skill => 2
}
@user = Factory(:user)
end
describe "Creating Athletes" do
describe "with the correct user should work" do
lambda do
post :create, :athlete => @attr
end.should_not change(Athlete, :count)
end
end
end
I love the concept of TDD but it seems like half the time I'm trying to get the testing environment to work. Can anyone tell me where I'm going wrong?
FURTHER EDIT:
Here's my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.4'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'
gem "will_paginate", "3.0.pre2"
gem 'jquery-rails', '>= 0.2.6'
group :development do
gem 'rspec-rails', '2.5.0'
gem 'annotate-models'
end
group :test do
gem 'factory_girl_rails'
gem 'rspec', '2.5.0'
gem 'webrat'
end
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow