rspec工厂女孩没有创建用户

时间:2014-08-19 11:04:56

标签: ruby-on-rails rspec devise

我将rails 3.2deviserspecfactory girl一起使用。我正在尝试登录用户,但似乎首先创建用户存在问题。

用户工厂:

factory :user do 
    first_name "Test"
    last_name "User"
    sequence(:email) { |n| "foo#{n}@test.com" }
    password "secretpassword"
    confirmed_at Time.now
end

我的规范

feature "BackOffice" do 
  subject { page }
  context "as user" do 
    let(:user) { create(:user) }
    describe "should not have access to backoffice" do 
      before do
        visit "http://domain_name/fr/users/sign_in"
        within ".login-wrapper" do
          fill_in "user_email", with: user.email
          fill_in "user_password", with: user.password
          click_button "S'identifier"
        end
      end
      it { should have_content "Bienvenue"}
    end
  end

错误

    Failure/Error: let(:user) { create(:user) }
         ActionView::Template::Error:
           No route matches {:action=>"edit", :controller=>"users/registrations"}
# ./app/views/user_mailer/welcome.html.erb:3:in `_app_views_user_mailer_welcome_html_erb__212088972377821759_70301344598820'
     # ./app/mailers/user_mailer.rb:31:in `welcome'
     # ./app/models/user.rb:125:in `send_welcome_email'
     # ./spec/requests/backoffice_spec.rb:15:in `block (3 levels) in <top (required)>'
     # ./spec/requests/backoffice_spec.rb:20:in `block (5 levels) in <top (required)>'
     # ./spec/requests/backoffice_spec.rb:19:in `block (4 levels) in <top (required)>'
     # ./spec/support/database_cleaner.rb:17:in `block (2 levels) in <top (required)>'

为什么要在创建资源时尝试进行编辑操作?

1 个答案:

答案 0 :(得分:0)

欢迎电子邮件中的链接出现问题我添加了以下内容以解决此问题: config.action_mailer.default_url_options = { protocol: "http", host: "localhost", port: 3000, locale: I18n.locale }