dchelimsky (owner)

Fork Of

Revisions

gist: 131285 Download_button fork
public
Public Clone URL: git://gist.github.com/131285.git
Embed All Files: show embed
customer_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
describe Customer, "last billing address" do
  before do
    @customer = Customer.generate!
    @customer = Address.new
  end
  it "should be settable and gettable" do
    @customer.last_billing_address = @account_address
    @customer.last_billing_address.should == @account_address
  end
  ...
end
 
describe Customer, "last delivery address" do
  before do
    @customer = Customer.generate!
    @account_address = Address.new
  end
  it "should be settable and gettable" do
    @customer.last_delivery_address = @account_address
    @customer.last_delivery_address.should == @account_address
  end
end
improved_spec.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
share_examples_for "named address" do
 
  it "should be settable and gettable" do
    named_address = @account_address
    @named_address.should == @account_address
  end
end
 
describe Customer, "last billing address" do
  it_should_behave_like "named address"
 
  before do
    named_address = @customer.last_billing_address=
    @named_address = @customer.last_billing_address