r1 - 22 Aug 2007 - 15:29:27 - HecPeAreYou are here: TWiki >  Rails Web > RailsSC > TestingWithoutFixtures60RSC

Mejor no usar las fixtures

Al menos no para tests de modelos. Así no dependen de las modificaciones en las propias fixtures conforme se crean más tests.

Stubbing

#La gema mocha facilita el trabajo:

sudo gem install mocha

En test_helper.rb: require "mocha"

cart=Cart.new
cart.line_items.build.stubs(:weight).returns(7)
cart.line_items.build.stubs(:weight).returns(7)
assert_equal 10, cart.total_weight

END

-- HecPeAre - 22 Aug 2007

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki

This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback