I'm trying to add rspec testing to an app I've already been working on. I've been following this tutorial: http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html which is from 2012, so I'm sure it was done using Rails 3. I installed rspec and capybara, ran bundle, and ran rails g rspec:install. I started writing the test of my Question model below, and when I ran it with rspec spec/models/question_spec.rb
I received the error: Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=test' to resolve this issue. I tried to run that and I received this error about one of my previous migrations:
== ChangeTestTypeInScores: migrating =========================================
-- change_column(:scores, :test_type, "boolean USING CAST(test_type AS boolean)")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: near "USING": syntax error: CREATE TABLE "scores" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "test_type" boolean USING CAST(test_type AS boolean), "name" varchar(255), "created_at" datetime, "updated_at" datetime, "user_id" integer, "month" varchar(255), "year" varchar(255))
How can I correctly set up rspec without messing up my database, which works fine otherwise?
rails_helper.rb:
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
ActiveRecord::Migration.check_pending!
.rspec:
--color
--require spec_helper
--require rails_helper
--format documentation
question_spec.rb:
require 'spec_helper'
describe Question do
it "has a valid factory"
it "is invalid without a body"
it "is invalid without an answer"
end
I assume there's an issue with my changing the :test_type in my Scores model to boolean based on that error, but it all works great locally and on Heroku, so I don't want to mess with my database in order to run tests. Any help is appreciated.
UPDATE:
I added this to the test.rb file:
config.active_record.maintain_test_schema = false
Also, I updated my version of rails to 4.1.6 after seeing many other related Stack Overflow issues. Now I get this error:
/Users/tambe257/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load': cannot load such file -- /Users/tambe257/programming/rails_projects/fast_track/spec/models/question.rb (LoadError)
It looks like a problem with some dependencies, but I've been googling the error with no luck.
On the update above I added this to the test.rb file, which actually cleared things up:
config.active_record.maintain_test_schema = false
I was then getting the (LoadError), but that was due to my file name not being completely correct. When you enter something like this below, be sure the route and file name are correct!
rspec spec/models/question_spec.rb
Related
When I attempt to edit an IFCBUILDINGSTOREY name value and write a new IFC file in WIT using the ExportFileAsIFC code from the IFC.js Crash Course IFC editing section, I get an error: Line object cannot be serialized:
Object { expressID: 138, type: 3124254112, GlobalId: {…}, OwnerHistory: {…}, Name: {…}, Description: null, ObjectType: {…}, ObjectPlacement: {…}, Representation: null, LongName: {…}, … } IFCWorker.js:87228:15. The value is definitely changed in the IFC data in the browser console output but it doesn't get written to the new IFC file. I cannot see any difference between my code and the course example code. The problem appears to be that the revised IFC data in the browser console output defines the storey as IFCBUILDINGSTOREY in the IFC.js course video but on my laptop the storey is defined as OBJECT in the browser console output. So I think it literally cannot serialize the non-specific OBJECT.
I have posted the project on my GitHub at https://github.com/quarto-zz/WIT2
Please can anyone tell me what is different?
Looks like a regression in web-ifc#0.0.36. We are looking into it. In the meantime, it should be solved by using the previous version by running the command: npm i web-ifc#0.0.35 web-ifc-three#0.0.118.
Solution found! In discussions with #ansoni on Discord at IFC.js the problem turned out to be two IFC library versions. The Crash Course videos show the library install commands for web-ifc and web-ifc-three as generic, which installs the latest version of each. The current versions of those two libraries cause a couple of issues, including the above problem. At this time, it is important to install the specific versions used in the Crash Course.
npm i web-ifc#0.0.35 web-ifc-three#0.0.118
You can check which versions you have currently loaded in the package.json file.
If you install the correct versions, be sure to replace the wasm and IfcWorker files locally, if you are already using them.
This will solve the above ExportFileAsIFC issue and also a failure to load an IFC file into a WIV scene issue.
The latest versions of these libraries that I had these issues with are:
web-ifc#0.0.36 and web-ifc-three#0.0.121
/data/local/tmp/VtsHalBiometricsFaceV1_0TargetTest/VtsHalBiometricsFaceV1_0TargetTest.config[1]: syntax error: unexpected 'newline'
Total Tests : 1
PASSED : 1
FAILED : 0
IMPORTANT: Some modules failed to run to completion, tests counts may be inaccurate.
============== End of Results ==============
Issue : Test case is passing but module is not getting reported as completed.
Issue seen with only Android 11 based VTS suites and works well with older android flavor VTS suites.
Environment of 18.04.2 LTS ubuntu and few modules inspite of passing the test cases it does not report a module pass (only for few modules) and shows it as Done=false in results report.
Logs indicate this kind of errors pointing to various .config files.
Any idea / suggestion what could be issue ?
This was asked again in syntax error: unexpected 'newline' in .config file in android vts and that got an answer that if you've modified the vts-tradefed file, then this error appears.
Additionally I noticed that even chmod changes can cause this problem to appear.
I am upgrading from Flyway 5.4 to 7.7.3 and ran into some issue.
flyway -teams -url=jdbc:oracle:thin:#localhost:1521/XE "-user=xxx as SYSDBA" -password=xxx -table=flyway_schema_history_app -encoding=utf-8 -baselineOnMigrate=true migrate
(I have the teams edition license)
Flyway gives me the following error message:
**
ERROR: Unable to parse statement in /flyway/sql/incremental/Build_302_Baseline/V302_106__fosprd_INSERT_Master_eg_pocqueue.sql at line 117 col 1. See https://flywaydb.org/documentation/knownparserlimitations for more information: No value provided for variable substitution: &R. Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
Caused by: No value provided for variable substitution: &R. Check your configuration. If this is not a SQLPLus variable intended to be substituted (eg. in a string literal), then you will need to add SET DEFINE OFF in the script beforehand.
**
This is caused by a special character "&" in the SQL statement, however, I have made sure the SQL file is using UTF-8 encoding as well as Unix return (LF).
Also, I keep my callbacks under:
bash-5.0$ pwd
/flyway/sql/callbacks
bash-5.0$ ls
afterBaseline.sql afterEachUndo.sql afterMigrateError.sql afterUndo.sql beforeEachUndo.sql
afterBaselineError.sql afterEachUndoError.sql afterRepair.sql afterUndoError.sql beforeMigrate.sql
afterEachMigrate.sql afterMigrate.sql afterRepairError.sql beforeEachMigrate.sql beforeUndo.sql
This used to be able to run on 5.4 with no issue. But it's giving me this error on 7.7.3, anyone can point me to the right direction?
Thanks
This is due to the changes between versions of flyway's SQLPlus support and the fat you have a teams license.
As indicated in the message, this is related to SQLPlus's variable substitution:
https://flywaydb.org/documentation/database/oracle#variable-substitution
If you are not using SQLPlus features, you could try disabling them:
https://flywaydb.org/documentation/configuration/parameters/oracleSqlPlus
but the recommended solution is to place SET DEFINE OFF in the SQL script before the offending ampersand (with the option of reverting that afterwards)
I use PHPUnit to test by PDO wrapper. One of my tests is an integration test that proves that the abstraction layer produces the right syntax, or binds PDOStatement in the right way, etc. For this, I use an in-memory SQLite database, and declare ext-pdo_sqlite as a dev-dependency of my project.
When Github Actions runs a build, dependencies all get installed, hinting that pdo_sqlite is present on the system. This is further confirmed by the fact that the connection succeeds. However, when I run an insert query to set up my database, I get the following error:
PDOException: SQLSTATE[HY000]: General error: 1 no such column: TRUE
The query looks like this:
INSERT INTO `persons` (`id`, `name`, `dob`, `weight`, `is_dev`, `teeth`) VALUES (NULL, 'Anton', '1987-11-03', 71.3, TRUE, 31)
Table creation is done with PDO like this:
$pdo->exec("CREATE TABLE `$tableName` (`id` int(6) PRIMARY KEY, `name` varchar(255), `dob` datetime, `weight` float(5), `is_dev` bool, `teeth` int(2))");
This only manifests on CI, and local tests pass fine - even on the same PHP version as CI.
Any ideas? Am I just missing something in the syntax? Could it be that GH Actions has only a dummy implementation of SQLite or something?
Note: This is an open source project, and you can see everything, including the failing build, in dhii/pdo-query#1.
I have developed a Symfony2 project (v2.2.2) and it was working all fine locally.
When I deploy it on my server I meet 2 issues:
the folder /bin does not transfer through Filezilla (impossible to start transfer)
i encounter a parse error when trying to access web/app.php/ in debug mode (see below)
First I do not understand why it would work in local but not on production.
I also guessed these errors where linked but I do not know what is /bin used for (contains only 2 files doctrine and doctrine.php) and if I remove it locally it keeps working ...
Parse error is the following :
"FatalErrorException: Parse: syntax error, unexpected '[' in /home/colocall/twinkler/src/Tk/ExpenseBundle/Services/Expenses.php line 21"
Expenses.php line 15->25:
public function getAllExpenses($member, $group)
{
$all_expenses_col = $group->getExpenses();
$all_expenses = array();
foreach($all_expenses_col as $expense){
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
}
return $all_expenses;
}
Maybe linked to : The parse error also happen when i try to update my database through ssh connection.
If someone would know the reason why I can't make it working it would save my day that i have already lost ...
Thank you in advance,
Jules
Your error is produced by using the short array syntax [] in your code.
It is not available in PHP 5.3.10 aka on your production server. The short syntax was introduced in PHP 5.4 which explains why your code is working in your dev-environment.
change ...
$all_expenses[] = [$expense, $this->forYou($member, $expense)];
...to
$all_expenses[] = array($expense, $this->forYou($member, $expense));
... or update your server's php version and it will work :)