Calabash-Android Run/Resign Gives Error - calabash

I am trying to set up Calabash-android to run with a test app but keep getting the following error. I am not sure if its a problem with the way I set it up or not. Any advice would be greatly appreciated.
/usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/dependencies.rb:220:in basename': no implicit conversion of nil into String (TypeError)
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/dependencies.rb:220:inplatform_directory'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/dependencies.rb:247:in locate_android_dependencies'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/dependencies.rb:125:insetup'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/operations.rb:30:in <top (required)>'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire'
from /usr/local/Cellar/ruby/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/lib/calabash-android/helpers.rb:104:inbuild_test_server_if_needed'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/bin/calabash-android-run.rb:16:in calabash_run'
from /usr/local/lib/ruby/gems/2.3.0/gems/calabash-android-0.7.3/bin/calabash-android:84:in'
from /usr/local/bin/calabash-android:23:in load'
from /usr/local/bin/calabash-android:23:in'

You need to have the ANDROID_HOME environment variable setup. If you have done this already then there may be an issue with how you have it configured.
The bit of the calabash code that this error has come uses the sdk directory - https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/dependencies.rb#L214

Related

Error while running Calabash-android with a test app

I am trying to set up Calabash-android to run with a test app but keep getting the following error.
I have generated keystore file in .android folder, but still getting the same error.
D:\Calabash>calabash-android resign EdgeConnectQA.apk
C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.14/lib/calabash-android/helpers.rb:118:in ``': No such file or directory - "C:/Program Files (x86)/android-sdk_r10-windows/android-sdk-windows/platform-tools/aapt" list "C:/Users/u46646/AppData/Local/Temp/d20161027-10688-1rl21xu/unsigned.apk" (Errno::ENOENT)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.14/lib/calabash-android/helpers.rb:118:in `unsign_apk'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.14/lib/calabash-android/helpers.rb:111:in `block in resign_apk'
from C:/Ruby193/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.14/lib/calabash-android/helpers.rb:106:in `resign_apk'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/calabash-android-0.5.14/bin/calabash-android:114:in `<top (required)>'
from C:/Ruby193/bin/calabash-android:23:in `load'
from C:/Ruby193/bin/calabash-android:23:in `<main>'
D:\Calabash>
Upgrade your Calabash-Android version. 0.5.14 is very old.

Cannot generate controller ,model or start rails server

