Gần đây đã chuyển sang Rails 4 và nhận các lỗi mà tôi chưa nhận được trước đây. Tôi đang thử nghiệm một biểu mẫu mà tôi đang sử dụng Capybara/Rspec.Bắt một ActionController :: UnknownFormat, kiểm tra rspec khi tạo đối tượng mới
Khi tôi bấm vào nút trên biểu mẫu, các lỗi tôi nhận được là:
Failure/Error: find(".submit.button").click
ActionController::UnknownFormat:
ActionController::UnknownFormat
# ./app/controllers/office_listings_controller.rb:32:in `create'
# ./spec/features/office_listings_spec.rb:78:in `block (3 levels) in <top (required)>'
Nó trỏ đến bộ điều khiển của tôi trông giống như:
def create
selected_amenities = params[:amenities] || [] # empty list if no amenities checked
@office_listing = OfficeListing.new(params[:office_listing])
@office_listing.broker = current_broker
p current_broker
@office_listing.neighborhood = Neighborhood.find(params[:neighborhood_id])
p @office_listing.neighborhood
if @office_listing && @office_listing.save!
@path = city_neighborhood_office_listing_path(@office_listing, :city_id => @office_listing.neighborhood.city.id, :neighborhood_id => @office_listing.neighborhood.id)
create_amenities(@office_listing, selected_amenities)
respond_to do |format|
format.js
end
else
@failure = "Unable to create office :-("
respond_to do |format|
format.js
end
end
end
và nó không giống như định dạng .js dòng mặc dù tôi có tệp create.js.erb đang được hiển thị khi tôi thực sự chạy trang.
Không hiểu tại sao trang thực sự đang chạy nhưng thử nghiệm của tôi không thành công.
Bất kỳ suy nghĩ nào sẽ được đánh giá cao !!
thử nghiệm của bạn có thể chạy hành động tạo ở định dạng html trong khi trình điều khiển của bạn chỉ chạy ở định dạng js. – rmagnum2002