我在Rails应用程序(5.2.3)上使用Rspec 我所有的测试在本地都是绿色的,但是在travis.ci上却失败了 下面是部分错误和我的travis配置。希望您能提供帮助。
主要错误是
ArgumentError:
SMTP To address may not be blank: []
这是包含更多详细信息的错误...它是怎么在本地而不是在Travis上传递的?
45.84s$ bundle exec rails spec
/home/travis/.rvm/rubies/ruby-2.4.4/bin/ruby -I/home/travis/.rvm/gems/ruby-2.4.4/gems/rspec-core-3.8.0/lib:/home/travis/.rvm/gems/ruby-2.4.4/gems/rspec-support-3.8.0/lib /home/travis/.rvm/gems/ruby-2.4.4/gems/rspec-core-3.8.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
Randomized with seed 28885
....FFFFFFFF.F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-27.450.html
.F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-27.997.html
****.............WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt. You're using version 4.8.6.
Capybara starting Puma...
* Version 3.12.1 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:45832
F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-32.656.html
Image screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-32.656.png
.............*...**....F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-38.949.html
..........F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-42.247.html
Image screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-07-09-13-42.247.png
*......................................F...F HTML screenshot: /home/travis/build/knop/kamelot/tmp/capybara/screenshot_2019-05-25-00-00-00.000.html
.............
1) Returnings showing a returning displays the order's date and returning's limit date
Failure/Error: ReturningMailer.send_returning(self).deliver_now
ArgumentError:
SMTP To address may not be blank: []
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/check_delivery_params.rb:21:in `check_to'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/check_delivery_params.rb:7:in `check'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/network/delivery_methods/test_mailer.rb:38:in `deliver!'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/message.rb:2159:in `do_delivery'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/message.rb:260:in `block in deliver'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/mail-2.7.1/lib/mail/message.rb:260:in `deliver'
# ./app/models/returning.rb:37:in `send_email_with_status'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/configuration.rb:18:in `block in initialize'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/evaluation.rb:18:in `create'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/strategy/create.rb:12:in `block in result'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/strategy/create.rb:9:in `tap'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/strategy/create.rb:9:in `result'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/factory.rb:43:in `run'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/factory_runner.rb:29:in `block in run'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/factory_runner.rb:28:in `run'
# /home/travis/.rvm/gems/ruby-2.4.4/gems/factory_bot-4.11.1/lib/factory_bot/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# ./spec/features/admin/returnings/returnings_spec.rb:10:in `block (2 levels) in <top (required)>'
这是我的配置.travis.yml
language: ruby
rvm:
- 2.4.4
addons:
postgresql: "9.4"
before_install:
- gem install bundler -v '>= 2'
- "echo 'gem: --no-document' > ~/.gemrc"
- "echo '--colour' > ~/.rspec"
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
before_script:
- bundle exec rake db:create db:migrate RAILS_ENV=test
cache:
bundler: true
directories:
- node_modules
yarn: true
install:
- bundle update --bundler
- bundle install
- nvm install node v11.10.0
- node -v
- npm i -g yarn
- yarn
script:
- bundle exec rails webpacker:compile
- bundle exec rails spec
返回模型
def send_email_with_status
if self.pending?
ReturningMailer.send_returning(self).deliver_now #line 37
elsif self.confirmed?
ReturningMailer.received_returning(self).deliver_now
end
end
我在config / test.rb中添加了它,但是这里不再失败了。 (感谢提示)
config.action_mailer.perform_deliveries = false