XChain is now running on rSpec
Whilst I wait to sort out the UI issues I’m building up the specs’ for XChain. I’m using RSpec, so it’s a lot more ’self documenting’ about what you can expect the application to do. Starting on a fresh project, it’s immensely enjoyable to get into the spec -> code -> test -> repeat cycle. If you’re at all hesitant about getting into them feel free to go browse the source of my specs. I only spent a little time on it last night but already starting to see progress - a lot of the schema is getting cleaned up as a result of the specs. Here’s the doc out put so far (which is about a fraction of what the finished specs will look like !).
Order when creating a new order - should be able to instantiate - should default to draft status - should be able to prefill an address - should have a default price type matching customer price type - should calculate return 0 dollars - should throw an error that it doesn't have line items - should be able to be edited - should be able to have an order line added Order when finding existing order - should have id = 1 - should have a purchase order number - should have 3 order lines - should have a billing address - should have a customer
To get the specs running.
1. Grab a latest copy of xchain from subversion http://xchain.googlecode.com/svn/trunk/.
2. Dump all databases, then create, and run migrations.
3. Install rpsec using instructions from here
4. Run rake rspec
5. You should (at time of writing) get 13 examples with 1 failure (to work on!)
By the end of the weekend there should be a healthy amount of specs in there and fair portion of the model structure of orders, pricing, customer management done.
Heres a sample chunk of code
require File.dirname(__FILE__) + '/../spec_helper' describe Order, "when creating a new order" do fixtures :orders, :order_lines, :customers, :addresses, :addressables, :products it "should be able to instantiate" do @order = Order.new end it "should default to draft status" do @order = Order.new @order.order_status_id.should == 10 end it "should be able to prefill an address" do @customer = Customer.find(1) @order = Order.new @order.should respond_to(:prefill_address) @order.prefill_address(Customer.find(1)) @order.billing_address.should eql(@customer.addresses.default_billing.address) @order.billing_city.should eql(@customer.addresses.default_billing.city) @order.billing_postcode.should eql(@customer.addresses.default_billing.postcode) @order.shipping_address.should eql(@customer.addresses.default_shipping.address) @order.shipping_city.should eql(@customer.addresses.default_shipping.city) @order.shipping_postcode.should eql(@customer.addresses.default_shipping.postcode) end end
If you want an introduction on rspec follow your nose to either the rpsec docs (which are fairly self explanatory) or if you’re the visual sort the head on over to http://peepcode.com/products/rspec-basics for a screencast (disclaimer, haven’t watched it, but judging on Peepcode’s previous efforts it should be good).

No Comments, Comment or Ping
Reply to “XChain is now running on rSpec”