my spec, using macros:
class FoodEntryControllerTest < ActionController::TestCase
context "on GET new" do
setup do
@food_entry = FoodEntry.new
get :new
end
should_assign_to :food_entry
end
end
the error:
/home/oren/weighmyplate/spec/controllers/food_entry_controller_spec.rb:
27:in `block in <class:FoodEntryControllerTest>': undefined method
`should_assign_to' for FoodEntryControllerTest::Subclass_1:Class
(NoMethodError)
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/example/example_group_methods.rb:183:in `module_eval'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/example/example_group_methods.rb:183:in `subclass'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/example/example_group_methods.rb:55:in `describe'
from /home/oren/weighmyplate/spec/controllers/
food_entry_controller_spec.rb:21:in `<class:FoodEntryControllerTest>'
from /home/oren/weighmyplate/spec/controllers/
food_entry_controller_spec.rb:20:in `<top (required)>'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/example_group_runner.rb:15:in `load'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/example_group_runner.rb:15:in `block in load_files'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/example_group_runner.rb:14:in `each'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/example_group_runner.rb:14:in `load_files'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/options.rb:132:in `run_examples'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
lib/spec/runner/command_line.rb:9:in `run'
from /opt/ruby-1.9.1-p243/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/
bin/spec:5:in `<top (required)>'
from /opt/ruby/bin/spec:19:in `load'
from /opt/ruby/bin/spec:19:in `<main>'
btw, machers works:
describe FoodEntryController, "GET new" do
before(:each) do
get :new
@food_entry = FoodEntry.new
end
it { should assign_to( :food_entry ) }
end
thanks!
if RAILS_ENV == 'test'
if defined? Spec
require 'shoulda/rspec'
else
require 'shoulda/rails'
end
end
so it looks like it's one or the other.
Best.
Mike
> --
> Individuals over processes. Interactions over tools.
>
> Agile Rails training from thoughtbot, the makers of Clearance, Shoulda, & Factory Girl:
> http://thoughtbot.com/services/training
>
> The Shoulda group:
> http://groups.google.com/group/shoulda
>
> To post to this group, send email to
> sho...@googlegroups.com
>
> To unsubscribe from this group, send email to
> shoulda+u...@googlegroups.com