cuesmash 0.1.7.1 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cuesmash.yml +4 -1
- data/Gemfile.lock +9 -1
- data/cuesmash.gemspec +2 -1
- data/lib/cuesmash/android_app.rb +36 -0
- data/lib/cuesmash/android_appium_text.rb +71 -0
- data/lib/cuesmash/android_command.rb +86 -0
- data/lib/cuesmash/android_compiler.rb +27 -0
- data/lib/cuesmash/androidapp.rb +36 -0
- data/lib/cuesmash/app.rb +22 -0
- data/lib/cuesmash/appium_text.rb +8 -5
- data/lib/cuesmash/command.rb +12 -10
- data/lib/cuesmash/compiler.rb +4 -39
- data/lib/cuesmash/cucumber.rb +1 -2
- data/lib/cuesmash/ios_app.rb +42 -0
- data/lib/cuesmash/ios_compiler.rb +49 -0
- data/lib/cuesmash/iosapp.rb +9 -15
- data/lib/cuesmash/ioscompiler.rb +49 -0
- data/lib/cuesmash/setup.rb +1 -0
- data/lib/cuesmash/start.rb +123 -36
- data/spec/android_compiler_spec.rb +37 -0
- data/spec/appium_text_spec.rb +22 -1
- data/spec/command_spec.rb +5 -10
- data/spec/cucumber_spec.rb +14 -14
- data/spec/ios_app_spec.rb +36 -0
- data/spec/ios_compiler_spec.rb +76 -0
- data/spec/{compiler_spec.rb → ioscompiler_spec.rb} +10 -9
- data/spec/spec_helper.rb +2 -0
- metadata +33 -4
data/lib/cuesmash/iosapp.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
+
require 'cuesmash/app'
|
5
|
+
|
4
6
|
module Cuesmash
|
5
7
|
|
6
8
|
#
|
7
9
|
# Provides an object to get information about the ios app that is being built.
|
8
10
|
#
|
9
|
-
|
10
|
-
#
|
11
|
-
class IosApp
|
11
|
+
class IosApp < App
|
12
12
|
|
13
13
|
# Public: the path to the dir containing the built app i.e. /tmp/MyAppQWERQW/Build/Products/Debug-iphonesimulator/
|
14
14
|
attr_reader :app_dir
|
@@ -26,23 +26,17 @@ module Cuesmash
|
|
26
26
|
# Create a new App instance
|
27
27
|
#
|
28
28
|
# @param file_name [String] The usually is the scheme of the xcode project
|
29
|
-
# @param
|
29
|
+
# @param build_configuration [String] which iOS build configuration to run i.e. Release, Debug
|
30
30
|
#
|
31
31
|
# @return [App] A app instance
|
32
|
-
def initialize(file_name:,
|
32
|
+
def initialize(file_name:, build_configuration:)
|
33
33
|
@app_name = "#{file_name}" << ".app"
|
34
34
|
@tmp_dir = Dir.mktmpdir(file_name)
|
35
35
|
@build_configuration = build_configuration
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
# our own tmp dir for each build.
|
40
|
-
if travis_build
|
41
|
-
@app_dir = "./build/Release-iphonesimulator/"
|
42
|
-
else
|
43
|
-
@app_dir = "#{@tmp_dir}" << "/#{@build_configuration}-iphonesimulator/"
|
44
|
-
end
|
37
|
+
@app_dir = "#{@tmp_dir}" << "/#{@build_configuration}-iphonesimulator/"
|
38
|
+
|
45
39
|
@app_path = "#{@app_dir}" << "#{@app_name}"
|
46
40
|
end
|
47
|
-
end
|
48
|
-
end
|
41
|
+
end # class IosApp
|
42
|
+
end # module Cuesmash
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Cuesmash
|
4
|
+
|
5
|
+
#
|
6
|
+
# iOS Specific compiler
|
7
|
+
#
|
8
|
+
class IosCompiler < Compiler
|
9
|
+
|
10
|
+
attr_accessor :scheme
|
11
|
+
attr_accessor :tmp_dir
|
12
|
+
attr_accessor :build_configuration
|
13
|
+
|
14
|
+
def initialize(scheme, tmp_dir, build_configuration)
|
15
|
+
@scheme = scheme
|
16
|
+
@tmp_dir = tmp_dir
|
17
|
+
@build_configuration = build_configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Generate the string to be used as the xcode build command
|
22
|
+
# using the scheme ivar
|
23
|
+
#
|
24
|
+
# @return [String] The full xcode build command with args
|
25
|
+
def command
|
26
|
+
xcode_command = "set -o pipefail && xcodebuild #{workspace} -scheme #{@scheme} -derivedDataPath #{@tmp_dir} -configuration #{@build_configuration} OBJROOT=#{@tmp_dir} SYMROOT=#{@tmp_dir} -sdk iphonesimulator build | bundle exec xcpretty -c"
|
27
|
+
|
28
|
+
Logger.info "xcode_command == #{xcode_command}"
|
29
|
+
xcode_command
|
30
|
+
end # command
|
31
|
+
|
32
|
+
#
|
33
|
+
# Looks in the current directory for the workspace file and
|
34
|
+
# gets it's name if there is one
|
35
|
+
#
|
36
|
+
# @return [String] The name of the workspace file that was found along with the -workspace flag
|
37
|
+
def workspace
|
38
|
+
wp = Dir["*.xcworkspace"].first
|
39
|
+
if wp
|
40
|
+
flag = "-workspace #{wp}"
|
41
|
+
Logger.debug "workspace == #{wp}"
|
42
|
+
return flag
|
43
|
+
else
|
44
|
+
Logger.debug "no workspace found"
|
45
|
+
return wp
|
46
|
+
end
|
47
|
+
end # workspace
|
48
|
+
end # class IosCompiler
|
49
|
+
end # module Cuesmash
|
data/lib/cuesmash/setup.rb
CHANGED
data/lib/cuesmash/start.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
|
4
4
|
require 'thor'
|
5
5
|
require 'cuesmash'
|
6
|
-
require 'cuesmash/
|
6
|
+
require 'cuesmash/ioscompiler'
|
7
|
+
require 'cuesmash/androidapp'
|
8
|
+
require 'cuesmash/androidcompiler'
|
9
|
+
require 'cuesmash/android_command'
|
10
|
+
require 'byebug'
|
7
11
|
|
8
12
|
module Cuesmash
|
9
13
|
|
@@ -22,14 +26,16 @@ module Cuesmash
|
|
22
26
|
--tags -t the tags to pass to cucumber, for multiple tags pass one per tag. See cucumber tags for more info. https://github.com/cucumber/cucumber/wiki/Tags\n
|
23
27
|
--output -o The output directory for the test report --not yet implemented--\n
|
24
28
|
--format -f The format of the test report --not yet implemented--\n
|
25
|
-
--scheme -s the Xcode scheme to build\n
|
29
|
+
--scheme -s iOS only: the Xcode scheme to build\n
|
30
|
+
--app_name -n Android only: the name of the app\n
|
26
31
|
--debug -d BOOLEAN turn on debug output\n
|
27
32
|
--travis_ci -c BOOLEAN turn on settings for building on Travis CI\n
|
28
33
|
--server -r BOOLEAN start up server (requires sinatra app in the project directory)\n
|
29
34
|
--profile -p which cucumber.yml profile to use\n
|
30
35
|
--quiet -q BOOLEAN cucumber quiet mode
|
31
36
|
LONGDESC
|
32
|
-
method_option :scheme, type: :string, aliases: "-s", desc: "the Xcode scheme to build"
|
37
|
+
method_option :scheme, type: :string, aliases: "-s", desc: "iOS only: the Xcode scheme to build"
|
38
|
+
method_option :app_name, type: :string, aliases: "-n", desc: "Android only: the name of the app"
|
33
39
|
method_option :tags, type: :array, aliases: "-t", desc: "the tags to pass to cucumber, for multiple tags pass one per tag"
|
34
40
|
method_option :debug, type: :boolean, default: false, aliases: "-d", desc: "turn on debug output"
|
35
41
|
method_option :travis_ci, type: :boolean, default: false, aliases: "-c", desc: "turn on settings for building on Travis CI"
|
@@ -39,59 +45,91 @@ module Cuesmash
|
|
39
45
|
def test
|
40
46
|
|
41
47
|
# get the cuesmash.yml config
|
42
|
-
config = load_config
|
43
|
-
|
44
|
-
# Create new IosApp object
|
45
|
-
app = IosApp.new(file_name: options[:scheme], travis_build: options[:travis_ci])
|
48
|
+
@config = load_config
|
46
49
|
|
47
50
|
# Compile the project
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
if @config['platform'] == 'iOS'
|
52
|
+
|
53
|
+
# Create new IosApp object
|
54
|
+
@app = IosApp.new(file_name: options[:scheme], build_configuration: @config['build_configuration'])
|
55
|
+
|
56
|
+
setup_ios
|
57
|
+
|
58
|
+
# enumerate over each device / OS combination and run the tests.
|
59
|
+
@config['devices'].each do |device, oses|
|
60
|
+
oses.each do |os|
|
61
|
+
say "\n============================\ntesting iOS #{os} on #{device}", :green
|
62
|
+
Cuesmash::Command.execute(device: device,
|
63
|
+
os: os,
|
64
|
+
server: options[:server],
|
65
|
+
tags: options[:tags],
|
66
|
+
scheme: options[:scheme],
|
67
|
+
debug: options[:debug],
|
68
|
+
app: @app,
|
69
|
+
profile: options[:profile],
|
70
|
+
quiet: options[:quiet],
|
71
|
+
timeout: @config['default']['test_timeout'].to_s)
|
72
|
+
end
|
73
|
+
end # device each
|
74
|
+
|
75
|
+
# clean up the temp dir
|
62
76
|
Logger.info "Cleaning up tmp dir\n"
|
63
|
-
FileUtils.remove_entry app.tmp_dir
|
77
|
+
FileUtils.remove_entry @app.tmp_dir
|
78
|
+
|
79
|
+
elsif @config['platform'] == 'Android'
|
80
|
+
|
81
|
+
say "Setting up android", :red
|
82
|
+
|
83
|
+
@app = Cuesmash::AndroidApp.new(project_name: options[:app_name], build_configuration: @config['build_configuration'])
|
84
|
+
setup_android
|
85
|
+
|
86
|
+
# enumerate over each device / OS combination and run the tests.
|
87
|
+
@config['devices']['emulators'].each do |emulator|
|
88
|
+
say "\n============================\ntesting Android on #{emulator}", :green
|
89
|
+
Cuesmash::AndroidCommand.execute( avd: emulator,
|
90
|
+
server: options[:server],
|
91
|
+
tags: options[:tags],
|
92
|
+
debug: options[:debug],
|
93
|
+
app: @app,
|
94
|
+
profile: options[:profile],
|
95
|
+
quiet: options[:quiet],
|
96
|
+
timeout: @config['default']['test_timeout'].to_s)
|
97
|
+
end # device each
|
98
|
+
else
|
99
|
+
say "please set platform: 'iOS' or 'Android' in your .cuesmash.yml file", :red
|
100
|
+
return
|
64
101
|
end
|
65
102
|
end # test
|
66
103
|
|
67
104
|
desc "build OPTIONS", "compile the app and create appium.txt to use for arc"
|
68
105
|
long_desc <<-LONGDESC
|
69
|
-
--scheme -s the Xcode scheme to build\n
|
106
|
+
--scheme -s iOS: the Xcode scheme to build\n
|
107
|
+
--app_name -n Android: the app name
|
70
108
|
LONGDESC
|
71
109
|
method_option :scheme, type: :string, aliases: "-s", desc: "the Xcode scheme to build"
|
110
|
+
method_option :app_name, type: :string, aliases: "-n", desc: "Android only: the name of the app"
|
72
111
|
def build
|
73
112
|
|
74
113
|
# get the cuesmash.yml config
|
75
|
-
config = load_config
|
114
|
+
@config = load_config
|
76
115
|
|
77
116
|
# if no default then bail
|
78
|
-
if config['default'] == nil
|
117
|
+
if @config['default'] == nil
|
79
118
|
say "add a default device and os version to the .cuesmash.yml", :red
|
80
119
|
return
|
81
120
|
end
|
82
121
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
appium.execute
|
122
|
+
if @config['platform'] == 'iOS'
|
123
|
+
setup_ios
|
124
|
+
elsif @config['platform'] == 'Android'
|
125
|
+
say "Setting up android"
|
126
|
+
setup_android
|
127
|
+
else
|
128
|
+
say "please set platform: 'iOS' or 'Android' in your .cuesmash.yml file", :red
|
129
|
+
return
|
130
|
+
end
|
93
131
|
|
94
|
-
say "\nYour build is available at #{app.app_path}", :green
|
132
|
+
say "\nYour build is available at #{@app.app_path}", :green
|
95
133
|
end # build
|
96
134
|
|
97
135
|
no_commands do
|
@@ -109,6 +147,55 @@ module Cuesmash
|
|
109
147
|
end
|
110
148
|
config
|
111
149
|
end # end load_config
|
150
|
+
|
151
|
+
#
|
152
|
+
# helper methods
|
153
|
+
#
|
154
|
+
def setup_ios
|
155
|
+
@app = IosApp.new(file_name: options[:scheme], build_configuration: @config['build_configuration'])
|
156
|
+
|
157
|
+
# Compile the project
|
158
|
+
compiler = Cuesmash::IosCompiler.new(options[:scheme], @app.tmp_dir, @config['build_configuration'])
|
159
|
+
compiler.compile
|
160
|
+
|
161
|
+
ios_appium_text
|
162
|
+
end
|
163
|
+
|
164
|
+
#
|
165
|
+
# helper method for setting up android build
|
166
|
+
#
|
167
|
+
def setup_android
|
168
|
+
@app = Cuesmash::AndroidApp.new(project_name: options[:app_name], build_configuration: @config['build_configuration'])
|
169
|
+
|
170
|
+
# Compile the project
|
171
|
+
compiler = Cuesmash::AndroidCompiler.new
|
172
|
+
compiler.compile
|
173
|
+
|
174
|
+
android_appium_text
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
# iOS Appium text file set up
|
179
|
+
#
|
180
|
+
def ios_appium_text
|
181
|
+
appium = Cuesmash::AppiumText.new(platform_name: "iOS",
|
182
|
+
device_name: @config['default']['os'],
|
183
|
+
platform_version: @config['default']['version'].to_s,
|
184
|
+
app: @app.app_path,
|
185
|
+
new_command_timeout: @config['default']['test_timeout'].to_s)
|
186
|
+
appium.execute
|
187
|
+
end
|
188
|
+
|
189
|
+
#
|
190
|
+
# Android Appium text file set up
|
191
|
+
#
|
192
|
+
def android_appium_text
|
193
|
+
appium = Cuesmash::AndroidAppiumText.new( platform_name: @config['platform'],
|
194
|
+
avd: @config['default_emulator'],
|
195
|
+
app: @app.app_path,
|
196
|
+
new_command_timeout: @config['default']['test_timeout'].to_s)
|
197
|
+
appium.execute
|
198
|
+
end
|
112
199
|
end # no_commands
|
113
200
|
end # Start class
|
114
201
|
end # module Cuesmash
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cuesmash/android_compiler'
|
3
|
+
|
4
|
+
describe Cuesmash::AndroidCompiler do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Cuesmash::AndroidCompiler.any_instance.stub(:puts)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "when generating the command" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@compiler = Cuesmash::AndroidCompiler.new
|
14
|
+
end
|
15
|
+
|
16
|
+
end # "when generating the command"
|
17
|
+
|
18
|
+
describe "when compiling" do
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
wait = double
|
22
|
+
@value = double
|
23
|
+
wait.stub(:value){@value}
|
24
|
+
wait.stub(:join)
|
25
|
+
Open3.stub(:popen3).and_yield(nil, nil, nil, wait)
|
26
|
+
|
27
|
+
@compiler = Cuesmash::AndroidCompiler.new
|
28
|
+
end # before
|
29
|
+
|
30
|
+
it "should complete if all is well" do
|
31
|
+
@value.stub(:exitstatus){0}
|
32
|
+
@compiler.compile do |complete|
|
33
|
+
expect(complete).to equal(true)
|
34
|
+
end
|
35
|
+
end # "should complete if all is well"
|
36
|
+
end # "when compiling"
|
37
|
+
end # describe Cuesmash::AndroidCompiler
|
data/spec/appium_text_spec.rb
CHANGED
@@ -4,9 +4,11 @@ describe Cuesmash::AppiumText do
|
|
4
4
|
|
5
5
|
describe "when creating a new instance" do
|
6
6
|
before(:all) do
|
7
|
-
@appiumtext = Cuesmash::AppiumText.new(platform_name: "iOS", device_name: "iPhone Simulator", platform_version: "7.1", app: "MyApp")
|
7
|
+
@appiumtext = Cuesmash::AppiumText.new(platform_name: "iOS", device_name: "iPhone Simulator", platform_version: "7.1", app: "MyApp", new_command_timeout: "90")
|
8
8
|
end
|
9
9
|
|
10
|
+
expected = "[caps]\nplatformName = \"iOS\"\ndeviceName = \"iPhone Simulator\"\nplatformVersion = \"7.1\"\napp = \"MyApp\"\nnewCommandTimeout = \"90\"\n"
|
11
|
+
|
10
12
|
it "should have a platform name" do
|
11
13
|
expect(@appiumtext.platform_name).to match("iOS")
|
12
14
|
end
|
@@ -22,5 +24,24 @@ describe Cuesmash::AppiumText do
|
|
22
24
|
it "should have an app name" do
|
23
25
|
expect(@appiumtext.app).to match("MyApp")
|
24
26
|
end
|
27
|
+
|
28
|
+
it "should have an newCommandTimeout" do
|
29
|
+
expect(@appiumtext.new_command_timeout).to match("90")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should output this text" do
|
33
|
+
# TODO: we need to test that the text output is actually right. I'm putting this off until next week though.
|
34
|
+
# # IO.expects(:write).with("features/support/appium.txt", expected).once
|
35
|
+
# expect(IO).to recieve(:write).with("features/support/appium.txt", expected)
|
36
|
+
|
37
|
+
# @appiumtext.execute
|
38
|
+
# # expect(@appiumtext.appium_text_for_file).to match(expected)
|
39
|
+
# #
|
40
|
+
# #
|
41
|
+
# # expect(logger).to receive(:account_closed).with(account)
|
42
|
+
|
43
|
+
# # account.close
|
44
|
+
end
|
45
|
+
|
25
46
|
end
|
26
47
|
end
|
data/spec/command_spec.rb
CHANGED
@@ -55,14 +55,9 @@ describe Cuesmash::Command do
|
|
55
55
|
Cuesmash::Cucumber.stub(:new){@mock}
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should set the cucumber ios version" do
|
59
|
-
Cuesmash::Cucumber.should_receive(:new).with("ios", anything, anything, anything)
|
60
|
-
Cuesmash::Command.run_tests(ios: "ios", tags: "tags", profile: "profile", quiet: true)
|
61
|
-
end
|
62
|
-
|
63
58
|
it "should set the cucumber tags" do
|
64
|
-
Cuesmash::Cucumber.should_receive(:new).with(
|
65
|
-
Cuesmash::Command.run_tests(
|
59
|
+
Cuesmash::Cucumber.should_receive(:new).with("tags", anything, anything)
|
60
|
+
Cuesmash::Command.run_tests(tags: "tags", profile: "profile", quiet: true)
|
66
61
|
end
|
67
62
|
|
68
63
|
it "should set the format" do
|
@@ -70,7 +65,7 @@ describe Cuesmash::Command do
|
|
70
65
|
Cuesmash::Cucumber.stub(:new){@cucumber}
|
71
66
|
|
72
67
|
@cucumber.should_receive(:format=)
|
73
|
-
Cuesmash::Command.run_tests(
|
68
|
+
Cuesmash::Command.run_tests(tags: nil, profile: nil, format: "format", quiet: anything)
|
74
69
|
end
|
75
70
|
|
76
71
|
it "should set the output" do
|
@@ -78,12 +73,12 @@ describe Cuesmash::Command do
|
|
78
73
|
Cuesmash::Cucumber.stub(:new){@cucumber}
|
79
74
|
|
80
75
|
@cucumber.should_receive(:output=)
|
81
|
-
Cuesmash::Command.run_tests(
|
76
|
+
Cuesmash::Command.run_tests(tags: nil, profile: nil, format: nil, output: "output", quiet: anything)
|
82
77
|
end
|
83
78
|
|
84
79
|
it "should start the tests" do
|
85
80
|
@mock.should_receive(:test)
|
86
|
-
Cuesmash::Command.run_tests(
|
81
|
+
Cuesmash::Command.run_tests(tags: "tags", profile: "profile", quiet: true)
|
87
82
|
end
|
88
83
|
|
89
84
|
end # describe "when running the cucumber tests"
|
data/spec/cucumber_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe Cuesmash::Cucumber do
|
|
15
15
|
wait.stub(:join)
|
16
16
|
Open3.stub(:popen3).and_yield(nil, nil, nil, wait)
|
17
17
|
|
18
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
18
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
19
19
|
@cucumber.stub(:command)
|
20
20
|
end
|
21
21
|
|
@@ -29,75 +29,75 @@ describe Cuesmash::Cucumber do
|
|
29
29
|
describe "when generating the command" do
|
30
30
|
|
31
31
|
it "should not add the ios version if missing" do
|
32
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
32
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
33
33
|
@cucumber.stub(:tag_arguments)
|
34
34
|
|
35
35
|
expect(@cucumber.instance_eval{command}).not_to match(/DEVICE_TARGET/)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should add the format" do
|
39
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
39
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
40
40
|
@cucumber.format = "test-format"
|
41
41
|
|
42
42
|
expect(@cucumber.instance_eval{command}).to match(/--format test-format/)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should not add the format if missing" do
|
46
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
46
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
47
47
|
|
48
48
|
expect(@cucumber.instance_eval{command}).not_to match(/--format/)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should add the output" do
|
52
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
52
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
53
53
|
@cucumber.output = "test-output"
|
54
54
|
|
55
55
|
expect(@cucumber.instance_eval{command}).to match(/--out test-output/)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should not add the output if missing" do
|
59
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
59
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
60
60
|
|
61
61
|
expect(@cucumber.instance_eval{command}).not_to match(/--out/)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should add the tags" do
|
65
|
-
@cucumber = Cuesmash::Cucumber.new(
|
65
|
+
@cucumber = Cuesmash::Cucumber.new(["tag1", "tag2"], nil, nil)
|
66
66
|
expect(@cucumber.instance_eval{command}).to match(/--tags tag1 --tags tag2/)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should not add tags if missing" do
|
70
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
70
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
71
71
|
expect(@cucumber.instance_eval{command}).not_to match(/--tags/)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should add the profile" do
|
75
|
-
@cucumber = Cuesmash::Cucumber.new(nil,
|
75
|
+
@cucumber = Cuesmash::Cucumber.new(nil, "test", nil)
|
76
76
|
expect(@cucumber.instance_eval{command}).to match(/--profile test/)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should not add tags if missing" do
|
80
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
80
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
81
81
|
expect(@cucumber.instance_eval{command}).not_to match(/--profile/)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should add the color flag" do
|
85
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
85
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
86
86
|
expect(@cucumber.instance_eval{command}).to match(/-c/)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should not add quiet if missing" do
|
90
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil
|
90
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, nil)
|
91
91
|
expect(@cucumber.instance_eval{command}).not_to match(/--quiet/)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should not add quiet if false" do
|
95
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil,
|
95
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, false)
|
96
96
|
expect(@cucumber.instance_eval{command}).not_to match(/--quiet/)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should add the quiet flag" do
|
100
|
-
@cucumber = Cuesmash::Cucumber.new(nil, nil,
|
100
|
+
@cucumber = Cuesmash::Cucumber.new(nil, nil, true)
|
101
101
|
expect(@cucumber.instance_eval{command}).to match(/--quiet/)
|
102
102
|
end
|
103
103
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cuesmash/ios_app'
|
3
|
+
require 'cuesmash/app'
|
4
|
+
|
5
|
+
describe Cuesmash::IosApp do
|
6
|
+
describe "when creating a new instance" do
|
7
|
+
|
8
|
+
it "should have an app_dir instance" do
|
9
|
+
stub_dir
|
10
|
+
@iosapp = Cuesmash::IosApp.new(file_name: "MyApp", build_configuration: "Debug")
|
11
|
+
expect(@iosapp.app_dir).to match("/tmp/Debug-iphonesimulator/")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have an app_path instance" do
|
15
|
+
stub_dir
|
16
|
+
@iosapp = Cuesmash::IosApp.new(file_name: "MyApp", build_configuration: "Debug")
|
17
|
+
expect(@iosapp.app_path).to match("/tmp/Debug-iphonesimulator/MyApp.app")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a tmp_dir instance" do
|
21
|
+
stub_dir
|
22
|
+
@iosapp = Cuesmash::IosApp.new(file_name: "MyApp", build_configuration: "Debug")
|
23
|
+
expect(@iosapp.tmp_dir).to match("/tmp")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have an app_name instance" do
|
27
|
+
|
28
|
+
@iosapp = Cuesmash::IosApp.new(file_name: "MyApp", build_configuration: "Debug")
|
29
|
+
expect(@iosapp.app_name).to match("MyApp.app")
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_dir
|
33
|
+
Dir.stub(:mktmpdir) { "/tmp" }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cuesmash/ios_compiler'
|
3
|
+
|
4
|
+
describe Cuesmash::IosCompiler do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Cuesmash::IosCompiler.any_instance.stub(:puts)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a scheme instance" do
|
11
|
+
compiler = Cuesmash::IosCompiler.new("scheme", "/tmp", "Debug")
|
12
|
+
expect(compiler.scheme).to match("scheme")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have a tmp_dir instance" do
|
16
|
+
compiler = Cuesmash::IosCompiler.new("scheme", "/tmp", "Debug")
|
17
|
+
expect(compiler.tmp_dir).to match("/tmp")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have a build config" do
|
21
|
+
compiler = Cuesmash::IosCompiler.new("scheme", "/tmp", "Debug")
|
22
|
+
expect(compiler.build_configuration).to match("Debug")
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "when generating the command" do
|
26
|
+
|
27
|
+
before(:each) do
|
28
|
+
Cuesmash::IosCompiler.any_instance.stub(:workspace)
|
29
|
+
@compiler = Cuesmash::IosCompiler.new("test-scheme", "/tmp", "Debug")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should contain the scheme" do
|
33
|
+
expect(@compiler.instance_eval{command}).to match(/test-scheme/)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should contain the tmp path" do
|
37
|
+
expect(@compiler.instance_eval{command}).to match(/tmp/)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should contain the build configuration" do
|
41
|
+
expect(@compiler.instance_eval{command}).to match(/Debug/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when getting the workspacae" do
|
46
|
+
|
47
|
+
before(:each) do
|
48
|
+
@compiler = Cuesmash::IosCompiler.new(nil, "/tmp", "Debug")
|
49
|
+
Dir.stub(:[]){["workspace-file"]}
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should get the workspace from the current directory" do
|
53
|
+
expect(@compiler.instance_eval{workspace}).to match(/workspace-file/)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "when compiling" do
|
58
|
+
|
59
|
+
before(:each) do
|
60
|
+
wait = double
|
61
|
+
@value = double
|
62
|
+
wait.stub(:value){@value}
|
63
|
+
wait.stub(:join)
|
64
|
+
Open3.stub(:popen3).and_yield(nil, nil, nil, wait)
|
65
|
+
|
66
|
+
@compiler = Cuesmash::IosCompiler.new(nil, "/tmp", "Debug")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should complete if all is well" do
|
70
|
+
@value.stub(:exitstatus){0}
|
71
|
+
@compiler.compile do |complete|
|
72
|
+
expect(complete).to equal(true)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|