Skip to content

Instantly share code, notes, and snippets.

@jeremiahlukus
Created December 29, 2017 13:32
Show Gist options
  • Select an option

  • Save jeremiahlukus/93c73d3873445df635a11a44fb5b2d3b to your computer and use it in GitHub Desktop.

Select an option

Save jeremiahlukus/93c73d3873445df635a11a44fb5b2d3b to your computer and use it in GitHub Desktop.
controller test
5 describe "POST #create" do
4 describe "with valid params" do
3 it "creates a new inbound order" do
2 inbound_params = FactoryGirl.attributes_for(:inbound_order)
>> 1 document = Document.create(name: Faker::App.name, doc: File.new("#{Rails.root}/spec/fixtures/test_file.pdf"))
27 inbound_params.documents << document # this is stupid but I need to do the for the inbound order not the params
1 expect { post :create, :inbound_order => inbound_params }.to change(InboundOrder, :count).by(1)
2 end
3
I need to write the document to the inbound order or I get an error
Failure/Error: elsif @inbound_order.documents.last.name == ""
NoMethodError:
undefined method `name' for nil:NilClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment