Skip to content

Instantly share code, notes, and snippets.

@sameera207
Created July 6, 2016 00:44
Show Gist options
  • Save sameera207/55f5db2c44865f01187ee471328a36d0 to your computer and use it in GitHub Desktop.
Save sameera207/55f5db2c44865f01187ee471328a36d0 to your computer and use it in GitHub Desktop.
context 'buyer names changes' do
let(:name) { 'Lindt' }
let(:supplier) { Supplier.create(name: 'Cocoa Beans Inc', email: 'cb@gmail.com', password: 'password') }
let(:buyer) { Buyer.cretae(name: name, email: 'lindt@gmail.com', password: 'password') }
subject {
FactoryGirl.create(:trade_request, buyer: buyer, supplier: supplier)
}
# go for a logical context name
context 'without buyer' do
it "creates an SP number from the first 4 letters from the client's name, then the first 4 letters from the supplier's name, then a sequential 3 digit number for each trade request with this combination of client and supplier, starting from an optional starting value" do
expect(subject.sp_number).to eq 'LINDCOCO101'
end
end
# go for a logical context name
context 'with buyer' do
let!(:name) { 'Cadbury' }
it "creates an SP number from the first 4 letters from the client's name, then the first 4 letters from the new supplier's name, and increments the sequential 3 digit number from the previous example" do
expect(subject.sp_number).to eq 'CADBCOCO102'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment