fwtoolkit 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/fwt +5 -0
- data/lib/fwtoolkit/cli.rb +68 -0
- data/lib/fwtoolkit/test/frank_model.rb +62 -0
- data/lib/fwtoolkit/test/misc_steps.rb +9 -0
- data/lib/fwtoolkit/test/model_helper.rb +141 -0
- data/lib/fwtoolkit/test/model_steps.rb +19 -0
- data/lib/fwtoolkit/test/network_steps.rb +60 -0
- data/lib/fwtoolkit/test/pickle_steps.rb +101 -0
- data/lib/fwtoolkit/test/ui_helper.rb +19 -0
- data/lib/fwtoolkit/test/ui_steps.rb +17 -0
- data/lib/fwtoolkit/version.rb +3 -0
- data/lib/fwtoolkit.rb +22 -0
- data/templates/models/factories.rb.erb +10 -0
- data/templates/models/model.rb.erb +33 -0
- metadata +236 -0
data/bin/fwt
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'fwtoolkit'
|
2
|
+
require 'frank-cucumber/cli'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
module FWToolkit
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
include Rake::DSL
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
desc "model CORE_DATA_MODEL", "create model files for cucumber"
|
12
|
+
method_option :no_prefix, :aliases => "-np", :default => false, :type => :boolean
|
13
|
+
def model(core_data_model_path)
|
14
|
+
# validation step - core_data_model should be of type .xcdatamodel
|
15
|
+
output_dir = File.join('Frank', 'features', 'support', 'models')
|
16
|
+
FWToolkit::CLI.source_root(FWToolkit.root)
|
17
|
+
|
18
|
+
@no_prefix = options.no_prefix
|
19
|
+
|
20
|
+
model = CoreData::DataModel.new(File.join(core_data_model_path, 'contents'))
|
21
|
+
@models = model.entities
|
22
|
+
|
23
|
+
@models.each do |entity|
|
24
|
+
@model = entity
|
25
|
+
factory_template = File.join 'templates', 'models', 'model.rb.erb'
|
26
|
+
template(factory_template, File.join(output_dir, "#{class_name(@model).ruby_format}.rb"))
|
27
|
+
end
|
28
|
+
|
29
|
+
factory_template = File.join 'templates', 'models', 'factories.rb.erb'
|
30
|
+
template(factory_template, File.join(output_dir, 'factories.rb'))
|
31
|
+
end
|
32
|
+
|
33
|
+
no_tasks do
|
34
|
+
def class_name(entity)
|
35
|
+
@no_prefix ? entity.name : entity.name[3..-1]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "setup", "setup FWToolkit testing for the current workspace"
|
40
|
+
def setup
|
41
|
+
Frank::CLI.start(["setup"])
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "build", "build the frankified App for testing"
|
45
|
+
method_option :workspace, :aliases => "-w", :default => "#{File.basename(Dir.getwd)}.xcworkspace"
|
46
|
+
method_option :scheme, :aliases => "-s", :default => File.basename(Dir.getwd)
|
47
|
+
def build
|
48
|
+
workspace = options[:workspace]
|
49
|
+
scheme = options[:scheme]
|
50
|
+
Frank::CLI.start(["build", "--workspace", workspace, "--scheme", scheme])
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "test [TAG]", "run cucumber tests"
|
54
|
+
def test(tag = nil)
|
55
|
+
Dir.chdir('Frank') do
|
56
|
+
command = 'cucumber'
|
57
|
+
if tag
|
58
|
+
command = "cucumber --tag #{tag}"
|
59
|
+
end
|
60
|
+
|
61
|
+
sh command do |ok,res|
|
62
|
+
exit res.exitstatus
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'pickle'
|
2
|
+
|
3
|
+
module FWToolkit
|
4
|
+
module Test
|
5
|
+
class FrankModel
|
6
|
+
|
7
|
+
attr_accessor :id, :core_data_entity
|
8
|
+
|
9
|
+
module PickleAdapter
|
10
|
+
include Pickle::Adapter::Base
|
11
|
+
|
12
|
+
# Gets a list of the available models for this adapter
|
13
|
+
def self.model_classes
|
14
|
+
klasses = ::FWToolkit::Test::FrankModel.__send__(:descendants)
|
15
|
+
|
16
|
+
#klasses.select do |klass|
|
17
|
+
# !klass.abstract_class? && klass.table_exists? && !except_classes.include?(klass.name)
|
18
|
+
#end
|
19
|
+
end
|
20
|
+
|
21
|
+
# get a list of column names for a given class
|
22
|
+
def self.column_names(klass)
|
23
|
+
#klass.column_names
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get an instance by id of the model
|
28
|
+
def self.get_model(klass, id)
|
29
|
+
FWToolkit::Test::FrankModel.object_in_cache(id)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Find the first instance matching conditions
|
33
|
+
def self.find_first_model(klass, conditions)
|
34
|
+
#klass.find(:first, :conditions => conditions)
|
35
|
+
puts "find_first_model"
|
36
|
+
end
|
37
|
+
|
38
|
+
# Find all models matching conditions
|
39
|
+
def self.find_all_models(klass, conditions)
|
40
|
+
#klass.find(:all, :conditions => conditions)
|
41
|
+
puts "find_all_models"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Create a model using attributes
|
45
|
+
def self.create_model(klass, attributes)
|
46
|
+
puts "create_model"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
@@object_cache = {}
|
51
|
+
|
52
|
+
def self.object_in_cache(id)
|
53
|
+
return @@object_cache[id.to_s]
|
54
|
+
end
|
55
|
+
|
56
|
+
def save!
|
57
|
+
self.id = self.object_id
|
58
|
+
@@object_cache[self.object_id.to_s] = self
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file is generated by FWToolkit and is covered by the license at
|
2
|
+
#
|
3
|
+
require 'fwtoolkit/test/model_helper'
|
4
|
+
|
5
|
+
Given /^the app is (online|offline)$/ do |val|
|
6
|
+
online = (val.eql? "online")
|
7
|
+
fwt_app_exec("setRKObjectManagerIsOnline:", online)
|
8
|
+
sleep 5
|
9
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'mimic'
|
2
|
+
require 'socket'
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
require 'erb'
|
6
|
+
require 'frank-cucumber/gateway'
|
7
|
+
require 'pickle/world'
|
8
|
+
require 'cfpropertylist'
|
9
|
+
|
10
|
+
module FWToolkit
|
11
|
+
module Test
|
12
|
+
module ModelHelpers
|
13
|
+
|
14
|
+
def mimic_server(port=11988)
|
15
|
+
@mimic = Mimic.mimic(:port => port) unless @mimic
|
16
|
+
@mimic
|
17
|
+
end
|
18
|
+
|
19
|
+
# todo: remove default response_content_type
|
20
|
+
def queue_mimic_get_response(path, content, response_content_type = 'application/xml')
|
21
|
+
mimic_server.get(path).returning(content, 200, {'Content-Type' => response_content_type})
|
22
|
+
end
|
23
|
+
|
24
|
+
def fwt_app_exec(method_name, *method_args)
|
25
|
+
operation_map = Frank::Cucumber::Gateway.build_operation_map(method_name,method_args)
|
26
|
+
|
27
|
+
res = frank_server.send_post(
|
28
|
+
'app_exec',
|
29
|
+
:operation => operation_map
|
30
|
+
)
|
31
|
+
|
32
|
+
return Frank::Cucumber::Gateway.evaluate_frankly_response( res, "app_exec #{method_name}" )
|
33
|
+
end
|
34
|
+
|
35
|
+
def fwt_template_response(template_file_name, capture_models = [], options = nil)
|
36
|
+
|
37
|
+
# probably should put some asserts in here
|
38
|
+
# template_file_name should be single if capture_models.count == 0
|
39
|
+
# template_file_name should be plural if capture_models.count > 0
|
40
|
+
unless capture_models.empty?
|
41
|
+
factory, name_or_index = *parse_model(capture_models[0])
|
42
|
+
unless template_file_name
|
43
|
+
template_file_name = factory.pluralize
|
44
|
+
end
|
45
|
+
|
46
|
+
objects = []
|
47
|
+
capture_models.each do |capture_model|
|
48
|
+
objects << model!(capture_model)
|
49
|
+
end
|
50
|
+
|
51
|
+
eval("@#{factory.pluralize} = objects")
|
52
|
+
eval("@#{factory} = objects.first")
|
53
|
+
end
|
54
|
+
|
55
|
+
if options
|
56
|
+
options.each do |option|
|
57
|
+
key, value = option.split(":")
|
58
|
+
eval("@#{key} = value")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
template_file = File.join(Dir.pwd, 'features', 'support', 'templates', "#{template_file_name}.erb")
|
63
|
+
erb = ERB.new(File.open(template_file).read, 0,"")
|
64
|
+
result = erb.result(binding)
|
65
|
+
|
66
|
+
# cleanup
|
67
|
+
unless capture_models.empty?
|
68
|
+
eval("@#{factory.pluralize} = nil")
|
69
|
+
eval("@#{factory} = nil")
|
70
|
+
end
|
71
|
+
|
72
|
+
if options
|
73
|
+
options.each do |option|
|
74
|
+
key, value = option.split(":")
|
75
|
+
eval("@#{key} = nil")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
result
|
80
|
+
end
|
81
|
+
|
82
|
+
def fwt_simulator_applications_dir
|
83
|
+
File.join(Dir.home, 'Library', 'Application Support', 'iPhone Simulator', fwt_ios_sdk, 'Applications')
|
84
|
+
end
|
85
|
+
|
86
|
+
def fwt_kill_simulator
|
87
|
+
`echo 'application "iPhone Simulator" quit' | osascript`
|
88
|
+
end
|
89
|
+
|
90
|
+
def fwt_simulator_reset_data(sdk)
|
91
|
+
fwt_kill_simulator
|
92
|
+
FileUtils.rm_rf(fwt_simulator_applications_dir)
|
93
|
+
end
|
94
|
+
|
95
|
+
def fwt_launch_app(device='iphone')
|
96
|
+
launch_app fwt_app_path, fwt_ios_sdk, device
|
97
|
+
end
|
98
|
+
|
99
|
+
def fwt_ios_sdk
|
100
|
+
raise "IOS_SDK not defined. Please define this in your env.rb, i.e. IOS_SDK='5.1'" unless defined?(IOS_SDK)
|
101
|
+
IOS_SDK
|
102
|
+
end
|
103
|
+
|
104
|
+
def fwt_app_path
|
105
|
+
raise "APP_BUNDLE_PATH not defined. Please define this in your env.rb, i.e. APP_BUNDLE_PATH='File.expand_path( '../../../frankified_build/Frankified.app', __FILE__ )'" unless defined?(APP_BUNDLE_PATH)
|
106
|
+
raise "File defined in APP_BUNDLE_PATH (#{APP_BUNDLE_PATH}) does not exist" unless File.exists?(APP_BUNDLE_PATH)
|
107
|
+
APP_BUNDLE_PATH
|
108
|
+
end
|
109
|
+
|
110
|
+
def fwt_seed_app(model_names=[])
|
111
|
+
objects = model_names.collect{|n| model!(n)}
|
112
|
+
fwt_app_exec("seedCoreData:", objects.to_json)
|
113
|
+
end
|
114
|
+
|
115
|
+
def fwt_set_user_defaults(bundle_identifier, user_defaults)
|
116
|
+
|
117
|
+
app_dir = Dir.entries(fwt_simulator_applications_dir)
|
118
|
+
app_dir.delete "."
|
119
|
+
app_dir.delete ".."
|
120
|
+
plist_file = File.join(fwt_simulator_applications_dir, app_dir.first, 'Library', 'Preferences', "#{bundle_identifier}.plist")
|
121
|
+
|
122
|
+
plist = CFPropertyList::List.new(:file => plist_file)
|
123
|
+
data = CFPropertyList.native_types(plist.value)
|
124
|
+
data.merge! user_defaults
|
125
|
+
plist.value = CFPropertyList.guess(data)
|
126
|
+
plist.save(plist_file, CFPropertyList::List::FORMAT_BINARY)
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
World(FWToolkit::Test::ModelHelpers)
|
134
|
+
|
135
|
+
Before do |scenario|
|
136
|
+
fwt_simulator_reset_data(fwt_ios_sdk)
|
137
|
+
end
|
138
|
+
|
139
|
+
After do |scenario|
|
140
|
+
Mimic.cleanup!
|
141
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# This file is generated by FWToolkit and is covered by the license at
|
2
|
+
#
|
3
|
+
require 'fwtoolkit/test/model_helper.rb'
|
4
|
+
|
5
|
+
Given /^the server responds with(?: "([^\"]*)" for)? path "([^\"]*)" 0 ([^"]*)$/ do |template_file_name, path, variable_name|
|
6
|
+
eval("@#{variable_name} = []")
|
7
|
+
content = fwt_template_response(template_file_name != nil ? template_file_name : variable_name)
|
8
|
+
queue_mimic_get_response(path, content)
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /^the server responds with "([^\"]*)" for path "([^\"]*)" with #{capture_model}(?: with #{capture_fields})?$/ do |template_file_name, path, capture_model, options|
|
12
|
+
content = fwt_template_response(template_file_name, [capture_model], options)
|
13
|
+
queue_mimic_get_response(path, content)
|
14
|
+
end
|
15
|
+
|
16
|
+
Given /^the server responds with "([^\"]*)" for path "([^\"]*)" with #{capture_model} and #{capture_model}(?: with #{capture_fields})?$/ do |template_file_name, path, capture_model_1, capture_model_2, options|
|
17
|
+
content = fwt_template_response(template_file_name, [capture_model_1, capture_model_2], options)
|
18
|
+
queue_mimic_get_response(path, content)
|
19
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module FWToolkit
|
2
|
+
module Test
|
3
|
+
module NetworkHelpers
|
4
|
+
|
5
|
+
#Given /^the network simulates a 3G connection
|
6
|
+
#ipfw add pipe 1 all from any to any out
|
7
|
+
#ipfw add pipe 2 all from any to any in
|
8
|
+
#ipfw pipe 1 config bw 64Kbit/s
|
9
|
+
#ipfw pipe 2 config bw 128Kbit/s
|
10
|
+
|
11
|
+
def ipfw_reset_rule_number
|
12
|
+
@@ipfw_rule_number = 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def ipfw_exit_unless_clean
|
16
|
+
ipfw_list = `sudo ipfw list`
|
17
|
+
if ipfw_list =~ /^(?!65535 allow ip from any to any$).*/
|
18
|
+
puts 'The firewall table contains rules other than the default. Run `sudo ipfw flush` before rerunning cucumber if you don\'t need these rules.'
|
19
|
+
exit -1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def ipfw_deny(host='localhost')
|
24
|
+
`sudo ipfw add #{@@ipfw_rule_number} deny tcp from any to #{host}`
|
25
|
+
@@ipfw_rule_number += 1
|
26
|
+
end
|
27
|
+
|
28
|
+
def ipfw_flush
|
29
|
+
`sudo ipfw flush`
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
World(FWToolkit::Test::NetworkHelpers)
|
35
|
+
|
36
|
+
# Check IPFW because we flush firewall rules at the end of each scenario
|
37
|
+
# If we have anything but the default rule, warn the user and exit
|
38
|
+
Before do
|
39
|
+
ipfw_exit_unless_clean
|
40
|
+
ipfw_reset_rule_number
|
41
|
+
end
|
42
|
+
|
43
|
+
After do
|
44
|
+
ipfw_flush
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Steps
|
49
|
+
#
|
50
|
+
Given /^the network has no connection$/ do
|
51
|
+
ipfw_deny
|
52
|
+
end
|
53
|
+
|
54
|
+
Then /^the network is returned to its original state$/ do
|
55
|
+
ipfw_flush
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# this file generated by script/generate pickle
|
2
|
+
require 'pickle/world'
|
3
|
+
|
4
|
+
# create a model
|
5
|
+
Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
|
6
|
+
create_model(name, fields)
|
7
|
+
end
|
8
|
+
|
9
|
+
# create n models
|
10
|
+
Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
11
|
+
count.to_i.times { create_model(plural_factory.singularize, fields) }
|
12
|
+
end
|
13
|
+
|
14
|
+
# create models from a table
|
15
|
+
Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
|
16
|
+
create_models_from_table(plural_factory, table)
|
17
|
+
end
|
18
|
+
|
19
|
+
# find a model
|
20
|
+
Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
|
21
|
+
find_model!(name, fields)
|
22
|
+
end
|
23
|
+
|
24
|
+
# not find a model
|
25
|
+
Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
|
26
|
+
find_model(name, fields).should be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
# find models with a table
|
30
|
+
Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
|
31
|
+
find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
|
32
|
+
end
|
33
|
+
|
34
|
+
# find exactly n models
|
35
|
+
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
36
|
+
find_models(plural_factory.singularize, fields).size.should == count.to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
# assert equality of models
|
40
|
+
Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
|
41
|
+
model!(a).should == model!(b)
|
42
|
+
end
|
43
|
+
|
44
|
+
# assert model is in another model's has_many assoc
|
45
|
+
Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
46
|
+
model!(owner).send(association).should include(model!(target))
|
47
|
+
end
|
48
|
+
|
49
|
+
# assert model is not in another model's has_many assoc
|
50
|
+
Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
51
|
+
model!(owner).send(association).should_not include(model!(target))
|
52
|
+
end
|
53
|
+
|
54
|
+
# assert model is another model's has_one/belongs_to assoc
|
55
|
+
Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
56
|
+
model!(owner).send(association).should == model!(target)
|
57
|
+
end
|
58
|
+
|
59
|
+
# assert model is not another model's has_one/belongs_to assoc
|
60
|
+
Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
61
|
+
model!(owner).send(association).should_not == model!(target)
|
62
|
+
end
|
63
|
+
|
64
|
+
# assert model.predicate?
|
65
|
+
Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
66
|
+
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
67
|
+
model!(name).should send("have_#{predicate.gsub(' ', '_')}")
|
68
|
+
else
|
69
|
+
model!(name).should send("be_#{predicate.gsub(' ', '_')}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# assert not model.predicate?
|
74
|
+
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
75
|
+
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
76
|
+
model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
|
77
|
+
else
|
78
|
+
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# model.attribute.should eql(value)
|
83
|
+
# model.attribute.should_not eql(value)
|
84
|
+
Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
|
85
|
+
actual_value = model(name).send(attribute)
|
86
|
+
expectation = expectation.gsub(' ', '_')
|
87
|
+
|
88
|
+
case expected
|
89
|
+
when 'nil', 'true', 'false'
|
90
|
+
actual_value.send(expectation, send("be_#{expected}"))
|
91
|
+
when /^[+-]?[0-9_]+(\.\d+)?$/
|
92
|
+
actual_value.send(expectation, eql(expected.to_f))
|
93
|
+
else
|
94
|
+
actual_value.to_s.send(expectation, eql(eval(expected)))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# assert size of association
|
99
|
+
Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
|
100
|
+
model!(name).send(association).size.should == size.to_i
|
101
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FWToolkit
|
2
|
+
module Test
|
3
|
+
module UIHelpers
|
4
|
+
def fwt_set_textfield_text(text_field_mark, text_to_type)
|
5
|
+
text_field_selector = "textField marked:'#{text_field_mark}'"
|
6
|
+
if element_exists(text_field_selector)
|
7
|
+
touch( text_field_selector )
|
8
|
+
else
|
9
|
+
raise "Could not find [#{text_field_mark}], it does not exist."
|
10
|
+
end
|
11
|
+
|
12
|
+
frankly_map( text_field_selector, 'becomeFirstResponder' )
|
13
|
+
frankly_map( text_field_selector, 'setText:', text_to_type )
|
14
|
+
frankly_map( text_field_selector, 'endEditing:', true )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
World(FWToolkit::Test::UIHelpers)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file is generated by FWToolkit and is covered by the license at
|
2
|
+
#
|
3
|
+
|
4
|
+
require 'fwtoolkit/test/ui_helper.rb'
|
5
|
+
|
6
|
+
When /^I touch the "(.*?)" button on the alert view$/ do |arg1|
|
7
|
+
touch("view:'UIAlertButton' marked:'#{arg1}'")
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I type "([^\"]*)"$/ do |cmd|
|
11
|
+
type_into_keyboard(cmd, :append_return => false)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^"([^\"]*)" is disabled$/ do |mark|
|
15
|
+
raise "#{mark} is not disabled" unless frankly_map("view marked:'#{mark}'", 'isEnabled')
|
16
|
+
end
|
17
|
+
|
data/lib/fwtoolkit.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'thor'
|
3
|
+
require 'rexml/document'
|
4
|
+
require 'core_data'
|
5
|
+
|
6
|
+
require 'fwtoolkit/version'
|
7
|
+
require 'fwtoolkit/test/frank_model'
|
8
|
+
|
9
|
+
module FWToolkit
|
10
|
+
def self.root
|
11
|
+
File.expand_path '../..', __FILE__
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class String
|
16
|
+
def ruby_format
|
17
|
+
self.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
18
|
+
end
|
19
|
+
def ruby_format!
|
20
|
+
replace ruby_format
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Generated code
|
2
|
+
class <%= class_name(@model) %> < FWToolkit::Test::FrankModel
|
3
|
+
# attributes
|
4
|
+
attr_accessor <%= @model.attributes.map{|p| ":#{p.name.ruby_format}"}.join(', ') %>
|
5
|
+
# relationships
|
6
|
+
attr_reader <%= @model.relationships.select{|r| r.inverse != nil}.map{|r| ":#{r.name.ruby_format}"}.join(', ') %>
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@core_data_entity = '<%= @model.name %>'
|
10
|
+
end
|
11
|
+
|
12
|
+
# inverse relationship setters
|
13
|
+
<% @model.relationships.select{|r| not r.to_many? and r.inverse}.each do |r| %><% name = r.name.ruby_format %>
|
14
|
+
def <%= name %>=(_<%= name %>)
|
15
|
+
@<%= name %> = _<%= name %>
|
16
|
+
unless @<%= name %>.<%= r.inverse.ruby_format %>
|
17
|
+
@<%= name %>.<%= r.inverse.ruby_format %> = []
|
18
|
+
end
|
19
|
+
@<%= name %>.<%= r.inverse.ruby_format %> << self
|
20
|
+
end
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
# lazy initialisation of to_many relationships
|
24
|
+
<% @model.relationships.select{|r| r.to_many? and r.inverse}.each do |r| %><% name = r.name.ruby_format %>
|
25
|
+
def <%= name %>
|
26
|
+
@<%= name %> ||= []
|
27
|
+
end
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
def as_json(options={})
|
31
|
+
{'<%= @model.name %>' => {<%= @model.attributes.map {|p| ":#{p.name} => @#{p.name.ruby_format}"}.join(', ') %>}}
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fwtoolkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matt Brooke-Smith
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cucumber
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: aruba
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: ruby-debug19
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: thor
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.14.6
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.14.6
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: core_data
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.0.4
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.0.4
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: factory_girl
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pickle
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.4.10
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - '='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.4.10
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: activesupport
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - '='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 3.2.6
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - '='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 3.2.6
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: mimic
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - '='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.4.3
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - '='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.4.3
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: frank-cucumber
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - '='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.9.5.pre6
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - '='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.9.5.pre6
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: CFPropertyList
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - '='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: 2.1.1
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - '='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 2.1.1
|
190
|
+
description: ''
|
191
|
+
email:
|
192
|
+
- matt@futureworkshops.com
|
193
|
+
executables:
|
194
|
+
- fwt
|
195
|
+
extensions: []
|
196
|
+
extra_rdoc_files: []
|
197
|
+
files:
|
198
|
+
- bin/fwt
|
199
|
+
- lib/fwtoolkit.rb
|
200
|
+
- lib/fwtoolkit/cli.rb
|
201
|
+
- lib/fwtoolkit/test/frank_model.rb
|
202
|
+
- lib/fwtoolkit/test/misc_steps.rb
|
203
|
+
- lib/fwtoolkit/test/model_helper.rb
|
204
|
+
- lib/fwtoolkit/test/model_steps.rb
|
205
|
+
- lib/fwtoolkit/test/network_steps.rb
|
206
|
+
- lib/fwtoolkit/test/pickle_steps.rb
|
207
|
+
- lib/fwtoolkit/test/ui_helper.rb
|
208
|
+
- lib/fwtoolkit/test/ui_steps.rb
|
209
|
+
- lib/fwtoolkit/version.rb
|
210
|
+
- templates/models/factories.rb.erb
|
211
|
+
- templates/models/model.rb.erb
|
212
|
+
homepage: ''
|
213
|
+
licenses: []
|
214
|
+
post_install_message:
|
215
|
+
rdoc_options: []
|
216
|
+
require_paths:
|
217
|
+
- lib
|
218
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
219
|
+
none: false
|
220
|
+
requirements:
|
221
|
+
- - ! '>='
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
226
|
+
requirements:
|
227
|
+
- - ! '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
requirements: []
|
231
|
+
rubyforge_project:
|
232
|
+
rubygems_version: 1.8.24
|
233
|
+
signing_key:
|
234
|
+
specification_version: 3
|
235
|
+
summary: ''
|
236
|
+
test_files: []
|