0

My calabash android test project has the following structure:

-- myApp.apk
-- features (directory)
          |-- my-feature-1-file-name.feature
          |-- step_definitions (directory)
          |      calabash_steps.rb
          |-- support (directory)
          |      thirdPartyLib.rb

My calabash test steps need to use a third party library thirdPartyLib.rb. As you see above, under features/ directory, I have a support/ directory, there, I have a thirdPartyLib.rb ruby file.

Inside thirdPartyLib.rb , the 1st line of code is this:

require 'jmespath'
...

When I go to my project root, and run the test by command calabash-android run myApp.apk DEBUG=1 , I get the following error:

DEBUG: Setting Android SDK location to $ANDROID_HOME
DEBUG: Android SDK location set to '/Users/John/Library/Android/sdk'
DEBUG: Set aapt path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/aapt'
DEBUG: Set zipalign path to '/Users/John/Library/Android/sdk/build-tools/23.0.3/zipalign'
DEBUG: Set adb path to '/Users/John/Library/Android/sdk/platform-tools/adb'
DEBUG: Set android jar path to '/Users/John/Library/Android/sdk/platforms/android-24/android.jar'
DEBUG: Setting Java SDK location to $JAVA_HOME
DEBUG: Java SDK location set to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home'
DEBUG: Found java on PATH
DEBUG: Set java path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/java'
DEBUG: Found keytool on PATH
DEBUG: Set keytool path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/keytool'
DEBUG: Found jarsigner on PATH
DEBUG: Set jarsigner path to '/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jarsigner'
cannot load such file -- jmespath (LoadError)

/Users/John/.calabash/sandbox/Rubies/2.1.6-p336/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/John/.calabash/sandbox/Rubies/2.1.6-p336/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/John/my-calabash-test/features/support/thirdPartyLib.rb:1:in `<top (required)>'
...

So, it is a loading error, it looks like calabash-android cannot load file jmespath (LoadError)that is declared in thirdPartLib.rb . How can I get rid of this error?

Leem.fin
  • 40,781
  • 83
  • 202
  • 354

1 Answers1

0

You need to install the jmespath gem to use it. To install it you need to add it to your gemfile. You can specify a local copy of a gem as follows

gem "foo", :path => "/path/to/foo"

Example taken from this question / answer - How can I specify a local gem in my Gemfile?

Community
  • 1
  • 1
alannichols
  • 1,496
  • 1
  • 10
  • 20
  • But calabahs-android cannot load/install the gems. My problem is how to make calabash-android be able to load the gems so that my test code which invoke the 3rd party gem functions can run. – Leem.fin Sep 05 '16 at 11:11
  • If you do a bundle install before it runs, it should be able to load them. Is that not working? – alannichols Sep 05 '16 at 11:27
  • No, that is not working, I can run my standalone ruby script which has `require aws-sdk`, but if I start running calabash test which loads my standalone ruby file, it complains undefined module `aws-sdk`. – Leem.fin Sep 05 '16 at 11:31
  • Just to check you have run `bundle install` then `bundle exec calabash-android run myApp.apk DEBUG=1` – alannichols Sep 05 '16 at 11:33
  • How did you get on? – alannichols Sep 06 '16 at 12:37