On Mon, Feb 9, 2009 at 10:18 PM, Sergio Bayona <li...@ruby-forum.com> wrote:
>  describe "responding to GET new" do
>
>    it "should expose a new property as @property" do
>      @account = mock_model(Account)
>      @account.should_receive(:properties)
>      @property = mock_model(Property, :new_record? => false, :errors =>
> [])
>      @account.properties.should_receive(:build).and_return(@property)
>      get :new
>      assigns[:property].should == @property
>    end
>
>  end

Another thing is that instance variables shouldn't be used unless
necessary. As a rule of thumb, things should have as limited a scope
as possible. Prefer class variables to global variables, instance
variables to class variables, and local variables to instance
variables.

Some reasons are 1) to better communicate your intent, 2) to limit the
places you have to look to see where a variable is being changed, and
3) to limit the amount of code that might depend on the variable.

///ark
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to