I recently started getting problems in generating controllers,models and starting rails server in new projects. I am able to do all these things in old projects.
What can be done to resolve this error?
OS: Ubuntu 15.04 ,Ruby:2.1 ,Rails: 4.2.0
Error Output:
aditya#Aditya-PC:~/testRails/blog$ rails g controller pages
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
/var/lib/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x00000002ec6c40> (NoMethodError)
from /home/aditya/testRails/blog/config/application.rb:24:in `<class:Application>'
from /home/aditya/testRails/blog/config/application.rb:10:in `<module:Blog>'
from /home/aditya/testRails/blog/config/application.rb:9:in `<top (required)>'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `require'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `preload'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
EDIT: I removed rails completely and again installed. But no effect, still having this error.
Have you tried to run bundle install in the application?
According to the error seems like you created a new rails app without activerecord
'method_missing': undefined method 'active_record' for #Rails::Application::Configuration
the stack trace is hinting at /home/aditya/testRails/blog/config/application.rb:24
If removing activerecord is intentional follow along to remove anything that is related to activerecord, if not continue reading as you might figure out what went missing ;)
remove any activerecord config from application.rb or environments/*
check your config/application.rb if
require 'rails/all is present, remove it and add the railties that you need like:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_job/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
# require "railtie/active_record"
remove any adapter from the Gemfile (mysql2, pg, sqlite3)
remove config/database.yml
Hope it helps :)

RSpec 3, capybara 2.3.0, Guard 2.6.1, Rails 4.1.1 uninitialized constant (NameError)

I've recently had to migrate a project from rails 4.0 to rails 4.1 and in the process I've also updated RSpec to RSpec (3.0.0).
The project previously had the following in certain feature specs being tested with Capybara:
require 'spec_helper' require 'support/integration_helpers.rb'
require 'support/admin_support/admin_user_creation_helpers.rb'
include BuildDefaults
The include BuildDefaults refers to a module spec/support/build_defaults.rb and has various helper methods to ensure that the database has been populated correctly. For some reason this has now stopped working and gives the following error (and stack trace):
path_to/spec/features/admin_features/admin_login_out_spec.rb:4:in
<top (required)>': uninitialized constant BuildDefaults (NameError)
from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
block in load_spec_files' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
each' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in
load_spec_files' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in setup' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:inrun' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in run' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:ininvoke' from
/Users/u_name/.rvm/gems/ruby-2.1.2#gemset_name/gems/rspec-core-3.0.2/exe/rspec:4:in
<top (required)>' from
/Users/u_name/Documents/rails/work/c_central_4.1.1/gemset_name/bin/rspec:7:in
' from
/Users/u_name/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from
/Users/u_name/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from -e:1:in `'
Would anybody happen to know why this has happened?
I would greatly appreciate any help on the matter.
I have looked at various other SO questions with a similar title as this one but none of them seem to be relevant.
Side note 1
It is worth noting that I have removed Spork from my test environment as it was not playing nicely for some reasons but have instead configured the project to use Spring. Though I don't think that this has anything to do with the issue, I did have to completely rebuild the test environment (running rails g rspec:install for instance) and then used Transpec to update the Rspec syntax.
Having spent some time looking around for a solution to this I eventually came across the official upgrade documentation (I know, I know).
As it says in the docs,
Default helper files created in RSpec 3.x have changed
In prior versions, only a single spec_helper.rb file was generated. This file
has been moved to rails_helper.rb. The new spec_helper.rb is the same
standard helper generated by running rspec --init.
This change was made to accomplish two general goals:
Keep the installation process in sync with regular RSpec changes
Provide an out-of-the-box way to avoid loading Rails for those specs
that do not require it
This second point got me thinking about the fact that a feature spec for capybara would need to load the application stack. As such, by loading the rails_helper.rb instead of the spec_helper.rb the spec/support/build_defaults.rb is now included in the load path.
Hope this helps somebody in the future.

I'm trying to run puppet-rspec, but get a not very specific error

I'm trying to get rspec to work on my Puppet module, but I get this error:
1) apache when called with no parameters on redhat
Failure/Error: })
Puppet::Error:
Could not parse for environment production: No file(s) found for import of '' at line 4 on node testhost.example.com
# ./spec/classes/apache_spec.rb:10:in `block (3 levels) in <top (required)>'
I have run puppet-rspec-init and put a simple spec in spec/classes/apache_spec.rb
This is the part that I'm most curious about; what is it trying to load?
No file(s) found for import of '' at line 4
I do have a .fixtures.yml in place (modules/apache/.fixtures.yml):
fixtures:
symlinks:
"apache": "#{source_dir}"
Could someone nudge me in the right direction? I've probably missed something obvious... :S
Thanks,
Ger.
I've seen a similarly phrased error when I didn't have a site.pp file in fixtures, though I haven't been able to duplicate that problem. If you haven't already, get your first spec running with just
it { should compile.with_all_deps }
...before you write any additional tests. Just getting the tools set up to work right (and keeping up with changes) is a lot harder than writing the tests; the tests are the easy part.
The .fixtures file should create the symlink for you when you run the appropriate rake task, but if it doesn't, make sure your module is symlinked in fixtures, as well as any dependent modules symlinked as well.
I like puppetlabs_spec_helper alongside rspec-puppet, though you end up with rake spec and rake rspec both available, one or the other of which may not work quite right.
Some code changes in PE 3.2 requires that I do this before a 'rake spec'
export MODULEPATH=/etc/puppetlabs/puppet/modules
Thanks to Ben from PuppetLabs.

Given a typical Rails 3 environment, why am I unable to execute any tests?

I'm working on writing simple unit tests for a Rails 3 project, but I'm unable to actually execute any tests.
Case in point, attempting to run the test auto-generated by Rails fails:
require 'test_helper'
class UserTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
Results in the following error:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load --
test_helper (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from user_test.rb:1:in `<main>'
Commenting out the require 'test_helper' line and attempting to run the test results in this error:
user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)
The action pack gems appear to be properly installed and up to date:
actionmailer (3.0.3, 2.3.5)
actionpack (3.0.3, 2.3.5)
activemodel (3.0.3)
activerecord (3.0.3, 2.3.5)
activeresource (3.0.3, 2.3.5)
activesupport (3.0.3, 2.3.5)
Ruby is at 1.9.2p0 and Rails is at 3.0.3.
The sample dump of my test directory is as follows:
/fixtures
/functional
/integration
/performance
/unit
-- /helpers
-- user_helper_test.rb
-- user_test.rb
test_helper.rb
I've never seen this problem before - I've run the typical rake tasks for preparing the test environment. I have nothing out of the ordinary in my application or environment configuration files, nor have I installed any unusual gems that would interfere with the test environment.
Edit March 9th
Xavier Holt's suggestion, explicitly specifying the path to the test_helper worked; however, this revealed an issue with ActiveSupport.
Now when I attempt to run the test, I receive the following error message (as also listed above):
user_test.rb:3:in `<main>': uninitialized constant Object::ActiveSupport (NameError)
But as you can see above, Action Pack is all installed and update to date.
Edit March 13th
When attempting to run tests using rake test:units the following stack trace is dumped to the console:
test/unit/bookmark_test.rb:3:in `<top (required)>': uninitialized constant Objec
t::ActiveSupport (NameError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `block in <main>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `<main>'
rake aborted!
So looking into the file listed above, I see the following:
#!/usr/bin/env ruby
# Load the test files from the command line.
ARGV.each { |f| load f unless f =~ /^-/ }
To my knowledge, everything looks as expected.
Your test/test_helper file should have been created when you generated the application. It contains this valuable content:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
The second line here is the most important: it requires the config/environment.rb file at the root of your application, which in turn requires a lot of other things, including the valuable (I like that word today, ok?) ActiveSupport constant.
When you generate a controller, model or scaffold it'll also generate tests for those. I just ran rails g scaffold ticket in my app and it generated test/unit/ticket_test.rb which contains this:
require 'test_helper'
class TicketTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
The first line of this file will require the test/test_helper.rb file that we jut saw. This will load ActiveSupport and the TestCase class within it, thereby making this test feasible. Everything else just flows on from there.
With all that explanation out of the way (even though it's something that you already know), I'm placing a large wager on it's something that's masscaring your LOAD_PATH, causing the test directory to be removed from it.
What's really unusual is that when you do specify the full path to the test/test_helper.rb you're saying it loads it, but ActiveSupport is still undefined. Well, that should be loaded as-per the description above. Is it actually loading config/environment.rb? Can you put something such as:
puts "LOADING CONFIG/ENVIRONMENT.RB"
At the top of your config/environment.rb file and then run the tests again? It should be output. Very unusual.
Continuing on the thread about LOAD_PATH... Got a dirty little secret you're not telling us about?
Actually, Dan Cheail makes a good point. You could be running the tests using ruby test/unit/ticket_test.rb in which case test_helper wouldn't be available, but still that still doesn't explain why when you specify the full path you're still getting an undefined constant ActiveSupport.
If you want to run a single test you should be doing this:
ruby -Itest test/unit/ticket_test.rb
That -I option there adds the test directory to the load path, meaning the test_helper file will be available through a straight require 'test_helper'. If it still errors after this, I reckon your test/test_helper.rb is either empty or broken.
The problem you're having is the way you're executing tests. Simply calling ruby test/unit/user_test.rb doesn't set up the load path, which explains the problems you've been having.
rake test:units is what you want and should work straight away.
Sorry about the post here, but I am unable to comment on questions yet.
what environment are you running, Win (has an issue with a .gemspec file) Linux, Mac?
Are you using RVM?
Test-Unit is installed by default with Rails, if you installed the gem Test-Unit you will get a conflict between the 2. try uninstalling the gem and your tests should start working.
If running on windows I would gem uninstall "autotest", then navigate to the following dir
drive:\Ruby192\lib\ruby\gems\1.9.1\specifications
In here you will find .gemspec files. Ensure that you dont have 2 autotest.gemspec files or any, for that matter. if so remove(delete) them, then download and gem install the autotest gem again. Grab the latest by using version switch.
You should be able to run your autotests. I did come across this once before, so to fix I simply removed the view and helper test files and wrote everything in the standard test file. Other than that I know running on windows autotest had issues, because of the ruby installer and bundler not clearing out things correctly and forgetting files.
I will find the link for you, to better explain.