Hello,
I have two issues with beta 2.0.0.beta.18. First, here’s the gems :
gem “rails”, “3.0.0.beta4”
gem “mongoid”, “2.0.0.beta10”
group :test do
gem “rspec-rails”, “2.0.0.beta.18”
gem “factory_girl_rails”, “1.0”
end
My spec_helper :
http://github.com/chatgris/blabbr/blob/spec/spec/spec_helper.rb
First issue is related to stubbing the current_user method in
controller.
describe ‘current_user == added_by’ do
before :all do
@current_user = Factory.create(:user)
@smiley = Factory.create(:smiley)
end
before :each do
controller.stub!(:logged_in?).and_return(true)
controller.stub!(:current_user).and_return(@current_user)
end
it 'should be able to see index' do
get :index
response.should be_success
end
end
current_user is defined in application_controller.rb
That code have this result :
SmiliesController current_user == added_by should be able to see index
Failure/Error: controller.stub!(:logged_in?).and_return(true)
undefined method `stub!’ for #SmiliesController:0xb5e848b4
# ./spec/controllers/smilies_controller_spec.rb:36
The other issue is related to helpers specs. Considers this code :
require ‘spec_helper’
describe LinkHelper do
before :all do
@user = Factory.create(:creator)
@topic = Factory.build(:topic)
end
it “displays a 80px width gravatar link to the user page” do
helper.link_to_avatar(@user).should == “<a href="/users/creator
"><img alt="4f64c9f81bb0d4ee969aaf7b4a5a6f40" src="http://
www.gravatar.com/avatar/4f64c9f81bb0d4ee969aaf7b4a5a6f40.jpg?size=80"
/>”
end
end
That gives this error :
LinkHelper displays a 80px width gravatar link to the user page
Failure/Error: Unable to find matching line from backtrace
undefined local variable or method example' for #<RSpec::Core::ExampleGroup::Nested_8:0xb5fc4bac> # /home/chatgris/.bundle/ruby/1.8/bundler/gems/rspec- rails-863ffee12bd6030ece577b07c39297c14aacad85-master/lib/rspec/rails/ example/helper_example_group.rb:54:in
_controller_path’
# /home/chatgris/.bundle/ruby/1.8/bundler/gems/rspec-
rails-863ffee12bd6030ece577b07c39297c14aacad85-master/lib/rspec/rails/
example/helper_example_group.rb:61
Thanks for your help.