cats and tags

got difference?
Added by Matt Platte almost 2 years ago

How about this: One Category, Many Tags


Comments

Added by Matt Platte almost 2 years ago

http://rubyforge.org/pipermail/rspec-users/2009-May/014712.html

"...[A]ll you need to do is write out
(on paper/in Vim/whatever) the behaviour of each scenario that can
occur while traversing through this controller. For example, one
[verbose] scenario is:

"When a user who's not logged-in and whose session isn't being
redirected requests HTML from FooBarsController#show , they should be
redirected to the sign-up page."

"Once you have the behaviour of each scenario mapped out, write specs
for each scenario.

"When that's all done, I recommend writing your specs before you write code.
-Nick

Added by Matt Platte almost 2 years ago

That aside, the nil error is happening because the user() method is
returning nil (in user.avatars). You can fix that by changing this:

  controller.stub!(:requires_user).and_return(@user)

to this:

  controller.stub!(:user).and_return(@user)

Though you may need to also stub requires_user if it's in a before
filter (which I think I remember from another thread on this), so
you'd actually want:

  controller.stub!(:requires_user)
  controller.stub!(:user).and_return(@user)

This way requires_user() doesn't do anything, and the user() method
returns the mock user. Of course, it's going to need to respond to the
avatars() method:

  @user.stub!(:avatars).and_return([@avatar])

or something like that.

Added by Matt Platte almost 2 years ago

http://www.m3p.co.uk/blog/2009/03/08/mock-roles-not-objects-live-and-in-person/

describe Hero do
  it "should describe its surroundings" do
    hero = Hero.new(room)  

    room.stub!(:description).and_return("a room with twisty passages")

    console.should_receive(:show).with("in a room with twisty passages")
    hero.look(console)
  end
end