When I tried to get date from excel sheet, I get the following error:
undefined method `length' for #<Date: 2011-11-11 (4911753/2,0,2299161)>
C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:439:
in `limit_to_maxlength'
C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:412:
in `type_by_character'
C:/ruby192/lib/ruby/gems/1.9.1/gems/watir-2.0.3/lib/watir/input_elements.rb:379:
in `set'
profile_check.rb:66:in `test_2'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:695:in `run'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:656:in `block (2 levels) in run_test_
suites'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:650:in `each'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:650:in `block in run_test_suites'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:649:in `each'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:649:in `run_test_suites'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:609:in `run'
C:/ruby192/lib/ruby/1.9.1/minitest/unit.rb:508:in `block in autorun'
How can I resolve this error?
In the excel sheet define that column as text so it will fetch proper date as your web page format.
Because excel sheets have different date format.
Related
I'm using Ruby's date module to convert/parse my date into a DateTime object. To do this, I'm using DateTime.parse(<time>). But it throws Date::Error even though it's a valid date. Full error message:
2022-07-13 09:54:48 - Date::Error - invalid date:
main.rb:123:in `parse'
main.rb:123:in `block (2 levels) in <main>'
main.rb:121:in `each'
main.rb:121:in `block in <main>'
Code that throws the error:
time = DateTime.parse(client["properties"]["closedate"])
I can run minitest through terminal command, but when I run the same command through jenkins, it throws "ArgumentError: invalid date" on all my test cases. I can't find any solutions from Google. Anyone can help me? And is here the right place to ask these questions?
ruby ../udesk_devops/autotest.rb 'develop' 'daily'
This can run correct through command line.
But will through 'invalid date' through jenkins
And in the process of executing through jenkins, I can see rollback in the log.
It seems the data is trying to go into mysql from fixtures.
Error:
test_问题库分类列表(管理员的问题库)(OpenApiV1::KnowledgeCatalogsControllerTest):
ArgumentError: invalid date
/usr/share/rvm/gems/ruby-2.3.3/gems/timecop-0.8.1/lib/timecop/time_extensions.rb:108:in `parse'
/usr/share/rvm/gems/ruby-2.3.3/gems/timecop-0.8.1/lib/timecop/time_extensions.rb:108:in `parse_with_mock_date'
/usr/share/rvm/gems/ruby-2.3.3/gems/activesupport-4.0.13/lib/active_support/core_ext/string/conversions.rb:53:in `to_datetime'
/usr/share/rvm/gems/ruby-2.3.3/gems/activesupport-4.0.13/lib/active_support/core_ext/date_time/calculations.rb:164:in `<=>'
/usr/share/rvm/gems/ruby-2.3.3/gems/activesupport-4.0.13/lib/active_support/core_ext/time/calculations.rb:286:in `compare_with_coercion'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:570:in `=='
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:570:in `block (2 levels) in table_rows'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:569:in `each'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:569:in `block in table_rows'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:557:in `each'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:557:in `map'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:557:in `table_rows'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:473:in `block (3 levels) in create_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:471:in `each'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:471:in `block (2 levels) in create_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/database_statements.rb:203:in `block in transaction'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `within_new_transaction'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/database_statements.rb:203:in `transaction'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:470:in `block in create_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:274:in `disable_referential_integrity'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:457:in `create_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:899:in `load_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:859:in `setup_fixtures'
/usr/share/rvm/gems/ruby-2.3.3/gems/activerecord-4.0.13/lib/active_record/fixtures.rb:712:in `before_setup'
/var/lib/jenkins/workspace/udesk_proj_week_daily/test/test_helper.rb:35:in `before_setup'
I've been doing testing with this tool to migrate data from mongo db and this one of the issue that I have yet to find out a solution... been wondering a while looking for a solution... but there's no clear solution until now. Please find the stack trace below..
mosql version unknown (but when I try to uninstall the mosql, it mentions the version of mosql-0.4.3
ruby version: ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]
I made a changes to cli.rb under this folder C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\mosql-0.4.3\lib\mosql to delete "USR2" at line 27 from the list to fix issue of running mosql.
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1252:in `literal_other_append': can't express BSON::ObjectId('5656805534616f4c317b7bff') as a SQL literal (Sequel::Error)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:108:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:486:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/adapters/shared/postgres.rb:1272:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/sql.rb:109:in `to_s_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1214:in `literal_expression_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:86:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:494:in `block in complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:492:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:492:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/adapters/shared/postgres.rb:1272:in `complex_expression_sql_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/sql.rb:109:in `to_s_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1214:in `literal_expression_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1229:in `literal_hash_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:84:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:504:in `block in _literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:499:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:499:in `_literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/extensions/pg_array.rb:483:in `sql_literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1248:in `literal_other_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:108:in `literal_append'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1576:in `block in update_sql_values_hash'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1568:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1568:in `update_sql_values_hash'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:1559:in `update_set_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:229:in `_update_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/sql.rb:175:in `update_sql'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sequel-4.34.0/lib/sequel/dataset/actions.rb:818:in `update'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/sql.rb:59:in `upsert!'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:61:in `block (2 levels) in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:39:in `unsafe_handle_exceptions'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:60:in `block in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:57:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:57:in `rescue in bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:52:in `bulk_upsert'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:164:in `import_collection'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:122:in `block (2 levels) in initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:120:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:120:in `block in initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:108:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:108:in `initial_import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/streamer.rb:28:in `import'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/cli.rb:167:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/lib/mosql/cli.rb:16:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mosql-0.4.3/bin/mosql:5:in `<top (required)>'
from C:/Ruby22-x64/bin/mosql:22:in `load'
from C:/Ruby22-x64/bin/mosql:22:in `<main>'
You probably want to add an #sql_literal or #sql_literal_append method to BSON::ObjectId so that Sequel knows how to literalize it.
This is the error. Please, does anyone know a solution?
sansontakeshi-no-MacBook-Air:~ yama1223xxx$ vagrant up
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:127:in `downcase': invalid byte sequence in Windows-31J (ArgumentError)
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:127:in `block (2 levels) in fs_real_path'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:126:in `each'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:126:in `block in fs_real_path'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:125:in `each'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/util/platform.rb:125:in `fs_real_path'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.3/lib/vagrant/environment.rb:118:in `initialize'
from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant:157:in `new'
from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant:157:in `<main>'
Per this page, consider setting your locale to ja_JP.UTF-8:
$ export LANG=ja_JP.UTF-8
Okay so this is a new one. RSPec. Rails 4.
This line is in my spec_helper.rb:
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
When I run a simple test (on an ActiveRecord model):
it { should respond_to :activity }
I get the following error & trace:
/Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord 4.0.0/lib/active_record/attribute_methods.rb:59:in `instance_method_already_implemented?': version is defined by Active Record (ActiveRecord::DangerousAttributeError)
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:282:in `block in define_attribute_method'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:279:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:279:in `define_attribute_method'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `block in define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:246:in `define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:29:in `block in define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:26:in `synchronize'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:26:in `define_attribute_methods'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:167:in `respond_to?'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:368:in `__define_callbacks'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:79:in `run_callbacks'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/core.rb:216:in `init_with'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/persistence.rb:55:in `instantiate'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `block in find_by_sql'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `block in each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/result.rb:21:in `each'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `map'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/querying.rb:45:in `find_by_sql'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:585:in `exec_queries'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:471:in `load'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation.rb:220:in `to_a'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/relation/delegation.rb:12:in `map'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:787:in `get_all_versions'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:793:in `current_version'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:800:in `needs_migration?'
from /Users/dev/.rvm/gems/ruby-2.0.0-p247#projectname/gems/activerecord-4.0.0/lib/active_record/migration.rb:379:in `check_pending!'
from /projects/subset_of_projects/this_project_group/projectname/spec/spec_helper.rb:17:in `<top (required)>'
I'd added the paper_trail gem but not run the install/migrations. Simple and obvious really. But it wasn't an error I'd seen before so I'll post this so others who might run into it can check the obvious before wasting a long time on this.