Điều này phải đơn giản, nhưng không thể tìm ra lý do tại sao nó gây ra lỗi thử nghiệm. Tôi đã nhận được lỗi sau khi chạy rspec. Nhưng sau khi bình luận "gửi" phương pháp, mọi thứ hoạt động tốt.Nhận sai số đối số (2 cho 0) khi chạy Kiểm tra Rspec bằng cách nhận và xóa
1) Messages GET /messages works! (now write some real specs)
Failure/Error: get target_app_messages_path(@message.target_app.id)
ArgumentError:
wrong number of arguments (2 for 0)
# ./app/controllers/messages_controller.rb:37:in `send'
routes.rb
resources :target_apps do
resources :messages do
member do
post 'send'
end
end
end
Mẫu Mã
class Message
include Mongoid::Document
belongs_to :target_app
end
điều khiển Mã
class MessagesController < ApplicationController
def index
...
end
def show
...
end
...
def send
...
end
end
/spec/requests/message_spec.rb
describe "Messages" do
describe "GET /messages" do
let(:message) do
FactoryGirl.create(:message)
end
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
get target_app_messages_path(message.target_app.id)
response.status.should be(200)
end
end
Cảm ơn, David. Thay đổi hành động thành tên khác hoạt động. – CCK
Một tên hành động khác cần tránh là 'xử lý'. – Mika