Hello,
I'm trying to spec a plugin that includes a module that adds
functionality to ActionController below is what I've come up with:
# vendor/plugins/custom_attribute_fu/spec/active_record_spec.rb
require File.dirname(__FILE__) + '/spec_helper'
class TestPerson < ActiveRecord::Base
end
class TestPeopleController < ActionController::Base
#calling defines_custom_attributes should add the
custom_attribute_definitions method, I've defined it explicitly for
now to just get the tests running
#defines_custom_attributes
def custom_attribute_definitions
end
end
describe TestPeopleController do
describe "handling GET /custom_attribute_definitions" do
before(:each) do
@controller = TestPeopleController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def do_get
get :custom_attribute_definitions
end
it "should be successful" do
do_get
response.should be_success
end
end
end
When I run the spec I get:
1)
ActionView::TemplateError in 'TestPeopleController handling GET /
custom_attribute_definitions should be successful'
undefined method `custom_attribute_definitions' for TestPerson(id:
integer, name: string):Class
What I don't understand is that why get :custom_attribute_definitions
is trying to call that method on TestPerson rather than
TestPersonController.
I'm sure there's a better way to set this up - any advice would be
greatly appreciated!
Les
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users