Created by Tasha Jones / @latazzajones
Check out the docs! http://www.relishapp.com/rspec/rspec-rails/v/3-4/docs/
Check out the docs! https://github.com/jnicklas/capybara http://www.rubydoc.info/github/jnicklas/capybara
Check out the docs! https://github.com/thoughtbot/factory_girl/wiki
We're going to add a '#new' action to a controller in my Garbage Pail Kids app.
I'd like to be able to grow my collection of Garbage Pail Kids. Lets add a #new action.
aka - spec in real life
aka - please stop using should!
Context implies a change in the conditions around the code running
don't chain it.
Person.where(:first_name => "Monique").where(:last_name => "Meloche").where(:import_id => import.id).first
can just be
Person.where(first_name: "Monique", last_name: "Meloche", import_id: import.id).first
it "should create an order for everything, too" do
import.orders.sort_by {|o| o.id}.each_with_index do |order, index|
order.organization.should eq import.organization
order.transaction_id.should be_nil
order.details.should_not be_nil
order.import.should eq import
order.payment_method.should eq target_orders[index].payment_method
order.person.should eq target_orders[index].person
end
end
it "should create settled items" do
import.orders.each do |order|
order.items.each {|item| item.should be_settled}
end
end
What happens when an import fails?