Git Product home page Git Product logo

motion-crescentia's Introduction

motion-crescentia

Gem Version

An easy way to integrate Calabash iOS into RubyMotion projects. It was conceived as an alternative to motion-calabash since I felt the need for a more recent version of calabash-ios and also since the gem on GitHub didn't receive a lot of love lately.

In addition to providing an alternative wrapper crescentia also adds some new features like easy support for the installation and removal of fixture data inside the running simulator.

Requirements

Installation

Add this line to your application's Gemfile:

    gem 'motion-crescentia'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install motion-crescentia

Usage

rake tasks

After following the installation steps there will be four new rake tasks available:

crescentia:setup

This will create the initial cucumber features directory and populate it with the files required by calabash as well as the fixture additions provided by crescentia.

crescentia:run [:target]

Execute cucumber to run the acceptance tests defined in your features directory. This task expects a target on which the tests should be run (either as rake argument or as the first parameter).

Possible values include any target supported by the iPhoneSimulator or device to execute on a connected iOS device. For a list of available simulator targets run:

    $ instruments -s devices

If no target is specified a list of possible targets will be provided to choose from.

NOTE: Any additional arguments for cucumber can be passed by setting the args environment variable.

crescentia:push [:target, :clean]

Install the application bundle in the simulator. If :clean is set to 1 (or passed via clean=1 ) the application will be removed and then reinstalled. For details on :target see crescentia:run.

NOTE: :run does an implicit :push if the target is a simulator.

crescentia:repl [:target]

Start the interactive calabash irb console. This task too requires a target specification, see crescentia:run for details on that.

providing fixture data

Crescentia provides support for copying fixture data at runtime. To enable this feature following line needs to be added to your ApplicationDelegate:

    include Crescentia::Fixtures

This will provide the required fixture callbacks in development builds and resolve to an empty stub-module in release builds.

Call from inside your Cucumber features / Spec files

To easily add and remove fixture data in your acceptance tests crescentia provides two functions which can be called from cucumber features or spec files:

# Copy the file or directory at `local_path` to `target_path` inside the 
# Simulator (does not work on empty directories for now).
# @param [String] local_path  The path to the source file.
# @param [String] target_path The destination path on the Simulator (may contain directory parts).
# @param [Symbol] target_root The root path for the file (see {NSSearchPathDirectory}).
def fixture_install( local_path, target_path, target_root )
  #...
end

# Remove the file or directory at `path` from the Simulator.
# @param [String] path The path to the file or directory on the Simulator.
# @param [Symbol] root The root path for the file (see {NSSearchPathDirectory})
def fixture_remove( path, root )
    #...
end

For Cucumber tests these functions make use of the backdoor()-API provided by Calabash. For Spec runs (only supported in the simulator) a direct call without backdoor() is performed.

sample step definition (Cucumber)
Given /^I have some data available$/ do
  # Copy recursively the folder 'fixture-data' to the simulator under the name 'files'
  fixture_install( "#{Dir.pwd}/fixture-data", 'files', :NSDocumentDirectory )
end

Given /^There is some deeply nested picture file/ do
  # Copy 'sample.png' to 'Pictures/Stuff/sample.png' inside the :NSDocumentDirectory.
  fixture_install( "#{Dir.pwd}/sample.png", 'Pictures/Stuff/sample.png', :NSDocumentDirectory )
end

Given /^I work an a clean slate$/ do
  # Remove the 'files' directory and all it's contents.
  fixture_remove( 'files', :NSDocumentDirectory )
end
sample step definition (RSpec)
describe 'My sample view controller' do
  context 'when there is data available' do
    before do
      # Copy recursively the folder 'spec/data/fixture-data' to the simulator under the name 'files'
      fixture_install( fixture_host_path( 'spec', 'data', 'fixture-data' ), 'files', :NSDocumentDirectory )
    end

    after do
      # Remove the 'files' directory and all it's contents.
      fixture_remove( 'files', :NSDocumentDirectory )
    end
  end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

motion-crescentia's People

Contributors

healscodes avatar

Stargazers

Andrew Havens avatar  avatar David Larrabee avatar

Watchers

 avatar David Larrabee avatar James Cloos avatar

Forkers

squidpunch

motion-crescentia's Issues

Hangs on fetching UUID

Thanks for the work on this as I've been struggling with other outdated gems for frank & calabash.

