Я работаю над обновлением приложения rails 3.2
до rails 4.2.10
, у меня почти все проработано, модульные и интеграционные тесты пройдены.
У меня возникли некоторые проблемы с тестами функцийЯ использую capybara 3.3.0
и poltergeist 1.18.1
, и это вызывает ошибку на visit '/'
Я рассмотрел множество проблем со стеком, касающихся Попытка присвоить свойству только для чтения но ни один из них не применим к моему делу здесь,
Это мой урезанный файл спецификации
require 'vcr'
Capybara.default_max_wait_time = 10
feature "Create something" do
include SpecHelpers
include Acceptance
before do
setup_database
end
after do
teardown_database
end
scenario "Creating a Consignment", :js => true do
puts "Running with #{Capybara.current_driver}"
VCR.use_cassette('cassette_name.yml') do
page.driver.resize(1000,2200) unless Capybara.current_driver == :selenium
visit '/'
expect(page).to have_content 'EMAIL'
expect(page).to have_content 'PASSWORD'
end
end
end
Это мой урезанный файл помощника спецификации
ENV["RAILS_ENV"] ||= 'test'
require_relative '../config/environment.rb'
require 'rspec/rails'
require 'capybara/rails'
require 'capybara/poltergeist'
require 'shoulda/matchers'
require 'redis'
require 'redis-namespace'
require 'resque'
require 'mock_redis'
require 'bcrypt'
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
# rspec
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
RSpec.configure do |config|
config.deprecation_stream = 'log/deprecations.log'
end
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, :type => :controller
end
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
BCrypt::Engine.cost = 1
if (ENV['DEBUG_CAP'])
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
else
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors: true})
end
Capybara.javascript_driver = :poltergeist
end
Capybara.server_port = 31337
Capybara.server = :webrick
module SpecHelpers
def setup_database
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
end
def teardown_database
DatabaseCleaner.clean
end
end
module Acceptance
VCR.configure do |c|
require 'webmock'
c.hook_into :webmock
c.cassette_library_dir = 'fixtures/vcr_cassettes'
c.allow_http_connections_when_no_cassette = true
c.default_cassette_options = {:record => :new_episodes}
c.ignore_request do |request|
URI(request.uri).port == Capybara.server_port || request.uri=~/shutdown/ || request.uri=~/session/
end
end
def wait_until(timeout = Capybara.default_max_wait_time)
require "timeout"
begin
Timeout.timeout(timeout) do
sleep(0.3) until value = yield
value
end
rescue => e
save_screenshot "capybara_#{Time.now.to_i}.png"
puts e.message
puts e.backtrace
raise e
end
end
end
require "rspec/mocks/standalone"
....
Этоэто трассировка стека ошибок
Running with poltergeist
Error: Attempted to assign to readonly property.
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:22:3139
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:3551
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:19730
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12707
s@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:20964
g@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12573
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:16265
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:22205
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4884
$digest@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:7801
$apply@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:9410
http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26430
a@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26340
Z@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26051
http://127.0.0.1:31337/lib/bfd57c67.components.js:7:28112
d@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:18351
fireWith@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:19152
ready@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:13970
wt@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:11347
Error: Attempted to assign to readonly property.
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:22:3139
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:3551
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:19730
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12707
s@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:20964
g@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12573
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:16265
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:22205
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4884
$digest@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:7801
$apply@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:9410
http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26430
a@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26340
Z@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26051
http://127.0.0.1:31337/lib/bfd57c67.components.js:7:28112
d@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:18351
fireWith@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:19152
ready@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:13970
wt@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:11347
Error: Attempted to assign to readonly property.
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:22:3139
r@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:3551
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:19730
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12707
s@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:20964
g@http://127.0.0.1:31337/lib/bfd57c67.components.js:5:12573
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:16265
http://127.0.0.1:31337/lib/bfd57c67.components.js:5:22205
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
c@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4206
http://127.0.0.1:31337/lib/bfd57c67.components.js:6:4884
$digest@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:7801
$apply@http://127.0.0.1:31337/lib/bfd57c67.components.js:6:9410
http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26430
a@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26340
Z@http://127.0.0.1:31337/lib/bfd57c67.components.js:4:26051
http://127.0.0.1:31337/lib/bfd57c67.components.js:7:28112
d@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:18351
fireWith@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:19152
ready@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:13970
wt@http://127.0.0.1:31337/lib/bfd57c67.components.js:1:11347
Обновление 1
При некоторой отладке получается, что ошибка генерируется из angularjs-bootstrap-datetimepicker пакет, когда он пытается установить $render
на функцию,
var ngModelController = $element.controller('ngModel')
var configuration = createConfiguration()
$scope.screenReader = configuration.screenReader
// Behavior
$scope.changeView = changeView
ngModelController.$render = $render --> in this line