Capybara issue when trying to click form submit button - ruby-on-rails

I'm pretty new to Ruby/Rails and especially to Capybara and the whole process, so please bear with me as I've spent a lot of time on this already and I finally decided to ask because I'm sure it's something simple that I just am as-of-yet unaware of.
So I have a form that has several checkboxes that are designed to filter the results displayed (ie, you select one or more and submit and thew page reloads with the list filtered). In my features file, I have the following scenarios (the button to submit the form has a value="Refresh"):
Scenario: no ratings selected
When I uncheck the following ratings: G, PG, PG-13, NC-17, R
And I press "Refresh"
Then show me the page
And I should see none of the movies
Scenario: all ratings selected
When I check the following ratings: G, PG, PG-13, NC-17, R
And I press "Refresh"
Then show me the page
And I should see all of the movies
When I run this with rake features, it gives the following output:
And I press "Refresh" # features/step_definitions/web_steps.rb:61
xprop: unable to open display ''
I am using page.body a little later in the scenario and I believe this is the reason I then get the following errors:
Deprecated: please use #source_tags instead.
Warning: program returned non-zero exit code #1
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
<link>
No applications found for mimetype: text/html
/usr/bin/xdg-open: 563: links2: not found
/usr/bin/xdg-open: 563: links: not found
/usr/bin/xdg-open: 563: lynx: not found
Error occured while reset 800b: errno=5
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-201203260037535403047955.html'
Error occured: errno=5
Warning: program returned non-zero exit code #1
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
<link>
No applications found for mimetype: text/html
/usr/bin/xdg-open: 563: links2: not found
/usr/bin/xdg-open: 563: links: not found
/usr/bin/xdg-open: 563: lynx: not found
Error occured while reset 800b: errno=5
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-201203260037534847572739.html'
Error occured: errno=5
Warning: program returned non-zero exit code #1
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
<link>
No applications found for mimetype: text/html
/usr/bin/xdg-open: 563: links2: not found
/usr/bin/xdg-open: 563: links: not found
/usr/bin/xdg-open: 563: lynx: not found
Error occured while reset 800b: errno=5
xdg-open: no method available for opening '/home/ubuntu/hw3_rottenpotatoes/tmp/capybara /capybara-20120326003754980186501.html'
Here are the relevant step definitions
When /I (un)?check the following ratings: (.*)/ do |unc, rating_list|
rating_list.split(", ").each do |r|
if(unc)
uncheck("ratings_#{r}")
else
check("ratings_#{r}")
end
end
assert true, "Implemented checking function"
end
Then /I should (not )?see movies with the following ratings: (.*)/ do |nt, rating_list|
flag = true
rating_list.split(", ").each do |r|
if(nt)
if(page.body =~ /<td>#{r}/)
flag = false;
end
else
if(page.body !~ /<td>#{r}/)
flag = false
end
end
end
assert flag, "Seeing (or not) movies of ratings list - implemented"
end
Then /I should see all of the movies/ do
tot = Movie.all.count
assert page.have_selector('tbody tr', :count => tot)
end
Then /I should see none of the movies/ do
num = page.body.scan(/00:00:00 UTC/m).length
assert size == 0, "Showing no movies - implemented"
end
When /^(?:|I )press "([^"]*)"$/ do |button|
click_button(button)
end
Then /^show me the page$/ do
save_and_open_page
end
I have been researching for days when I have time and there is just so much I don't know. Any help or insights would be greatly appreciated. Thank you!

Your problem is that you don't have any browser installed to handle html files.
It seems you are using an headless server (without X) so your system is trying to find a suitable browser (one that can be run from the command line).
Take a look at Capybara drivers and choose an appropriate one.

Related

Lua error -129 for most mediawiki templates

I've been attempting to import some wikipedia templates in my local mediawiki wiki, but most attempts at using them end up with the same error. For instance, for the following code :
==Title==
{{Main|Title}}
(which uses the main template), I get the following error :
Lua error: Internal error: The interpreter has terminated with signal "-129".
No further details are available.
I haven't been able to find any occurence of that error, or even a relevant use of 129 in the source code I could find, and there is nothing generated in the Lua error log.
The Lua binaries have all been given permission to be executed, and I have installed the Scribunto and TemplateStyles extensions and a variety of modules, although beyond the ones advised for main, I don't know where to find a list of missing modules if there are any.
Edit : Here is the output of $status in Scribunto :
array(8) {
["command"]=> string(459) "'exec' '/bin/sh' '/XXX/extensions/Scribunto/includes/engines/LuaStandalone/lua_ulimit.sh' '7' '8' '51200' ''\''/XXX/extensions/Scribunto/includes/engines/LuaStandalone/binaries/lua5_1_5_linux_32_generic/lua'\'' '\''/XXX/extensions/Scribunto/includes/engines/LuaStandalone/mw_main.lua'\'' '\''/XXX/extensions/Scribunto/includes'\'' '\''0'\'' '\''4'\'''"
["pid"]=> int(17067)
["running"]=> bool(false)
["signaled"]=> bool(true)
["stopped"]=> bool(false)
["exitcode"]=> int(-1)
["termsig"]=> int(-129)
["stopsig"]=> int(0)
}
I am beginning to suspect that the issue may be that my server doesn't allow executables.