However, I'm getting rake crescentia:run 'iPhone 6s (9.0) [22451E75-34E0-46B4-A5DC-2B92FF8658A3]', hanging with:

Run Fetching the UUID for 'iPhone 6s (9.0) [22451E75-34E0-46B4-A5DC-2B92FF8658A3]'

I'm going to download and test on an 8.4 Simulator but there seems to be an issue here.

Problems starting the application

Hey @Shirk I have come back to try and use motion-crescentia again and I am having problems getting it going. Wondering if you have seen similar issues.

  • create a new app with motion create
  • add gem
  • bundle
  • run setup
  • run the tests

I think this worked the first time through, but not any time after. I have rebooted and dont seem to get any better results. The app fails to ever initiate on the simulator, and there is no crash log. Running in debug gives a bunch of details but nothing specifically explaining what might be going on here

I am on the latest RubyMotion, Latest Xcode, and latest Yosemite.

here is what I see in debug logs

DEBUG=1 rake crescentia:run "iPhone 6 (8.3 Simulator)"
  WARNING! Found 3 iOS/iPhone Developer certificates in the keychain. Set the `codesign_certificate' project setting to explicitely use one of (defaults to the first): iPhone Developer: David Larrabee (FB2V23J4T8), iPhone Developer: David Larrabee (WY2GF49GM5), iPhone Developer: David Larrabee (74X9P5BM3M)
  WARNING! Found 3 provisioning profiles named `(?-mix:iOS\s?Team Provisioning Profile)'. Set the `provisioning_profile' project setting. Will use the first one: `/Users/davidlarrabee/Library/MobileDevice/Provisioning Profiles/42d8bfb6-6db6-400e-b005-e811d90066dc.mobileprovision'
        -- DEVICE_TARGET -> iPhone 6 (8.3 Simulator)
        -- BUNDLE_ID -> com.yourcompany.narf
     ***** build/iPhoneSimulator-8.3-Development/narf.app
*****---** DEVICE_TARGET -> iPhone 6 (8.3 Simulator)
*****---** BUNDLE_ID -> com.yourcompany.narf
*****---** APP_BUNDLE_PATH -> /Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app
       Run Fetching the UUID for 'iPhone 6 (8.3 Simulator)'
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl shutdown D8D5B3C1-70D8-4DD0-A8A1-1298AE1F15C4 &>/dev/null || true
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl boot     D8D5B3C1-70D8-4DD0-A8A1-1298AE1F15C4 &>/dev/null || true
       Run Uninstalling com.yourcompany.narf..
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl uninstall D8D5B3C1-70D8-4DD0-A8A1-1298AE1F15C4 com.yourcompany.narf &>/dev/null || true
       Run Installing com.yourcompany.narf on iPhone 6 (8.3 Simulator)..
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl install D8D5B3C1-70D8-4DD0-A8A1-1298AE1F15C4 /Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl shutdown D8D5B3C1-70D8-4DD0-A8A1-1298AE1F15C4 &>/dev/null || true
       Run calabash-env: {"DEVICE_TARGET"=>"iPhone 6 (8.3 Simulator)", "BUNDLE_ID"=>"com.yourcompany.narf", "APP_BUNDLE_PATH"=>"/Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app"}
       Run cucumber []
Feature: Running a test
  As an iOS developer
  I want to have a sample feature file
  So I can begin testing quickly

  Scenario: Example steps                            # features/my_first.feature:6

INFO: Using uia strategy: 'preferences'
2015-05-09 19:20:34 -0400 [RunLoop:debug]: Simulator instruction set 'x86_64' is compatible with ["i386", "x86_64"]
2015-05-09 19:20:34 -0400 [RunLoop:debug]:
{
                        :app => "/Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app",
                       :args => [],
    :bundle_dir_or_bundle_id => "/Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app",
                  :bundle_id => "com.yourcompany.narf",
                     :device => "iphone",
              :device_target => "iPhone 6 (8.3 Simulator)",
              :launch_method => :instruments,
             :launch_retries => 5,
                   :log_file => "/var/folders/h6/l7xw2mn56zv29xpxqz8bzzz40000gp/T/run_loop20150509-5372-rp2m90/run_loop.out",
                  :no_launch => false,
                    :no_stop => false,
                      :reset => false,
                :results_dir => "/var/folders/h6/l7xw2mn56zv29xpxqz8bzzz40000gp/T/run_loop20150509-5372-rp2m90",
          :results_dir_trace => "/var/folders/h6/l7xw2mn56zv29xpxqz8bzzz40000gp/T/run_loop20150509-5372-rp2m90/trace",
                     :script => "/var/folders/h6/l7xw2mn56zv29xpxqz8bzzz40000gp/T/run_loop20150509-5372-rp2m90/_run_loop.js",
                :sdk_version => nil,
                       :udid => "iPhone 6 (8.3 Simulator)",
               :uia_strategy => :preferences,
                      :xcode => "6.3.1",
                 :xcode_path => "/Applications/Xcode.app/Contents/Developer"
}

### Starting on iPhone 6 (8.3 Simulator) App: /Users/davidlarrabee/code/narf/build/iPhoneSimulator-8.3-Development/narf.app ###

hoping you have some ideas, because I would like to try and switch over to this, or at least get more familiar with it. Again this is not an existing app, its a fresh app without any changes after the motion create and the steps to get the gem in place and running.

Thank you in advance for any feedback you can give to try and troubleshoot a bit more

Xcode 7

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/simctl: No such file or directory

Looks like not compatible with Xcode 7

iOS 7.1 simulator

I just created a new rubymotion project (version 3.2) and then followed the steps to use this gem.

I am noticing that when running an 8.1 simulator everything works fine, but when trying to run a 7.1 simulator it seems to just hang unexpectedly. Can you reproduce? Perhaps I am doing something wrong?

rake crescentia:run 'iPhone 5s (8.1 Simulator)'
  WARNING! Found 2 iOS/iPhone Developer certificates in the keychain. Set the `codesign_certificate' project setting to explicitely use one of (defaults to the first): iPhone Developer: David Larrabee (FB2V23J4T8), iPhone Developer: David Larrabee (WY2GF49GM5)
       Run Fetching the UUID for 'iPhone 5s (8.1 Simulator)'
       Run Uninstalling com.yourcompany.use-crescentia..
       Run Installing com.yourcompany.use-crescentia on iPhone 5s (8.1 Simulator)..
       Run calabash-env: {"DEVICE_TARGET"=>"iPhone 5s (8.1 Simulator)", "BUNDLE_ID"=>"com.yourcompany.use-crescentia", "APP_BUNDLE_PATH"=>"build/iPhoneSimulator-8.1-Development/use-crescentia.app"}
       Run cucumber []
