Spec::Rails – Specifying Helpers
Helper Examples live in $RAILS_ROOT/spec/helpers/.
Writing specs for your helpers is a snap. Just tell the context the name of the helper …
describe RegistrationHelper do
...
end
... and then you can reference the methods directly because they are actually included in the specs!
Sample Helpers Examples
require File.dirname(__FILE__) + '/../spec_helper'
describe PeopleHelper do
it "should say hello" do
say_hello.should == "Hello"
end
it "should provide person address text field tag" do
@person = mock_model(Person)
@person.stub!(:address).and_return("The moon")
person_address_text_field.should == "<input id=\"person_address\" name=\"person[address]\" size=\"30\" type=\"text\" value=\"The moon\" />"
end
end