How do I get 'rake test:acceptance' to run successfully on Windows? - ruby-on-rails

I am currently investigating using the selenium-on-rails plug-in for testing an upcoming web app that we are developing.
I've written some tests, and can get them to run successfully in the test runner in the browser, however when I try to run them from the command line using 'rake test:acceptance' I see the following error:
rake aborted!
fork() function is unimplemented on this machine
I have installed the win32-open3 gem and win32-process, neither of these seem to have helped.
Any ideas how I can get this working?

I managed to resolve this by adding the following to the top of acceptance_test_runner.rb:
require 'win32/open3'
require 'win32/process'
However the script was also determining my platform as 'i386-mingw32', which does not match the regexp the script uses to determine if you are on windows /mswin/.
Resolved this second issue by manually specifying
RUBY_PATH=mswin
Phew.

Related

After installing tailwindcss for ruby should I skip the following suggestions/warnings:

I tried to complete the first suggestion by typing
ruby
rails bin/dev
but I was not able to get an output (The terminal showed no output )
then I realized my code was wrong so I tried once again and typed:
rails create bin/dev
But it showed me an error and said "rails aborted!
Don't know how to build task 'create' (See the list of available tasks with rails --tasks)
Did you mean? db:create"
Then I tried the other command by typing rails in front of it but that didn't work either.
So even though my app works should I bother to solve this warning or skip past it?
TLDR: You need to build your CSS output on every Tailwind style addition so execute bin/dev in a terminal to start your rails server AND watch for tailwind changes.
Hey! Your screenshot is saying that you have successfully installed Tailwind via the tailwind-rails gem.
The end of the message provides instructions on how to build your Tailwind CSS during local development so that Tailwind styles are output to the CSS and applied to your app on localhost:3000 immediately.
Option 1: (documented in the installation output) In your terminal, execute bin/dev to start your rails server AND watch for tailwind changes. This command uses a library called foreman to run two processes, reading from the Procfile.dev that was created in your project's root directory during tailwind installation.
Option 2: (documented in this section of the README) In your terminal, execute rails s in one terminal window and rails tailwindcss:watch in a different window (separate commands)
Option 1 is simpler and probably recommended.
(Based on your screenshot, you are not on a Mac and your exact command may differ, but these work for me on a macbookpro.)

rails active_storage:install fails in app created with --minimal

I made an app with --minimal since standard rails apps are bloated and I would rather add pieces one at a time so I don't end up with unused dependencies, etc.
But when I try to add ActiveStorage, I get the following:
rails aborted!
Don't know how to build task 'active_storage:install' (See the list of available tasks
with `rails --tasks`)
Same result with rails active_storage:install:migrations and app:active_storage:install:migrations.
I have uncommented this line in application.rb:
require "active_storage/engine"
But that didn't solve it. I created another app without the --minimal flag and it works just fine for that one so I am sure I am just missing some piece of the puzzle.
Any help is appreciated!
NOTE: I am using Windows Subsystem for Linux with an Ubuntu distro. Rails 6.1.4
Must have done something wrong because it started working. I think the application.rb file didn't get saved.

Rails test unit access denied rename

I'm new here. I search everywhere and I haven't found anything. I'm using rails on windows 10. I'm following the basic tutorial of a sample app. When I execute "rails test" command in the console I get the following errors. I checked the permissions of each file and directory and all have the permissions needed. Can someone help me ?
I'm using rails 6.0.2.2 version.
Hope I'll get answer here.
Solution : I installed ubuntu on windows 10.
Stop your rails server before executing your tests: the server is keeping cache files locked and the testing framework is trying to alter them.
I encountered the same issue (while following what's probably the same tutorial you were following) on Rails 6.0.3.4 on Windows 10 and doing so solved it. (launching the server again before executing tests reproduced it again)
Update: I thought this was a complete solution, but it's more complex than that. Here's my experience:
running rails test while rails server is running results in the error;
running rails test when rails server is not running sometimes results in the error.
I haven't encountered this error on Linux so far, so my guess is that the implementation of Rails of Windows is unstable and sometimes gets stuck locking its own files.
You can check if you can reproduce the same behaviour, but I would report it as a bug.

New rails app from GitHub that worked fails when checked out with bad authentication token devise/rails. Why?

I created an app on one Mac. It runs fine. I checked it into GitHub and pushed it to the remote. I then go to another mac and do git fetch origin,
followed by git reset --hard. I follow this with bundle install, then rails db:reset, and rails db:migrate. I then try to register exactly as I did on the other mac. I get:
ActionController::InvalidAuthenticityToken in Devise::RegistrationsController#create
I'm afraid I'm having a problem with moving the code between machines. They both have exactly the same version of rvm, rails, rbenv, etc. It doesn't seem like it should be this flaky. What other steps are necessary?
I realized after ready the above answer from Vishal, that my environment was not persisted in github. I realize now that I have to check out the code, then run bundle install, then rake db:create, then rake db:migrate, then finally rails s, if I got not errors in the previous. When I did this, I found I had a different rails version on the target computer than I did on the source computer.
I now use a script 'laptop' which I located at: https://github.com/monfresh/laptop.git
This works on a mac ( I use macs pretty exclusively ) and sets up the same environment on each one where it is run. After doing this, I find I can check in codes on one mac, then check them out on another, run laptop, then my rails apps work correctly.

'rails generate model' fails to run

I inherited a Rails application and am having quite a difficult time generating a model. Running 'rails generate model Account' pauses for a moment, but then returns me to the command prompt without the output I would normally expect from a successful operation.
Environment info:
-Rails 4.2.5
-Ruby 2.3.0p, loaded via RVM
I've spent hours trying to debug this myself and have found a few interesting things:
1.) Generating a controller works as expected, only models seem broken
2.) If I create a new Rails project I can generate models as expected
3.) I've verified that spring is not running, using "spring stop"
4.) A similar problem is mentioned in this thread by a user with my same environment. I verified I'm in the proper dir, and also tried running "bundle update" as suggested by a user, but that didn't resolve the problem.
A few other resources allude to this being a problem with RVM, but rolling back to older versions of Ruby haven't made a difference.
Any idea what I'm doing wrong here?
Try the following commands:
bundle config --delete bin
rake rails:update:bin
Was able to reach out to one of the previous developers and learned that I'm dealing with JSONClient models and that's why it isn't working for me. D'oh!

Resources