CableReady (Rails) Basic case giving mystifying error message - ruby-on-rails

cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?

Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.

Related

Ruby gem origami sign signature failed

I'm trying to make the PDF file with signature with origami gem, follow this example https://github.com/gdelugre/origami/blob/master/examples/signature/signature.rb
Now i just run this signature.rb and got error
[error] Breaking on: ">>\nendobj\n..." at offset 0x1f6f3
[error] Last exception: [Origami::InvalidObjectError] Failed to parse object (no:43,gen:0) -> [ArgumentError] wrong number of arguments (given 1, expected 0; required keyword: year)
I have no idea to move forward :'<
I also found the sign method of gem at https://github.com/gdelugre/origami/blob/master/lib/origami/signature.rb, and have take a look, I can't find any specific things to do :'<
Might this example is outdate?
The error message is known see https://github.com/gdelugre/origami/issues/80
A fix should be available https://github.com/gdelugre/origami/pull/74/commits
But has not been added so use newer file from the fork https://github.com/pocke/origami/tree/fix-ruby-2.7-kwargs-warnings
Specifically you need this updated file and may need to follow any other suggestions from above.
https://github.com/pocke/origami/raw/fix-ruby-2.7-kwargs-warnings/lib/origami/filters/predictors.rb
However it always worth looking for a fork with many more recent improvements such as
https://github.com/joelsondrew/origami

MockWebServer: java.lang.NoSuchMethodError

Trying MockWebServer for the first time on a Groovy/Spring project that uses Spock for unit testing.
I added MockWebServer dependencies as directed (I had to add the second line myself to avoid errors, but it's not documented:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")
I have a basic Spock test that looks like this:
def 'server'() {
setup:
MockWebServer server = new MockWebServer()
expect:
server
}
But it fails with this output:
java.lang.NoSuchMethodError: okhttp3.internal.Util.immutableListOf([Ljava/lang/Object;)Ljava/util/List;
at okhttp3.mockwebserver.MockWebServer.<init>(MockWebServer.kt:176)
Is there another dependency I'm missing? Does MockWebServer not play well with Groovy and Spock?
For what it's worth, using version 3.1.4 seems to work:
testImplementation("com.squareup.okhttp3:mockwebserver:3.14.2")
(I'm a first time user of MockWebServer)
Thank you!
Try adding this:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("com.squareup.okhttp3:okhttp:4.0.0")
With MockWebServer your OkHttp dependency must be the same version.
I got the same problem, I found the solution in version, just change the version to "3.7.0" and it's work fine.
there is some discussion about version changing to "3.4.1" but this version got the problem (Cannot inherit from final class) that discussed at this issue :
https://github.com/andrzejchm/RESTMock/issues/56
so the safest version is "3.7.0" :D
just notice that both versions should be the same..
change your to dependencies to below:
//mock retrofit
testImplementation("com.squareup.okhttp3:mockwebserver:3.7.0")
testImplementation("com.squareup.okhttp3:okhttp:3.7.0")
//if your source code is java
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")

TypeError: expect(...).toBeObservable is not a function - Jasmine marbles

I am trying to write a basic ngrx effects testing. However I keep getting the error as TypeError: expect(...).toBeObservable is not a function.
This is a new project setup with Angular 7. I had no issues with my previous projects which ran in angular 4.
Initially thought it could be something to do with packages so upgraded all packages to the most latest but no luck yet.
I event tried to test a very simple observable as expect(effects.test$).toBeObservable(5); but it gives the same error. As mentioned in the title I am using jasmine-marbles and the version is 0.4.1.
You need to init the test scheduler and add matchers in before each or toBeObservable will not be defined:
import { addMatchers, initTestScheduler } from 'jasmine-marbles';
beforeEach(() => {
...
initTestScheduler();
addMatchers();
});

Problems with using clj-oauth

I'm developing Twitter sign in for my platform. I want to use for this purpose clj-oauth library (https://github.com/mattrepl/clj-oauth). I added [clj-oauth "1.5.2"] to my project.clj and created seperate file oauth.clj for testing purposes with only this code:
(ns greenius.service.oauth
(:require
['oauth.client :as 'oauth]))
When I try compile oauth.clj I get error:
ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Named clojure.core/name (core.clj:1518)
I have an impression that I follow the guide in every bit. What could be the cause of that error?
Remove the ' because you are using the require from inside the ns macro, so the names have to be symbols.
Example from the ns documentation:
(ns foo.bar
(:refer-clojure :exclude [ancestors printf])
(:require (clojure.contrib sql combinatorics))
(:use (my.lib this that))
(:import (java.util Date Timer Random)
(java.sql Connection Statement)))
I managed to fix the problem.
First I followed th esuggestion given by #Razvanescu and changed ['oauth.client :as 'oauth] into [oauth.client :as oauth].
After that I was getting new error:
FileNotFoundException Could not locate oauth/client__init.class or oauth/client.clj on classpath: clojure.lang.RT.load (RT.java:443).
When I reran my IDE it changed into CompilerException java.lang.ClassNotFoundException: org.apache.http.conn.ssl.SSLContexts, compiling:(clj_http/conn_mgr.clj:1:1)
Googling that error led me to this: https://github.com/cemerick/friend/issues/128.
I was using friend 0.2.0 and clj-oauth uses clj-http so it applied to my problem. After I upgraded to [com.cemerick/friend "0.2.2-SNAPSHOT"] and reran my IDE the problem was gone and it works now.
Sad thing is that I realized just now that twitter grants info only about username, which in my case is practically useless for sign up...

Why does Corona give an error loading code that loads fine with lua?

I'm having problems with a specific line of code - building.transmitter:[operation](player, unpack({...})) that causes an error in Corona, yet this loads fine when it's run in Lua separately. I suspect it has something to do with the : being placed before the [operation] variable but I'm clueless why.
Specifically the module is written as,
local activate = {}
local function activate.transmitter(player, operation, ...)
building = player:getTile()
building.transmitter:[operation](player, unpack({...}))
end
return activate
The runtime errror that is appearing gives me
"error loading module from file, '<name>' expected near '['"
Edit - WOW! I didn't notice that when troubleshooting this in Corona I changed some of the lines of code to identify the problem. I then mistakenly tested the edited code in Lua and it ran fine. I didn't realize the code wasn't the original until siffiejoe pointed out the interpreter getting an error as well. Sorry for the mistake.
maybe Corona uses older version of Lua which does not support this syntax. You can try workaround instead of
building.transmitter:[operation](player, unpack({...}));
you can call
building.transmitter[operation](building.transmitter, player, unpack({...}));

Resources