Reputation: 8451
I fell a bit ridiculous but I really have no idea what this error is trying to tell me? I'm new to rspec and this is a new one for me. I'll post my code for clarity - ERROR: undefined method `permit' for "1":String|
CONTROLLER:
def subscriber_params
params.require(:subscriber).permit(:first_name, :last_name, :email, :phone_number)
end
SPEC: require "rails_helper"
describe SubscribersController do
include Devise::TestHelpers
let(:user) { FactoryGirl.create(:user) }
let(:subscriber) { FactoryGirl.create(:subscriber) }
it "creates a new comment" do
sign_in(user)
comment = FactoryGirl.attributes_for(:comment)
expect { post :create, subscriber: subscriber, comment: comment }.to change(Comment, :count).by(1)
end
end
ERROR:
Upvotes: 3
Views: 1376
Reputation: 106882
Change
let(:subscriber) { FactoryGirl.create(:subscriber) }
to
let(:subscriber) { FactoryGirl.attributes_for(:subscriber) }
because you want to pass the subscriber's attributes to the request not an actually instance of a subscriber.
Upvotes: 7