3
votes

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:

enter image description here

1
Images are a horrible way to show error messages etc. - Frederick Cheung
@FrederickCheung Noted thank you! - Bitwise

1 Answers

6
votes

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.