This should be a simple one, but just could not find out why it caused the testing failure. I kept getting the following error when running rspec. But after commenting "send" method, everything works fine.
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
Model Code
class Message
include Mongoid::Document
belongs_to :target_app
end
Controller Code
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
Every object in Ruby has a send method:
http://ruby-doc.org/core-1.9.3/Object.html
By naming your action "send" you caused a name conflict. Try renaming that action to "sendmessage" or defining it in a different way. There should be a way to have "send" in your URL map to an action named "sendmessage".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With