Feature: Running a test
  As an iOS developer
  I want to have a sample feature file
  So I can begin testing quickly

  Scenario: Example steps                            # features/my_first.feature:6
    Given I am on the Welcome Screen                 # features/step_definitions/my_first_steps.rb:1
    Then I swipe left                                # calabash-cucumber-0.11.4/features/step_definitions/calabash_steps.rb:234
    And I wait until I don't see "Please swipe left" # calabash-cucumber-0.11.4/features/step_definitions/calabash_steps.rb:165
    And take picture                                 # calabash-cucumber-0.11.4/features/step_definitions/calabash_steps.rb:229

1 scenario (1 passed)
4 steps (4 passed)
0m13.123s

But when trying to run a 7.1 it just simply sticks at the Scenario:

rake crescentia:run 'iPhone 5s (7.1 Simulator)'
  WARNING! Found 2 iOS/iPhone Developer certificates in the keychain. Set the `codesign_certificate' project setting to explicitely use one of (defaults to the first): iPhone Developer: David Larrabee (FB2V23J4T8), iPhone Developer: David Larrabee (WY2GF49GM5)
       Run Fetching the UUID for 'iPhone 5s (7.1 Simulator)'
       Run Uninstalling com.yourcompany.use-crescentia..
       Run Installing com.yourcompany.use-crescentia on iPhone 5s (7.1 Simulator)..
       Run calabash-env: {"DEVICE_TARGET"=>"iPhone 5s (7.1 Simulator)", "BUNDLE_ID"=>"com.yourcompany.use-crescentia", "APP_BUNDLE_PATH"=>"build/iPhoneSimulator-8.1-Development/use-crescentia.app"}
       Run cucumber []
Feature: Running a test
  As an iOS developer
  I want to have a sample feature file
  So I can begin testing quickly

  Scenario: Example steps                            # features/my_first.feature:6
^C
Exiting... Interrupt again to exit immediately.

Looking into switching over from frank, but figured it best to get an understanding with a fresh project to get a feel for the product.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.