How to translate erlang error messages into user friendly text in elixir

I recently got the following error when I was trying to read a file in elixir.
iex()> File.read("no_existant_file.csv")
{:error, :enoent}
Luckily I knew what "enoent" meant and quickly realised that this was because I had a typo in the file name. Once I fixed this everything worked as expected.
However, this made me wonder if there was a way to change this error message into a more "human friendly" message that could potentially be displayed to an end user?
The function I was after in this question is the erlang function :file.format_error.
Using the example above
iex()> {:error, error_msg} = File.read("no_existant_file.csv")
{:error, :enoent}
iex()> error_msg
:enoent
iex()> :file.format_error(error_msg)
'no such file or directory'
Using :file.format_error/1 we can see that the error is now a lot more user friendly

Trying to use re-frame-10x (was re-frame-trace) with descjop (electron) project

I'm trying to set up a project using a combination of re-frame and electron and I woud like to install re-frame-10x so I can easily watch certain parts of the app-db. I have used it before with a regular clojurescript/re-frame project accessed via google chrome, but not yet using electron. I'm hopeful, as I believe electron uses basically the same code as chrome under the hood.
I followed the setup instructions on the re-frame-10x github page and all seems to be ok. However I'm not able to call up the 10x window.
This is part of my project.clj file, notably the clojurescript dev builds:
:cljsbuild
{:builds
{:dev-main {:source-paths ["src"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/dev/js/cljsbuild-main.js"
:externs ["app/dev/js/externs.js"
"node_modules/closurecompiler-externs/path.js"
"node_modules/closurecompiler-externs/process.js"]
:warnings true
:elide-asserts true
:target :nodejs
:output-dir "app/dev/js/out_main"
:optimizations :simple
:pretty-print true
:output-wrapper true
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [day8.re-frame-10x.preload]
:main "anh.core" }}
:dev-front {:source-paths ["src_front" "src_front_profile/anh_front/dev"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/dev/js/front.js"
:externs ["app/dev/js/externs_front.js"]
:warnings true
:elide-asserts true
:optimizations :none
:output-dir "app/dev/js/out_front"
:pretty-print true
:output-wrapper true }}
Note that there are 2 builds. (figwheel-status) tells me it is watching and recompiling dev-front. dev-main contains the pointer to main that re-frame-10x needs.
Clojurescript has been upgraded to the latest version "1.10.64" and everything looks fine, no error messages as the repl starts (using jack-in from emacs) or as the clojurescript repl starts.
There is still no sign of the re-frame-10x window. It should appear when I hit ctrl-h in the app window.
Below this line is things I tried on the way. Probably irrelevant.
Scrolling back through the clojure repl messages I see that it hit some kind of problem with re-frame-10x during the startup of the cljs repl:
user> Figwheel: Starting server at http://0.0.0.0:3441
Figwheel: Watching build - dev-front
Figwheel: Cleaning build - dev-front
Compiling "app/dev/js/front.js" from ["src_front" "src_front_profile/anh_front/dev"]...
Failed to compile "app/dev/js/front.js" in 10.853 seconds.
---- Could not Analyze app/dev/js/out_front/day8/re_frame_10x/subs.cljs ----
No such namespace: cljs.spec.alpha, could not locate cljs/spec/alpha.cljs, cljs/spec/alpha.cljc, or Closure namespace "cljs.spec.alpha"
---- Analysis Error : Please see app/dev/js/out_front/day8/re_frame_10x/subs.cljs ----
Launching ClojureScript REPL for build: dev-front
Any idea what this means? I'm not using cljs.spec (yet) but it seems like the compiler is looking for it.
This is a section of the project.clj file, with the modifications asked for by re-frame-10x, notably the closure-defines, preload and link to main in the compiler section of the relevant cljsbuild section:
:dev-front {:source-paths ["src_front" "src_front_profile/anh_front/dev"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/dev/js/front.js"
:externs ["app/dev/js/externs_front.js"]
:warnings true
:elide-asserts true
:optimizations :none
:output-dir "app/dev/js/out_front"
:pretty-print true
:output-wrapper true
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [day8.re-frame-10x.preload]
:main "anh.core"
}}
Update:
this helped:
No such namespace: clojure.spec.alpha in clojurescript project setup
Following the suggestion, I upgraded the clojurescript to the latest version which has the spec stuff needed and the repl shows a different error when the cljs repl is started:
Failed to load resource: net::ERR_FILE_NOT_FOUND
cljs_deps.js Failed to load resource: net::ERR_FILE_NOT_FOUND
base.js:677 goog.require could not find: day8.re_frame_10x.preload
goog.logToConsole_ # base.js:677
base.js:711 Uncaught Error: goog.require could not find: day8.re_frame_10x.preload
at Object.goog.require (base.js:711)
at index.html:11
base.js:677 goog.require could not find: anh.core
goog.logToConsole_ # base.js:677
base.js:711 Uncaught Error: goog.require could not find: anh.core
at Object.goog.require (base.js:711)
at index.html:11
base.js:677 goog.require could not find: anh_front.init
goog.logToConsole_ # base.js:677
base.js:711 Uncaught Error: goog.require could not find: anh_front.init
at Object.goog.require (base.js:711)
at index.html:12
This is just the main function not being found. The project.clj file specifies 2 dev builds, dev-front and dev-main. I had the clojurescript compiler options in the wrong section. Moving them to the correct section gets rid of the errors but the re-frame-10x window still won't appear when I hit ctrl-h.
The key to fixing this was putting it in the right build. Descjop has 2 dev builds, one for the app itself (dev-main) and one for the window (dev-front). Dev-main can, and probably should, be left alone. The changes need to go in the dev-front build.
Step 1
Convert the dev-front build to :optimizations none. This is one of the requirements for re-frame-10x. To do this the following needs to be added to the cljsbuild section of profile.clj under the :dev-front :compiler section:
:main "setup-front.init"
:asset-path "js/out_front"
The html file can then be simplified as "setup-front.init" will load the necessary stuff for you. Something like this:
<body>
<div id="app">
<p>Minimum app does not work.</p>
</div>
<script type="text/javascript" src="js/front.js" charset="utf-8"></script>
</body>
Step 2
Upgrade! Descjop by default uses an older version of clojurescript that doesn't provide some of the functions re-frame-10x uses. org.clojure/clojurescript "1.10.64" works for me.
After that the re-frame-10x instructions can be followed and it should just work. In short, add the following to the cljsbuild section right next to where you put the :main statement
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [day8.re-frame-10x.preload]
and add this to the dependencies. Probably best to go in the :profiles :dev section. Check the instructions or clojars for the most up to date version though:
[day8.re-frame/re-frame-10x "0.2.1-SNAPSHOT"]
The source of a very basic hello-world using these changes is available on github
Thanks to Mike Callahan for the gist of this solution.

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...

Vim: How do I tell where a function is defined? (

I just installed macvim yesterday and I installed vim latex today.
One of the menu items is calling a broken function (TeX-Suite -> view).
When I click on the menu-time it makes this call:
:silent! call Tex_ViewLatex()
Question: Where can I find that function? Is there some way to figure out where it is defined?
Just for curiosity sake I removed the silent part and ran this:
:call Tex_ViewLatex()
Which produces:
Error detected while processing function Tex_ViewLaTeX:
line 34:
E121: Undefined variable: s:viewer
E116: Invalid arguments for function strlen(s:viewer)
E15: Invalid expression: strlen(s:viewer)
line 39:
E121: Undefined variable: appOpt
E15: Invalid expression: 'open '.appOpt.s:viewer.' $*.'.s:target
line 79:
E121: Undefined variable: execString
E116: Invalid arguments for function substitute(execString, '\V$*', mainfname, 'g'
)
E15: Invalid expression: substitute(execString, '\V$*', mainfname, 'g')
line 80:
E121: Undefined variable: execString
E116: Invalid arguments for function Tex_Debug
line 82:
E121: Undefined variable: execString
E15: Invalid expression: 'silent! !'.execString
Press ENTER or type command to continue
I suspect that if I could see the source function I could figure out what inputs are bad or what it is looking for.
Use the :verbose prefix command:
:verbose function Tex_ViewLaTeX
In the second line of output (just above the function's body) is the location of where the function was defined.
I installed gVim 7.2 on windows and latex-suite, and miktex too
I tried what you said, after compile and view, I can view the dvi files
The error message seemed like to indicate it's the view's problem
The document for latex-suite said the viewer for Macintosh is not set, maybe it's where the problem lies
I think you can try to set a few variables in your .vimrc file, to set up the proper viewing app for PDF files
And the source code for Tex_ViewLaTeX is here:
http://www.tedpavlic.com/research_related/tpavlic_masters_thesis/compiler.vim
By the way, I also installed MacVim on my Macbook Pro, however I never used vim for LaTeXing, because I find TextMate and its latex bundle is much superior than MacVim, you'll definately like it
One way to search would be to do a grep or vimgrep on directory tree where you thought the source file was located. Search for 'function Tex_ViewLatex' or 'function! Tex_ViewLatex'.
I believe in the usual install it would be in a .../ftplugin/latex-suite/compiler.vim file, as part of the latex-suite plugin. There are a couple ftplugin directories, so make sure you get right one (one is in tree of main vim install and other may be off your home .vim directory.
It seems there is a bug with the Tex_ViewLatex function on OS X. Check here for some info:
http://comments.gmane.org/gmane.comp.editors.vim.latex.devel/775
Put this in your .vimrc, solved the problem for me.
let g:Tex_ViewRule_pdf = 'open -a Preview.app'

Resources