frank-cucumber 0.8.13 → 0.8.14
Sign up to get free protection for your applications and to get access to all the features.
- data/frank-cucumber.gemspec +2 -0
- data/frank-skeleton/libFrank.a +0 -0
- data/frank-skeleton/libShelley.a +0 -0
- data/lib/frank-cucumber/frank_helper.rb +2 -0
- data/lib/frank-cucumber/keyboard_helper.rb +14 -0
- data/lib/frank-cucumber/version.rb +1 -1
- data/lib/frank-cucumber/wait_helper.rb +28 -0
- data/test/keyboard_helper_test.rb +74 -0
- data/test/launcher_test.rb +3 -0
- data/test/test_helper.rb +8 -2
- metadata +28 -14
data/frank-cucumber.gemspec
CHANGED
data/frank-skeleton/libFrank.a
CHANGED
Binary file
|
data/frank-skeleton/libShelley.a
CHANGED
Binary file
|
@@ -2,11 +2,13 @@ require 'json'
|
|
2
2
|
require 'frank-cucumber/gateway'
|
3
3
|
require 'frank-cucumber/host_scripting'
|
4
4
|
require 'frank-cucumber/wait_helper'
|
5
|
+
require 'frank-cucumber/keyboard_helper'
|
5
6
|
|
6
7
|
module Frank module Cucumber
|
7
8
|
|
8
9
|
module FrankHelper
|
9
10
|
include WaitHelper
|
11
|
+
include KeyboardHelper
|
10
12
|
include HostScripting
|
11
13
|
|
12
14
|
class << self
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Frank
|
2
|
+
module Cucumber
|
3
|
+
|
4
|
+
module KeyboardHelper
|
5
|
+
def type_into_keyboard(text_to_type)
|
6
|
+
text_to_type = text_to_type+"\n" unless text_to_type.end_with?("\n")
|
7
|
+
res = frank_server.send_post(
|
8
|
+
'type_into_keyboard',
|
9
|
+
:text_to_type => text_to_type,
|
10
|
+
)
|
11
|
+
Frank::Cucumber::Gateway.evaluate_frankly_response( res, "typing the following into the keyboard '#{text_to_type}'" )
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end end
|
@@ -3,6 +3,34 @@ require 'timeout'
|
|
3
3
|
module Frank
|
4
4
|
module Cucumber
|
5
5
|
|
6
|
+
# What's going on here?!
|
7
|
+
#
|
8
|
+
# This module contains a single method called wait_until. When we mix this module into another class or module (such as
|
9
|
+
# FrankHelper) then that wait_until method will be available inside that class or module. Because we call module_function
|
10
|
+
# at the end of the module this method is also available as a static method on the module. That means you can also call
|
11
|
+
# Frank::Cucumber::WaitHelper.wait_until from anywhere in your code.
|
12
|
+
#
|
13
|
+
#
|
14
|
+
# wait_until will repeatedly execute the passed in block until either it returns true or a timeout expires. Between
|
15
|
+
# executions there is a pause of POLL_SLEEP seconds.
|
16
|
+
#
|
17
|
+
# wait_until takes two options, a timeout and a message.
|
18
|
+
# The timeout defaults to the WaitHelper::TIMEOUT constant. That constant is based off of a WAIT_TIMEOUT
|
19
|
+
# environment variable, otherwise it defaults to 240 seconds.
|
20
|
+
# If a message is passed in as an option then that message is used when reporting a timeout.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# Example usage:
|
24
|
+
#
|
25
|
+
# wait_until( :timeout => 20, :message => 'timed out waiting for splines to reticulate' ) do
|
26
|
+
# num_splines_reticulated = reticulate_splines(1,2,3)
|
27
|
+
# num_splines_reticulated > 0
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# Here we will keep calling the reticulate_splines method until either it returns a result
|
31
|
+
# greater than 0 or 20 seconds elapses. In the timeout case an exception will be raised
|
32
|
+
# saying "timed out waiting for splines to reticulate"
|
33
|
+
|
6
34
|
module WaitHelper
|
7
35
|
TIMEOUT = ENV['WAIT_TIMEOUT'].to_i || 240
|
8
36
|
POLL_SLEEP = 0.1 #seconds
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative 'test_helper.rb'
|
2
|
+
|
3
|
+
class HelperForTesting
|
4
|
+
include Frank::Cucumber::KeyboardHelper
|
5
|
+
|
6
|
+
|
7
|
+
def mock_frank_server
|
8
|
+
RR.mock(@mock_frank_server = Object.new)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def frank_server
|
13
|
+
@mock_frank_server
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "frank keyboard helper" do
|
18
|
+
|
19
|
+
the_helper = nil
|
20
|
+
before do
|
21
|
+
the_helper = HelperForTesting.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def successful_response
|
25
|
+
%Q{ { "outcome": "SUCCESS" } }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'posts to the right endpoint' do
|
29
|
+
the_helper.mock_frank_server.send_post('type_into_keyboard', anything ){ successful_response }
|
30
|
+
|
31
|
+
the_helper.type_into_keyboard('blah')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sends the right payload, adding a trailing new-line if needed' do
|
35
|
+
the_helper.mock_frank_server.send_post.with_any_args do |endpoint,payload|
|
36
|
+
payload.must_equal( {:text_to_type => "the text I want to type\n"} )
|
37
|
+
|
38
|
+
successful_response
|
39
|
+
end
|
40
|
+
|
41
|
+
the_helper.type_into_keyboard('the text I want to type')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "doesn't add a trailing newline if already there" do
|
45
|
+
the_helper.mock_frank_server.send_post.with_any_args do |endpoint,payload|
|
46
|
+
payload.must_equal( {:text_to_type => "existing newline\n"} )
|
47
|
+
|
48
|
+
successful_response
|
49
|
+
end
|
50
|
+
|
51
|
+
the_helper.type_into_keyboard("existing newline\n")
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'raises an exception if the server responds negatively' do
|
55
|
+
failure_message = <<-EOS
|
56
|
+
{
|
57
|
+
"outcome": "NOT SUCCESS AT ALL",
|
58
|
+
"reason": "reason for failure",
|
59
|
+
"details": "details about failure"
|
60
|
+
}
|
61
|
+
EOS
|
62
|
+
|
63
|
+
the_helper.mock_frank_server.send_post.with_any_args{ failure_message }
|
64
|
+
|
65
|
+
exception = lambda{
|
66
|
+
the_helper.type_into_keyboard('text we attempted to type')
|
67
|
+
}.must_raise RuntimeError
|
68
|
+
|
69
|
+
exception.message.must_match /text we attempted to type/
|
70
|
+
exception.message.must_match /reason for failure/
|
71
|
+
exception.message.must_match /details about failure/
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/launcher_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
require 'ostruct'
|
1
2
|
require 'stringio'
|
2
3
|
require 'minitest/autorun'
|
3
4
|
require 'minitest/mock'
|
4
5
|
require 'minitest/spec'
|
5
6
|
include MiniTest
|
7
|
+
|
8
|
+
require 'rr'
|
9
|
+
class MiniTest::Unit::TestCase
|
10
|
+
include RR::Adapters::MiniTest
|
11
|
+
end
|
12
|
+
|
6
13
|
require_relative '../lib/frank-cucumber/color_helper'
|
7
14
|
require_relative '../lib/frank-cucumber/frank_helper'
|
8
15
|
require_relative '../lib/frank-cucumber/launcher'
|
9
|
-
|
10
|
-
include Frank::Cucumber::FrankHelper
|
16
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frank-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-22 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber
|
17
|
-
requirement: &
|
17
|
+
requirement: &70144982662120 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70144982662120
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &70144982661540 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70144982661540
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: sim_launcher
|
39
|
-
requirement: &
|
39
|
+
requirement: &70144982661020 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70144982661020
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: i18n
|
50
|
-
requirement: &
|
50
|
+
requirement: &70144982660500 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *70144982660500
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: plist
|
61
|
-
requirement: &
|
61
|
+
requirement: &70144982660000 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *70144982660000
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: json
|
72
|
-
requirement: &
|
72
|
+
requirement: &70144982659180 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,18 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *70144982659180
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rr
|
83
|
+
requirement: &70144982658640 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *70144982658640
|
81
92
|
description: Use cucumber to test native iOS apps via Frank
|
82
93
|
email:
|
83
94
|
- gems@thepete.net
|
@@ -133,10 +144,12 @@ files:
|
|
133
144
|
- lib/frank-cucumber/frank_localize.rb
|
134
145
|
- lib/frank-cucumber/gateway.rb
|
135
146
|
- lib/frank-cucumber/host_scripting.rb
|
147
|
+
- lib/frank-cucumber/keyboard_helper.rb
|
136
148
|
- lib/frank-cucumber/launcher.rb
|
137
149
|
- lib/frank-cucumber/localize.yml
|
138
150
|
- lib/frank-cucumber/version.rb
|
139
151
|
- lib/frank-cucumber/wait_helper.rb
|
152
|
+
- test/keyboard_helper_test.rb
|
140
153
|
- test/launcher_test.rb
|
141
154
|
- test/test_helper.rb
|
142
155
|
homepage: http://rubygems.org/gems/frank-cucumber
|
@@ -164,5 +177,6 @@ signing_key:
|
|
164
177
|
specification_version: 3
|
165
178
|
summary: Use cucumber to test native iOS apps via Frank
|
166
179
|
test_files:
|
180
|
+
- test/keyboard_helper_test.rb
|
167
181
|
- test/launcher_test.rb
|
168
182
|
- test/test_helper.rb
|