Change your test case as below:
class ElementsControllerTest < ActionController::TestCase
test "should get create" do
post :create, element: {attrb1: "value", attrb2: "value"}, piece_id: id_of_existing_piece_record ## Post method
assert_response :success
end
end
create
is a post
route not a get
route. This is why you are getting error as No route matches {:action=>"create", :controller=>"elements"}
Also, as elements
is nested within pieces
, you would have to pass an id of existing piece to your post :create
call.
element: {attrb1: "value", attrb2: "value"}
is for the attributes that you would like to save in element record.