I am new to Ruby/Calabash and managed to set a dedicated calabash automation framework for ios with a page object model pattern and its running successfully.
I want to extend the same framework for android too. I created a dedicated folder for ios and android inside features folder and thought of having their respective page objects inside those folder.
But when I ran calabash-android, calabash finds a similar page class exists in ios folder and started throwing the error message. I want to follow same naming convention for ios and android pages without having this name-clash. Is it possible?
superclass mismatch for class AuthenticationPage (TypeError)
/Users/MACUSER/Documents/Automation/features/ios/pages/authentication_page. rb:5:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/rb_support/rb_language.rb:95:in `load'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/rb_support/rb_language.rb:95:in `load_code_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:180:in `load_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:82:in `each'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime/support_code.rb:82:in `load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:184:in `load_step_definitions'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/runtime.rb:42:in `run!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/lib/cucumber/cli/main.rb:47:in `execute!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-1.3.18/bin/cucumber:13:in `<top (required)>'
/usr/bin/cucumber:23:in `load'
/usr/bin/cucumber:23:in `<main>'
Based on your description of the issue, it is not clear what the problem is.
I think it would help if you added more details about your folder structures and files.
But as you have not mentioned profiles as all I am suspecting that you are not using an .yml file.
When you execute your tests you should define what profile you are running and have one for iOS and one for Android. For each profile you will define what folders to include.
Like this
android: PLATFORM=android RESET_BETWEEN_SCENARIOS=1 -r features/support -r features/android/support -r features/android/helpers -r features/step_definitions -r features/android/pages/
And then when you execute the tests you define for what profile
calabash-android run path_to.apk -p android features/login.feature
If you have not already you should look at either Xamarin cross-platform tutorial or on the Github page for same
had similar problem, solved by adding exclude option "--exclude ios" to android profile in config/cucumber.yml file (and "--exclude android" for ios respectively)
---
android: PLATFORM=android --exclude ios -r features/support -r features/android -r features/step_definitions -r features/android/pages
ios: PLATFORM=ios APP_BUNDLE_PATH=path_to_your.app --exclude android -r features/support -r features/ios/support -r features/ios/helpers -r features/step_definitions -r features/ios/pages
seems to be cucumber bug, because according to cucumber docs -r switch should prevent loading all files except those specified explicitly
-r, --require LIBRARY|DIR Require files before executing the features. If this
option is not specified, all *.rb files that are
siblings or below the features will be loaded auto-
matically. Automatic loading is disabled when this
option is specified, and all loading becomes explicit.
Files under directories named "support" are always
loaded first.
...
-e, --exclude PATTERN Don't run feature files or require ruby files matching PATTERN
Xamarin is saying you should give the profile and the config in the command --profile ios --config=config/cucumber.yml. See this:
test-cloud submit prebuilt/Moda-cal.ipa 93dbwrmwrb0d65099640f23 --devices 99dwdhw846 --series "ip7" --locale "en_US" --app-name "Moda" --user gunesmes#gmail.com --profile ios --config=config/cucumber.yml
test-cloud submit prebuilt/Moda.apk 93dbwrmwrb06sfu440f23 --devices 9933nb846 --series "nex" --locale "en_US" --app-name "Moda" --user gunesmes#gmail.com --profile android --config=config/cucumber.yml
Related
I want to run my lambda function locally (I am currently using ruby 2.7.1), but when I require a gem that needs native dependencies it fails because it doesn't find them.
I tried to use the 'pg' gem to connect to a postgresql database. Then I proceeded to run sam build and sam local invoke HelloWorldFunction --event events/event.json, which failed with the next error:
Invoking app.lambda_handler (ruby2.7)
Failed to download a new amazon/aws-sam-cli-emulation-image-ruby2.7:rapid-1.0.0 image.
Invoking with the already downloaded image.
Mounting /home/user/sam-app/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated
inside runtime container
Init error when loading handler app.lambda_handler
{
"errorMessage": "libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg_ext.so",
"errorType": "Init<LoadError>",
"stackTrace": [
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/vendor/bundle/ruby/2.7.0/gems/pg-1.2.3/lib/pg.rb:5:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/task/app.rb:3:in `<top (required)>'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'",
"/var/lang/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'"
]
}
Next thing I tried was to execute sam build --use-container and got a Gem::Ext::BuildError with the message ERROR: Failed to build gem native extension.
It seems that the external libraries that the gem needs are not being included.
My questions are:
How can I make this possible using AWS SAM? And what would be the best approach for this?
How can I solve this problem for testing the lambda locally and also leave it working in the productive environment?
I read something about using Layers for this but I don't fully understand, as it's my first time working with lambda functions.
It also seems that the sam proyect has some open issues about solving this, but it won't be in the near future.
Any help will be very much appreciated!
Thank you!
Layers in Lambda basically give you a way of installing dependencies that aren't related directly to your function but are used by it. It is a really great way to support re-use and to speed up build and deploy times. The idea here is that you would install common or shared dependencies like the postgresql libraries into the layer, then just reference them from your function.
In short, they give you a way to place things on the filesystem that the lambda can access at runtime.
However, there are a few interlinked issues in this case:
the pg gem requires packages to be installed on the OS and files to be available at build-time
the pg gem does not install the dependencies itself
This means that using layers is a little less simple than would be ideal.
For your issue, try the following:
Create a new directory called pg_layer
In that directory, create a file called Makefile (the case is important) with the following content:
LIB_DIR = $(ARTIFACTS_DIR)/lib
LIB_FILES = \
/usr/lib64/libpq.so.* \
/usr/lib64/libldap_r-2.4.so.2* \
/usr/lib64/liblber-2.4.so.* \
/usr/lib64/libsasl2.so.* \
/usr/lib64/libssl3.so \
/usr/lib64/libsmime3.so \
/usr/lib64/libnss3.so
build-PGLayer:
yum install -y amazon-linux-extras
yum install -y postgresql-devel postgresql-libs
mkdir -p $(ARTIFACTS_DIR)/vendor/bundle
mkdir -p $(LIB_DIR)
for f in $(LIB_FILES); do cp $$f $(LIB_DIR); done
cp -r . $(ARTIFACTS_DIR)
mkdir -p $(ARTIFACTS_DIR)/ruby/gems
gem install pg --install-dir $(ARTIFACTS_DIR)/ruby/gems/2.7.0
Alter your template.yaml file, and add the below to your Resources section:
PGLayer:
Type: AWS::Serverless::LayerVersion
Properties:
CompatibleRuntimes:
- ruby2.7
ContentUri: 'pg_layer'
Metadata:
BuildMethod: makefile
In the template.yaml file, alter your function definition to add the below to the Properties:
Layers:
- !Ref PGLayer
Remove pg from your function's Gemfile (it will be available automatically because of the layer and leaving it there will prevent you from building the function)
When you're ready to build, use the command sam build --use-container.
To run your lambda function locally with the layer, use sam local start-api.
When you're ready to deploy sam deploy will push up your entire application, including the layer, and configure the function to use the layer.
My gem uses a local copy of Tidy HTML Validator. It's available in lib/tidy/tidy. My tests run perfectly locally, but on Travis CI, I'm getting the error that Tidy can't be found.
Errno::ENOENT:
No such file or directory - tidy
The code looks like this:
stdin, stdout, stderr = Open3.popen3('tidy -quiet')
Is there a restriction or something that prevents executing a local executable? I also call a local copy of the Jigsaw CSS Validator which is a Java jar file and is executed like this:
`java -jar css-validator.jar --output=soap12 file:#{uri}`
This works perfectly on Travis CI. Could there be a problem with Open3?
Here's the link to the GitHub repo: https://github.com/jmuheim/headhunter
Here's the link to the failing Travis CI build: https://travis-ci.org/jmuheim/headhunter
Update
I have rewritten the code that executes the external java executable to also use Open3, and it's working. So the problem has to do with tidy.
For further debugging I have renamed tidy into tidy2 (to make sure that really the wanted executable is called), and I added a manual File.exist? 'tidy' before calling it, so this would raise an error if it couldn't be found.
Dir.chdir(VALIDATOR_DIR) do
raise "Could not find tidy in #{Dir.pwd}" unless File.exists? EXECUTABLE
# Docs for Tidy: http://tidy.sourceforge.net/docs/quickref.html
stdin, stdout, stderr = Open3.popen3("#{EXECUTABLE} -quiet")
# ...
end
The file is definitely found, but executing it still results in this error.
1) Headhunter::HtmlValidator#validate returns a local response when calling the validator succeeds
Failure/Error: subject.validate('invalid.html', read_file('html_validator/invalid.html'))
Errno::ENOENT:
No such file or directory - tidy2
# ./lib/headhunter/html_validator.rb:20:in `block in validate'
# ./lib/headhunter/html_validator.rb:16:in `chdir'
# ./lib/headhunter/html_validator.rb:16:in `validate'
# ./spec/lib/headhunter/html_validator_spec.rb:9:in `block (4 levels) in <top (required)>'
# ./spec/lib/headhunter/html_validator_spec.rb:8:in `block (3 levels) in <top (required)>'
So the only thing I can guess now is that be there is a permissions problem? Is there a way to set permissions to local executables with Travis CI?
I also tried putting tidy into bin like somebody suggested in the comments, but this didn't seem to change a thing, too.
It looks like your tidy2 executable is a Mach-O binary for OS X, but the Travis worker runs Linux. Try to include a suitable ELF binary from http://tidy.sourceforge.net/#binaries.
A couple things:
Typically the environment is different than your current environment when spawning programs so you have to check what the environment is. This is the case in cron, monit, and for some ruby method calls.
In your case, for Open, it uses Process.spawn so you're not guaranteed to be in your own directory. Open.popen3 takes a :chdir option, so set that to your Dir.pwd and see what happens.
You can also try just using absolute paths.
Sources
http://ruby-doc.org/stdlib-1.9.3/libdoc/open3/rdoc/Open3.html#method-c-popen3
https://stackoverflow.com/a/5917927/463225
http://ruby-doc.org/core-1.9.3/Process.html#method-c-spawn
I'm new to ruby ,when i want to use github build a blog,and i added a plugin
slashdotdash/jekyll-lunr-js-search for full text search, I put jekyll-lunr-js-search.rb
under ./_plugins,then I added gems:[jekyll-lunr-js-search] to my _config.yml, after this I can't build site, got this error:
ray#ubuntu:/var/www/ss$ jekyll build -t
Configuration file: /var/www/ss/_config.yml
/home/ray/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:
in require': cannot load such file -- jekyll-lunr-js-search.rb (LoadError) from /home/ray/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /home/ray/.rvm/gems/ruby-2.0.0-p247/gems/jekyll-1.3.0/lib/jekyll/site.rb:81:in block in setup'
Please help!!!
fixed..I should not add this gems:[jekyll-lunr-js-search] to_config.yml...
I have been struggling for a while with this problem. I'm trying to test a ruby CLI that uses a lot of fileutils operations like making directories and copying files, etc. But when I'm writing tests, I need some way to test the functionality without touching and changing the actual filesystem. I am trying to use the fakefs gem but I am running into a error right away
When I successfully run `dotfiles init` # aruba-0.5.3/lib/aruba/cucumber.rb:71
No such file or directory - No such file or directory - /tmp/aruba-out20130817-15800-ke8nou (Errno::ENOENT)
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:146:in `open'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:146:in `block in initialize'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tmpdir.rb:142:in `create'
/Users/Brian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/tempfile.rb:136:in `initialize'
features/dotfiles_repository.feature:8:in `When I successfully run `dotfiles init`'
So its not finding /tmp/aruba which is where cucumber aruba does all of its file operations according to the readme.
The tests run fine without fakefs, so I'm assuming its something with the setup.
Here is my features/support/env.rb file
require 'aruba/cucumber'
require 'fakefs/safe'
Before do
FakeFS.activate!
end
After do
FakeFS::FileSystem.clear
FakeFS.deactivate!
end
Does anyone have any idea what I may be doing wrong? Any help is appreciated. Even if its an idea that doesn't use fakefs, I would like to hear it. Thanks
When I try to start my Rails server, I am getting the following error:
I am using ruby 1.9.2
=> Booting WEBrick
=> Rails 3.1.8 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/agent/agent.rb:318:in `log_app_names': undefined method `join' for nil:NilClass (NoMethodError)
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/agent/agent.rb:439:in `start'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:95:in `start_agent'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:83:in `init_plugin'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `run'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `each'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/application.rb:96:in `initialize!'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/toptier/Desktop/Proyectos/CursoIngles/config/environment.rb:5:in `<top (required)>'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `block in require'
It is using the following gem: newrelic_rpm (3.4.2).
If I comment newrelic line in gemfile it works well,
Any idea?
I work at New Relic and we've tracked down the problem.
This happens when nil is explicitly set as the app name, which typically happens for local development of heroku apps that pull their app name from ENV["NEW_RELIC_APP_NAME"]. Since this environment variable is not typically set on your local dev box it comes into the agent's config as nil and crashes the local server. It doesn't effect deployed versions of the app where this variable is set.
Obviously the agent should handle this case gracefully, and we'll have a patch out in the next day or two. We just completed a major refactoring of the agent's configuration, and this edge case was missed in our internal testing.
etoleb gives a good workaround in the comment. We're very sorry for causing you this headache.
If you have any questions or concerns feel free to email me directly at sam#newrelic.com.
Thanks!
The issue seems to be related to the app_name setting being blank in your newrelic config. Personally I went through the Heroku installation (so your config may look different) but this is what I did:
Within config/newrelic.yml (copied from https://gist.github.com/2253296) I removed the line
app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
from the common config (line 35 for me) into the production config (after line 247 for me), which winds up looking like
production:
<<: *default_settings
monitor_mode: true
app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
Great to see a reply from someone who can take responsibility! Nice work, New Relic. Thanks, #samg.
Since the issue is just a nil env value, rather than downgrading the gem or diddling with config files, I just added the environment variable.
It's easy to see what the setting is on heroku:
$ heroku config
...
NEW_RELIC_APP_NAME: my_app_name
NEW_RELIC_ID: 123456
NEW_RELIC_LICENSE_KEY: 982987ae987987af98798something7e897987987c7b9d7
NEW_RELIC_LOG: stdout
...
I then opted to set a local env var via my project's .rvmrc file, where I so some other similar things:
rvm use ruby-1.9.2-p290#ConTracker --create
export PATH=bin:$PATH
export NEW_RELIC_APP_NAME=my_app_name
Then it just took a cd .. and a cd back in to my project, and it was working with the gem on version 3.4.2.
Party on!
Thanks for the comment. The answer is to downgrade to 3.4.1.