I ran script/generate rspec_scaffold page title:string body:text and
have been reading on the generated code in my spare time in an attempt
to fully understand rspec. It mostly makes a lot of sense except for
the square brackets in the snippet below. To my best understanding,
[mock_page] would be an array containing mock_page. That almost makes
sense, buy why wouldn't the variable mock_page simply be an array like
@pages. You wouldn't say [EMAIL PROTECTED]
I can't get my head wrapped around the syntax.
Thanks in advance.
pages_controller_spec.rb
def mock_page(stubs={})
@mock_page ||= mock_model(Page, stubs)
end
describe "responding to GET index" do
it "should expose all pages as @pages" do
Page.should_receive(:find).with(:all).and_return([mock_page])
get :index
assigns[:pages].should == [mock_page]
end
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users