cuesmash 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61ac71212da28dd89ced337ad1a6700018b6426a
4
+ data.tar.gz: f7a6eb00adbda3872dd692de2b7a964bcbbe142d
5
+ SHA512:
6
+ metadata.gz: d85247a3c87e31b31b3440c7d6d85a1287b89ddfb9935a36e7027d164137d2780df716f3412b1e7a376af448bdb407df6314437152c9e9eceaf6a75ed5ec0d67
7
+ data.tar.gz: bd365bf32a45215624256701874e67a9b0b7540b77be6fa620272443c4539df8ddbf74c3853343115943c79300f8c054a82c8fdfb759c75bdcae24b32f2d76e4
data/.cuesmash.yml ADDED
@@ -0,0 +1,12 @@
1
+ devices:
2
+ iPhone 5s:
3
+ [7.1, 8.0]
4
+
5
+ iPhone 5:
6
+ [7.1, 8.0]
7
+
8
+ iPhone 6:
9
+ [8.0]
10
+
11
+ iPhone 6 Plus:
12
+ [8.0]
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ .DS_Store
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ script: bundle exec rspec spec
5
+ notifications:
6
+ email:
7
+ - jarod@ustwo.com
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cuesmash.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cuesmash (0.0.1)
5
+ CFPropertyList
6
+ thor
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ CFPropertyList (2.2.8)
12
+ coderay (1.0.9)
13
+ diff-lcs (1.2.5)
14
+ ffi (1.9.0)
15
+ formatador (0.2.4)
16
+ guard (1.8.0)
17
+ formatador (>= 0.2.4)
18
+ listen (>= 1.0.0)
19
+ lumberjack (>= 1.0.2)
20
+ pry (>= 0.9.10)
21
+ thor (>= 0.14.6)
22
+ guard-rspec (3.0.0)
23
+ guard (>= 1.8)
24
+ rspec (~> 2.13)
25
+ listen (1.1.6)
26
+ rb-fsevent (>= 0.9.3)
27
+ rb-inotify (>= 0.9)
28
+ rb-kqueue (>= 0.2)
29
+ lumberjack (1.0.3)
30
+ method_source (0.8.1)
31
+ pry (0.9.12.2)
32
+ coderay (~> 1.0.5)
33
+ method_source (~> 0.8)
34
+ slop (~> 3.4)
35
+ rake (10.1.0)
36
+ rb-fsevent (0.9.3)
37
+ rb-inotify (0.9.0)
38
+ ffi (>= 0.5.0)
39
+ rb-kqueue (0.2.0)
40
+ ffi (>= 0.5.0)
41
+ rspec (2.14.1)
42
+ rspec-core (~> 2.14.0)
43
+ rspec-expectations (~> 2.14.0)
44
+ rspec-mocks (~> 2.14.0)
45
+ rspec-core (2.14.7)
46
+ rspec-expectations (2.14.4)
47
+ diff-lcs (>= 1.1.3, < 2.0)
48
+ rspec-mocks (2.14.4)
49
+ slop (3.4.4)
50
+ thor (0.18.1)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ bundler (~> 1.3)
57
+ cuesmash!
58
+ guard-rspec
59
+ pry
60
+ rake
61
+ rspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, :cli => '--color --format doc' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alex Fish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex Fish
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ cuesmash
2
+ ========
3
+
4
+ <!-- [![Gem Version](https://badge.fury.io/rb/cuesmash.png)](http://badge.fury.io/rb/cuesmash)
5
+ [![Build Status](https://travis-ci.org/ustwo/cuesmash.png?branch=master)](https://travis-ci.org/ustwo/cuesmash) -->
6
+
7
+ Cuesmash provides an interface to run a suite of appium-cucumber tests against an iOS application using a mocked backend. This is a fork of [calasmash](https://github.com/ustwo/cuesmash) that supports appium instead of calabash.
8
+
9
+ ## Installation
10
+
11
+ From the git repo:
12
+
13
+ rake install
14
+
15
+ Once we get to a first release of them gem there will be a gem install
16
+
17
+ <!-- Add this line to your application's Gemfile:
18
+
19
+ gem 'cuesmash'
20
+
21
+ And then execute:
22
+
23
+ $ bundle install -->
24
+
25
+ ## Usage
26
+
27
+ ###Commands
28
+
29
+ cuesmash help [COMMAND] # Describe available commands or one specific command
30
+ cuesmash init # set up the project
31
+ cuesmash test OPTIONS # Usage: cuesmash test [OPTIONS]
32
+
33
+ ### Test Options
34
+
35
+ --tags -t the tags to pass to Cucumber, for multiple tags pass one -t option per tag
36
+ --scheme -s the Xcode scheme to build
37
+ --ios -i the iOS version to build with
38
+ --output -o The output directory for the test report
39
+ --format -f The format of the test report
40
+ --debug -d output debug information
41
+
42
+ ## Configuration
43
+
44
+ Cover what the appium.txt file does.
45
+ [http://appium.io/slate/en/tutorial/ios.html?ruby#starting-the-console](http://appium.io/slate/en/tutorial/ios.html?ruby#starting-the-console)
46
+
47
+ Cover how to configure the travis.yml file
48
+ [http://docs.travis-ci.com/user/languages/objective-c/](http://docs.travis-ci.com/user/languages/objective-c/)
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
57
+
58
+ ## TODO:
59
+
60
+ 1. reporting - at the end of a run provide reports of the results.
61
+ 2. passing build options to xcodebuild (sandbox, mocked, live).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/cuesmash ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'cuesmash/start'
5
+
6
+ Cuesmash::Start.start
data/cuesmash.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "cuesmash"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Alex Fish", "Jarod McBride"]
9
+ spec.email = ["fish@ustwo.co.uk", "jarod@ustwo.com"]
10
+ spec.description = "A gift for Juan"
11
+ spec.summary = "Compile an app, point the app at sinatra, run cucumber with appium"
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = '>= 2.0.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "guard-rspec"
26
+ spec.add_development_dependency "pry"
27
+
28
+ spec.add_runtime_dependency "CFPropertyList"
29
+ spec.add_runtime_dependency "thor"
30
+
31
+ spec.executables << "cuesmash"
32
+ end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ module Cuesmash
5
+
6
+ #
7
+ # Provides an interface for starting the appium server
8
+ #
9
+ # @author [jarod]
10
+ #
11
+ class AppiumServer
12
+
13
+ # Public: the output directory for the tests
14
+ attr_accessor :output
15
+
16
+ # Public: the output format for the tests
17
+ attr_accessor :format
18
+
19
+ #
20
+ # Create a new instance of AppiumServer
21
+ #
22
+ def initialize()
23
+ end
24
+
25
+ #
26
+ # Run the appium server
27
+ #
28
+ def start_server
29
+ started
30
+
31
+ command = "appium --log-level debug"
32
+
33
+ @stdin, @stdout, @stderr, @wait_thr = Open3.popen3(command)
34
+ Logger.info "Appium running with pid: #{@wait_thr.pid}"
35
+
36
+ if Logger.debug?
37
+ [@stdout, @stderr].each do |stream|
38
+ Thread.new do
39
+ until (line = stream.gets).nil? do
40
+ Logger.debug line
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ #
48
+ # Stop the appium server
49
+ #
50
+ def stop_server
51
+ Process.kill('INT', @wait_thr.pid)
52
+ @stdin.close
53
+ @stdout.close
54
+ @stderr.close
55
+
56
+ completed
57
+ end
58
+
59
+ private
60
+
61
+ #
62
+ # Output a nice message for starting
63
+ #
64
+ def started
65
+ Logger.info "Starting Appium Server"
66
+ end
67
+
68
+ #
69
+ # Output a nice message for completing
70
+ #
71
+ def completed
72
+ Logger.info "Stopping Appium server 👌"
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ module Cuesmash
5
+
6
+ #
7
+ # Creates the appium.txt file that is needed by appium
8
+ #
9
+ # @author [jarod]
10
+ #
11
+ class AppiumText
12
+
13
+ attr_accessor :platform_version
14
+ attr_accessor :app
15
+ attr_accessor :platform_name
16
+ attr_accessor :device_name
17
+
18
+ #
19
+ # Create a new appium_text instance. These params are based off the appium.txt
20
+ # [caps] format.
21
+ #
22
+ # @param platform_name [String] The platform_name platformName = "iOS"
23
+ # @param device_name [String] deviceName = "iPhone Simulator"
24
+ # @param platform_version [String] platformVersion = "7.1"
25
+ # @param app [String] path to built .app file
26
+ #
27
+ # @return [AppiumText] A appiumtext instance
28
+ def initialize(platform_name:, device_name:, platform_version:, app:)
29
+ @platform_name = platform_name
30
+ @device_name = device_name
31
+ @platform_version = platform_version
32
+ @app = app
33
+ end
34
+
35
+ def execute
36
+ started
37
+ update
38
+ completed
39
+ end
40
+
41
+
42
+ private
43
+
44
+ def started
45
+ Logger.info "Updating appium.txt"
46
+ end
47
+
48
+ def update
49
+ text = file_text
50
+ IO.write("features/support/appium.txt", text)
51
+ end
52
+
53
+ def completed
54
+ Logger.info "appium.txt updated 👌"
55
+ end
56
+
57
+ # [caps]
58
+ # platformName = "iOS"
59
+ # deviceName = "iPhone Simulator"
60
+ # platformVersion = "7.1"
61
+ # app = "/Users/jarod/Library/Developer/Xcode/DerivedData/laterooms-fnlioqzgtpowdmezkwdzsyicgjiz/Build/Products/Debug-iphonesimulator/laterooms.app"
62
+ def file_text
63
+ text = "[caps]\n"
64
+ text << "platformName = \"#{platform_name}\"\n"
65
+ text << "deviceName = \"#{device_name}\"\n"
66
+ text << "platformVersion = \"#{platform_version}\"\n"
67
+ text << "app = \"#{app}\"\n"
68
+ Logger.debug "appium.text == #{text}"
69
+ text
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ module Cuesmash
5
+
6
+ #
7
+ # The main point of entry for all commands, Command parses command line arguments
8
+ # and decides what to do about them.
9
+ #
10
+ # @author [alexfish]
11
+ #
12
+ class Command
13
+
14
+ class << self
15
+
16
+ #
17
+ # Execute a command with some arguments
18
+ # then figure out what we're supposed to be doing with
19
+ # the arguments
20
+ #
21
+ # @param *args [Array] An Array of arguments to play with
22
+ #
23
+ # @return [type] [description]
24
+ def execute(device:, os:, server:, tags:, scheme:, debug: false, format: nil, output: nil)
25
+
26
+ if debug
27
+ Logger.level = ::Logger::DEBUG
28
+ Logger.formatter = proc do |serverity, time, progname, msg|
29
+ "\n#{time}\t#{serverity}\t#{msg.rstrip}"
30
+ end
31
+ end
32
+
33
+ # Create new IosApp object
34
+ app = IosApp.new(file_name: scheme)
35
+ app_server = AppiumServer.new
36
+
37
+ # Compile the project
38
+ compile(scheme, app.tmp_dir) do
39
+ # Update the plist
40
+ # update_plist(scheme, app.app_path)
41
+ # Update the appium.txt file
42
+ create_appium_txt(app: app.app_path, device_name: device, platform_version: os)
43
+ # start the appium server
44
+ app_server.start_server
45
+ # Run the tests
46
+ run_tests(os, tags, format, output)
47
+ # Stop the Appium server
48
+ # app_server.stop_server
49
+ end
50
+
51
+ # clean up temp dir
52
+ Logger.info "Cleaning up tmp dir"
53
+ FileUtils.remove_entry app.tmp_dir
54
+ end
55
+
56
+ #
57
+ # Kick off a compile
58
+ # @param scheme [String] The scheme to compile
59
+ # @param app_dir [String] the directory where the .app file will be
60
+ # @param &compiled [Block] Completion block
61
+ #
62
+ def compile(scheme, app_dir, &compiled)
63
+ compiler = Cuesmash::Compiler.new(scheme, app_dir)
64
+ compiler.compile do |complete|
65
+ yield
66
+ end
67
+ end
68
+
69
+ #
70
+ # Update the applications plist so that the application
71
+ # connects to sinatra
72
+ # @param scheme [String] The scheme related to the application
73
+ #
74
+ def update_plist(scheme, app_path)
75
+ plist = Cuesmash::Plist.new(scheme, app_path)
76
+ plist.execute
77
+ end
78
+
79
+ #
80
+ # Run the cucumber tests, that's why we're here afterall
81
+ #
82
+ # @param ios [String] The iOS version to test with
83
+ # @param tags [Array] The cucumber tags to test with
84
+ # @param format [String] The output format for the cucumber tests, Optional
85
+ # @param output [String] The path to the output directory to output test reports to, Optional
86
+ def run_tests(ios, tags, format=nil, output=nil)
87
+ cucumber = Cuesmash::Cucumber.new(ios, tags)
88
+ cucumber.format = format if format
89
+ cucumber.output = output if output
90
+ cucumber.test
91
+ end
92
+
93
+ #
94
+ # Update appium.txt file with the directory of the build product
95
+ #
96
+ def create_appium_txt(platform_name: "iOS", device_name:, platform_version:, app:)
97
+ appium = AppiumText.new(platform_name: platform_name, device_name: device_name, platform_version: platform_version, app: app)
98
+ appium.execute
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+
3
+ module Cuesmash
4
+
5
+ #
6
+ # The calamsash compiler will compiles the Xcode project with the
7
+ # scheme it's told to compile with.
8
+ #
9
+ # @author [alexfish]
10
+ #
11
+ class Compiler
12
+ # include Logging
13
+
14
+ # Public: the Scheme the compiler is compiling
15
+ attr_accessor :scheme
16
+ attr_accessor :tmp_dir
17
+
18
+ def initialize(scheme, tmp_dir)
19
+ @scheme = scheme
20
+ @tmp_dir = tmp_dir
21
+ end
22
+
23
+ #
24
+ # The compiler's heart, executes the compiling with xcodebuild
25
+ #
26
+ # @param &complete Compleition block
27
+ #
28
+ # Returns nothing because it completes with a complete block
29
+ def compile(&complete)
30
+ started
31
+ status = nil
32
+ output = ""
33
+
34
+ Open3.popen3 command do |stdin, out, err, wait_thr|
35
+ print "\n"
36
+ [out, err].each do |stream|
37
+ Thread.new do
38
+ until (line = stream.gets).nil? do
39
+ print "."
40
+ output << line
41
+ end
42
+ end
43
+ end
44
+ wait_thr.join
45
+ status = wait_thr.value.exitstatus
46
+ end
47
+
48
+ if status != 0
49
+ Logger.fatal "Compilation failed: #{output}"
50
+ # exit status
51
+ status
52
+ else
53
+ completed
54
+ complete.call(true) if complete
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ #
61
+ # Output a nice message for starting
62
+ #
63
+ def started
64
+ Logger.info "Compiling"
65
+ end
66
+
67
+ #
68
+ # Output a nice message for completing
69
+ #
70
+ def completed
71
+ Logger.info "Compiled 👌"
72
+ end
73
+
74
+ #
75
+ # Generate the string to be used as the xcode build command
76
+ # using the scheme ivar
77
+ #
78
+ # @return [String] The full xcode build command with args
79
+ def command
80
+ xcode_command = "xcodebuild #{workspace} -scheme #{@scheme} -sdk iphonesimulator CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -derivedDataPath #{@tmp_dir}"
81
+ Logger.info "xcode_command == #{xcode_command}"
82
+ xcode_command
83
+ end
84
+
85
+ #
86
+ # Looks in the current directory for the workspace file and
87
+ # gets it's name if there is one
88
+ #
89
+ # @return [String] The name of the workspace file that was found along with the -workspace flag
90
+ def workspace
91
+ wp = Dir["*.xcworkspace"].first
92
+ if wp
93
+ flag = "-workspace #{wp}"
94
+ Logger.debug "workspace == #{wp}"
95
+ return flag
96
+ else
97
+ Logger.debug "no workspace found"
98
+ return wp
99
+ end
100
+ end
101
+ end
102
+ end