_rubyapp 0.0.3
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.
- data/.gitignore +6 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.md +0 -0
- data/Rakefile +65 -0
- data/bin/rubyapp +78 -0
- data/features/breadcrumbs.feature +10 -0
- data/features/content.feature +15 -0
- data/features/default.feature +9 -0
- data/features/exception.feature +50 -0
- data/features/input.feature +12 -0
- data/features/list.feature +12 -0
- data/features/step_definitions/default_macros.rb +15 -0
- data/features/step_definitions/default_steps.rb +36 -0
- data/features/support/env.rb +8 -0
- data/lib/rubyapp.rb +1 -0
- data/lib/rubyapp/config.ru +22 -0
- data/lib/rubyapp/element.css.haml +3 -0
- data/lib/rubyapp/element.html.haml +2 -0
- data/lib/rubyapp/element.js.haml +3 -0
- data/lib/rubyapp/element.rb +100 -0
- data/lib/rubyapp/elements/button.css.haml +5 -0
- data/lib/rubyapp/elements/button.html.haml +3 -0
- data/lib/rubyapp/elements/button.rb +19 -0
- data/lib/rubyapp/elements/click.js.haml +9 -0
- data/lib/rubyapp/elements/click.rb +44 -0
- data/lib/rubyapp/elements/content.css.haml +12 -0
- data/lib/rubyapp/elements/content.html.haml +3 -0
- data/lib/rubyapp/elements/content.js.haml +9 -0
- data/lib/rubyapp/elements/content.rb +51 -0
- data/lib/rubyapp/elements/dialog.css.haml +30 -0
- data/lib/rubyapp/elements/dialog.html.haml +8 -0
- data/lib/rubyapp/elements/dialog.rb +58 -0
- data/lib/rubyapp/elements/dialogs/exception_dialog.css.haml +4 -0
- data/lib/rubyapp/elements/dialogs/exception_dialog.html.haml +8 -0
- data/lib/rubyapp/elements/dialogs/exception_dialog.rb +32 -0
- data/lib/rubyapp/elements/dialogs/message_dialog.html.haml +8 -0
- data/lib/rubyapp/elements/dialogs/message_dialog.rb +33 -0
- data/lib/rubyapp/elements/exception_element.css.haml +12 -0
- data/lib/rubyapp/elements/exception_element.html.haml +6 -0
- data/lib/rubyapp/elements/exception_element.rb +19 -0
- data/lib/rubyapp/elements/input.css.haml +5 -0
- data/lib/rubyapp/elements/input.html.haml +2 -0
- data/lib/rubyapp/elements/input.js.haml +8 -0
- data/lib/rubyapp/elements/input.rb +55 -0
- data/lib/rubyapp/elements/link.css.haml +5 -0
- data/lib/rubyapp/elements/link.html.haml +3 -0
- data/lib/rubyapp/elements/link.rb +19 -0
- data/lib/rubyapp/elements/list.css.haml +33 -0
- data/lib/rubyapp/elements/list.html.haml +11 -0
- data/lib/rubyapp/elements/list.js.haml +9 -0
- data/lib/rubyapp/elements/list.rb +60 -0
- data/lib/rubyapp/elements/mobile/ios/page.html.haml +36 -0
- data/lib/rubyapp/elements/mobile/ios/page.rb +29 -0
- data/lib/rubyapp/elements/navigation/breadcrumbs.css.haml +24 -0
- data/lib/rubyapp/elements/navigation/breadcrumbs.html.haml +16 -0
- data/lib/rubyapp/elements/navigation/breadcrumbs.js.haml +9 -0
- data/lib/rubyapp/elements/navigation/breadcrumbs.rb +49 -0
- data/lib/rubyapp/elements/navigation/page_link.css.haml +12 -0
- data/lib/rubyapp/elements/navigation/page_link.html.haml +8 -0
- data/lib/rubyapp/elements/navigation/page_link.js.haml +9 -0
- data/lib/rubyapp/elements/navigation/page_link.rb +56 -0
- data/lib/rubyapp/elements/navigation/page_menu.css.haml +36 -0
- data/lib/rubyapp/elements/navigation/page_menu.html.haml +11 -0
- data/lib/rubyapp/elements/navigation/page_menu.js.haml +9 -0
- data/lib/rubyapp/elements/navigation/page_menu.rb +57 -0
- data/lib/rubyapp/elements/page.css.haml +50 -0
- data/lib/rubyapp/elements/page.html.haml +30 -0
- data/lib/rubyapp/elements/page.js.haml +52 -0
- data/lib/rubyapp/elements/page.rb +60 -0
- data/lib/rubyapp/elements/pages/default_page.css.haml +4 -0
- data/lib/rubyapp/elements/pages/default_page.html.haml +5 -0
- data/lib/rubyapp/elements/pages/default_page.js.haml +4 -0
- data/lib/rubyapp/elements/pages/default_page.rb +33 -0
- data/lib/rubyapp/elements/pages/exception_page.css.haml +4 -0
- data/lib/rubyapp/elements/pages/exception_page.html.haml +3 -0
- data/lib/rubyapp/elements/pages/exception_page.rb +27 -0
- data/lib/rubyapp/elements/pages/test_pages/alphabet_list.html.haml +3 -0
- data/lib/rubyapp/elements/pages/test_pages/base_test_page.css.haml +17 -0
- data/lib/rubyapp/elements/pages/test_pages/base_test_page.html.haml +6 -0
- data/lib/rubyapp/elements/pages/test_pages/base_test_page.js.haml +4 -0
- data/lib/rubyapp/elements/pages/test_pages/base_test_page.rb +41 -0
- data/lib/rubyapp/elements/pages/test_pages/breadcrumbs_test_page.html.haml +4 -0
- data/lib/rubyapp/elements/pages/test_pages/breadcrumbs_test_page.rb +36 -0
- data/lib/rubyapp/elements/pages/test_pages/content_test_page.css.haml +5 -0
- data/lib/rubyapp/elements/pages/test_pages/content_test_page.html.haml +6 -0
- data/lib/rubyapp/elements/pages/test_pages/content_test_page.js.haml +4 -0
- data/lib/rubyapp/elements/pages/test_pages/content_test_page.rb +40 -0
- data/lib/rubyapp/elements/pages/test_pages/default_test_page.html.haml +3 -0
- data/lib/rubyapp/elements/pages/test_pages/default_test_page.rb +26 -0
- data/lib/rubyapp/elements/pages/test_pages/exception_content.html.haml +8 -0
- data/lib/rubyapp/elements/pages/test_pages/exception_test_page.css.haml +9 -0
- data/lib/rubyapp/elements/pages/test_pages/exception_test_page.html.haml +21 -0
- data/lib/rubyapp/elements/pages/test_pages/exception_test_page.rb +65 -0
- data/lib/rubyapp/elements/pages/test_pages/input_test_page.css.haml +5 -0
- data/lib/rubyapp/elements/pages/test_pages/input_test_page.html.haml +7 -0
- data/lib/rubyapp/elements/pages/test_pages/input_test_page.js.haml +4 -0
- data/lib/rubyapp/elements/pages/test_pages/input_test_page.rb +40 -0
- data/lib/rubyapp/elements/pages/test_pages/list_test_page.css.haml +5 -0
- data/lib/rubyapp/elements/pages/test_pages/list_test_page.html.haml +7 -0
- data/lib/rubyapp/elements/pages/test_pages/list_test_page.js.haml +4 -0
- data/lib/rubyapp/elements/pages/test_pages/list_test_page.rb +56 -0
- data/lib/rubyapp/mixins/duration.rb +18 -0
- data/lib/rubyapp/mixins/render.rb +69 -0
- data/lib/rubyapp/mixins/route.rb +40 -0
- data/lib/rubyapp/mixins/template.rb +38 -0
- data/lib/rubyapp/mixins/translate.rb +47 -0
- data/lib/rubyapp/rack/duration.rb +32 -0
- data/lib/rubyapp/rack/locale.rb +32 -0
- data/lib/rubyapp/rack/logger.rb +30 -0
- data/lib/rubyapp/rack/route.rb +97 -0
- data/lib/rubyapp/rack/session.rb +32 -0
- data/lib/rubyapp/resources/application.manifest +0 -0
- data/lib/rubyapp/resources/favicon.ico +0 -0
- data/lib/rubyapp/resources/mobile/ios/icon.png +0 -0
- data/lib/rubyapp/resources/mobile/ios/icon.psd +0 -0
- data/lib/rubyapp/resources/mobile/ios/start.png +0 -0
- data/lib/rubyapp/resources/mobile/ios/start.psd +0 -0
- data/lib/rubyapp/session.rb +44 -0
- data/lib/rubyapp/template/Gemfile +3 -0
- data/lib/rubyapp/template/Rakefile +25 -0
- data/lib/rubyapp/template/config.ru +22 -0
- data/lib/rubyapp/template/elements/pages/default_page.css.haml +13 -0
- data/lib/rubyapp/template/elements/pages/default_page.html.haml +6 -0
- data/lib/rubyapp/template/elements/pages/default_page.rb +22 -0
- data/lib/rubyapp/template/resources/application.manifest +0 -0
- data/lib/rubyapp/template/resources/favicon.ico +0 -0
- data/lib/rubyapp/template/resources/mobile/ios/icon.png +0 -0
- data/lib/rubyapp/template/resources/mobile/ios/start.png +0 -0
- data/lib/rubyapp/template/session.rb +17 -0
- data/lib/rubyapp/template/translations/en.yml +5 -0
- data/lib/rubyapp/translations/ar.yml +46 -0
- data/lib/rubyapp/translations/bg.yml +46 -0
- data/lib/rubyapp/translations/ca.yml +46 -0
- data/lib/rubyapp/translations/cs.yml +46 -0
- data/lib/rubyapp/translations/da.yml +46 -0
- data/lib/rubyapp/translations/de.yml +46 -0
- data/lib/rubyapp/translations/el.yml +46 -0
- data/lib/rubyapp/translations/en.bak +44 -0
- data/lib/rubyapp/translations/en.yml +48 -0
- data/lib/rubyapp/translations/es.yml +46 -0
- data/lib/rubyapp/translations/et.yml +46 -0
- data/lib/rubyapp/translations/fa.yml +46 -0
- data/lib/rubyapp/translations/fi.yml +46 -0
- data/lib/rubyapp/translations/fr.yml +46 -0
- data/lib/rubyapp/translations/gl.yml +46 -0
- data/lib/rubyapp/translations/hi.yml +46 -0
- data/lib/rubyapp/translations/hr.yml +46 -0
- data/lib/rubyapp/translations/ht.yml +46 -0
- data/lib/rubyapp/translations/hu.yml +46 -0
- data/lib/rubyapp/translations/id.yml +46 -0
- data/lib/rubyapp/translations/it.yml +46 -0
- data/lib/rubyapp/translations/iw.yml +46 -0
- data/lib/rubyapp/translations/ja.yml +46 -0
- data/lib/rubyapp/translations/ko.yml +46 -0
- data/lib/rubyapp/translations/lt.yml +46 -0
- data/lib/rubyapp/translations/lv.yml +46 -0
- data/lib/rubyapp/translations/mt.yml +46 -0
- data/lib/rubyapp/translations/nl.yml +46 -0
- data/lib/rubyapp/translations/no.yml +47 -0
- data/lib/rubyapp/translations/pl.yml +46 -0
- data/lib/rubyapp/translations/pt-PT.yml +46 -0
- data/lib/rubyapp/translations/ro.yml +46 -0
- data/lib/rubyapp/translations/ru.yml +46 -0
- data/lib/rubyapp/translations/sk.yml +46 -0
- data/lib/rubyapp/translations/sl.yml +46 -0
- data/lib/rubyapp/translations/sq.yml +46 -0
- data/lib/rubyapp/translations/sr.yml +46 -0
- data/lib/rubyapp/translations/sv.yml +46 -0
- data/lib/rubyapp/translations/th.yml +46 -0
- data/lib/rubyapp/translations/tl.yml +46 -0
- data/lib/rubyapp/translations/tr.yml +46 -0
- data/lib/rubyapp/translations/uk.yml +46 -0
- data/lib/rubyapp/translations/vi.yml +46 -0
- data/lib/rubyapp/translations/zh-CN.yml +46 -0
- data/lib/rubyapp/translations/zh-TW.yml +46 -0
- data/lib/rubyapp/translations/zh.yml +46 -0
- data/lib/rubyapp/version.rb +3 -0
- data/rubyapp.gemspec +36 -0
- data/spec/element_spec.rb +20 -0
- data/spec/mixins/duration_spec.rb +17 -0
- data/spec/mixins/render_spec.rb +190 -0
- data/spec/mixins/route_spec.rb +60 -0
- data/spec/mixins/template_spec.rb +78 -0
- data/spec/mixins/test_a.css.haml +3 -0
- data/spec/mixins/test_a.html.haml +3 -0
- data/spec/mixins/test_a.js.haml +3 -0
- data/spec/mixins/test_b.css.haml +4 -0
- data/spec/mixins/test_b.html.haml +3 -0
- data/spec/mixins/test_b.js.haml +4 -0
- data/spec/mixins/test_c.css.haml +4 -0
- data/spec/mixins/test_c.html.haml +2 -0
- data/spec/mixins/test_c.js.haml +4 -0
- data/spec/mixins/test_e.html.haml +2 -0
- data/spec/mixins/test_f.html.haml +2 -0
- data/spec/mixins/test_g.css.haml +4 -0
- metadata +540 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm ruby-1.8.7-p334@RubyApp
|
data/Gemfile
ADDED
data/README.md
ADDED
|
File without changes
|
data/Rakefile
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
|
|
5
|
+
require 'rake'
|
|
6
|
+
|
|
7
|
+
namespace :gems do
|
|
8
|
+
|
|
9
|
+
desc 'Install required gems'
|
|
10
|
+
task :install do |task|
|
|
11
|
+
system 'bundle install'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
namespace :test do
|
|
17
|
+
|
|
18
|
+
desc 'Run feature tests for the given feature file or all features files if no argument is provided'
|
|
19
|
+
task :features, :file do |task, arguments|
|
|
20
|
+
system("bundle exec cucumber --format pretty #{arguments.file}")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc 'Run RSpec tests'
|
|
24
|
+
task :specs, :file, :line do |task, arguments|
|
|
25
|
+
if arguments.file
|
|
26
|
+
if arguments.line
|
|
27
|
+
system("bundle exec rspec #{arguments.file} --line_number=#{arguments.line} --format=documentation --colour")
|
|
28
|
+
else
|
|
29
|
+
system("bundle exec rspec #{arguments.file} --format=documentation --colour")
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
system("bundle exec rspec spec/ --format=documentation --colour")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc 'Run all tests'
|
|
37
|
+
task :all => ['test:specs',
|
|
38
|
+
'test:features']
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc 'Translate the application'
|
|
43
|
+
task :translate do |task|\
|
|
44
|
+
require 'ftools'
|
|
45
|
+
File.copy('./lib/rubyapp/translations/en.yml', './lib/rubyapp/translations/en.bak')
|
|
46
|
+
system 'bundle exec babelphish -y ./lib/rubyapp/translations/en.yml -o'
|
|
47
|
+
Dir.glob('./lib/rubyapp/translations/*.yml').each do |file|
|
|
48
|
+
unless File.basename(file) == 'en.yml'
|
|
49
|
+
puts("Substituting patterns in #{file}")
|
|
50
|
+
system "sed 's/% 1/ %1/' < #{file} | sed 's/% 2/ %2/' | sed 's/1%/%1/' | sed 's/2%/%2/' > #{file}.out"
|
|
51
|
+
File.delete(file)
|
|
52
|
+
File.rename("#{file}.out", file)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
desc 'Run the application'
|
|
58
|
+
task :run do |task|
|
|
59
|
+
system 'clear; bundle exec rackup lib/rubyapp/config.ru'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
desc 'Monitor the log'
|
|
63
|
+
task :monitor do |task|
|
|
64
|
+
system 'rm log/*; touch log/application.log; clear; tail -f log/application.log'
|
|
65
|
+
end
|
data/bin/rubyapp
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
require 'term/ansicolor'
|
|
7
|
+
extend Term::ANSIColor
|
|
8
|
+
|
|
9
|
+
require 'rubyapp'
|
|
10
|
+
|
|
11
|
+
def usage
|
|
12
|
+
<<-USAGE
|
|
13
|
+
usage: bundle exec rubyapp <command> <arguments>
|
|
14
|
+
|
|
15
|
+
Available commands include:
|
|
16
|
+
create_application Create a basic application in the folder <arguments>.
|
|
17
|
+
create_page Create a baisc page consisting of .rb, .html, .css. and .js files
|
|
18
|
+
|
|
19
|
+
USAGE
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_folder(application, path)
|
|
23
|
+
print "Creating #{path.sub(FileUtils.pwd, '.')} ... "
|
|
24
|
+
if File.exists?(path)
|
|
25
|
+
puts "#{bold}#{red}exists#{reset}"
|
|
26
|
+
else
|
|
27
|
+
FileUtils.mkdir(path)
|
|
28
|
+
puts "#{bold}#{green}created#{reset}"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def copy_file(application, source_path, destination_path)
|
|
33
|
+
destination_file = File.join(destination_path, File.basename(source_path))
|
|
34
|
+
print "Creating #{destination_file.sub(FileUtils.pwd, '.')} ... "
|
|
35
|
+
if File.exists?(destination_file)
|
|
36
|
+
puts "#{bold}#{red}exists#{reset}"
|
|
37
|
+
else
|
|
38
|
+
FileUtils.cp(source_path, destination_path)
|
|
39
|
+
system "sed 's/\$APPLICATION_DOWNCODE/#{downcode(application)}/' < '#{destination_file}' | sed 's/\$APPLICATION_UPCODE/#{upcode(application)}/' > '#{destination_file}.out'"
|
|
40
|
+
FileUtils.rm(destination_file)
|
|
41
|
+
FileUtils.mv("#{destination_file}.out", destination_file)
|
|
42
|
+
puts "#{bold}#{green}created#{reset}"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def copy_folder(application, source_path, destination_path)
|
|
47
|
+
create_folder application, destination_path
|
|
48
|
+
Dir.new(source_path).each do |item|
|
|
49
|
+
if File.directory?(File.join(source_path, item))
|
|
50
|
+
copy_folder application, File.join(source_path, item), File.join(destination_path, File.basename(item)) unless item.start_with?('.')
|
|
51
|
+
else
|
|
52
|
+
copy_file application, File.join(source_path, item), destination_path unless item.start_with?('.')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def downcode(value)
|
|
58
|
+
|
|
59
|
+
value = value.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
|
60
|
+
value = value.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
|
61
|
+
value = value.tr("-", "_")
|
|
62
|
+
value.downcase
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def upcode(value)
|
|
67
|
+
value
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
case $*[0].downcase
|
|
71
|
+
when 'create_application'
|
|
72
|
+
application = $*[1]
|
|
73
|
+
folder = File.join(FileUtils.pwd, application)
|
|
74
|
+
copy_folder application, File.join(File.dirname(__FILE__), %w[.. lib rubyapp template]), folder
|
|
75
|
+
else
|
|
76
|
+
puts "Blank or unrecognized command '#{$*[0].downcase}'"
|
|
77
|
+
puts usage
|
|
78
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Feature: Interact with the breadcrumbs
|
|
2
|
+
|
|
3
|
+
Scenario: View the breadcrumbs test page
|
|
4
|
+
Given I go to the test pages
|
|
5
|
+
When I click "Breadcrumbs Test Page"
|
|
6
|
+
Then I should see "Add"
|
|
7
|
+
When I click "Add"
|
|
8
|
+
And I click "Breadcrumbs Test Page"
|
|
9
|
+
Then I should see "Add"
|
|
10
|
+
And I quit
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Feature: Clicking a link in content
|
|
2
|
+
|
|
3
|
+
Scenario: Clicking a link in content
|
|
4
|
+
Given I go to the test pages
|
|
5
|
+
When I click "Content Test Page"
|
|
6
|
+
Then I should see "Click this one to go somewhere and this other one to go somewhere else."
|
|
7
|
+
When I click "this one"
|
|
8
|
+
Then I should see "You selected ..."
|
|
9
|
+
And I should see "google"
|
|
10
|
+
When I click "Close"
|
|
11
|
+
And I click "this other one"
|
|
12
|
+
Then I should see "You selected ..."
|
|
13
|
+
And I should see "yahoo"
|
|
14
|
+
When I click "Close"
|
|
15
|
+
And I quit
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Feature: View a variety of exception handling pages
|
|
2
|
+
|
|
3
|
+
Scenario: View the exception test page
|
|
4
|
+
Given I go to the test pages
|
|
5
|
+
When I click "Exception Test Page"
|
|
6
|
+
Then I should see "Displayed 1 times"
|
|
7
|
+
When I refresh the page
|
|
8
|
+
Then I should see "Displayed 2 times"
|
|
9
|
+
When I refresh the page
|
|
10
|
+
Then I should see "Displayed 3 times"
|
|
11
|
+
When I refresh the page
|
|
12
|
+
Then I should see "Displayed 4 times"
|
|
13
|
+
When I refresh the page
|
|
14
|
+
Then I should see "Displayed 5 times"
|
|
15
|
+
When I refresh the page
|
|
16
|
+
Then I should see "RuntimeError"
|
|
17
|
+
And I should see "Displayed more than 5 times"
|
|
18
|
+
When I refresh the page
|
|
19
|
+
And I refresh the page
|
|
20
|
+
Then I should see "Displayed 2 times"
|
|
21
|
+
And I quit
|
|
22
|
+
|
|
23
|
+
Scenario: View the update exception test page
|
|
24
|
+
Given I go to the test pages
|
|
25
|
+
When I click "Exception Test Page"
|
|
26
|
+
Then I should see "Updated 1 times"
|
|
27
|
+
When I click "Update"
|
|
28
|
+
Then I should see "Updated 2 times"
|
|
29
|
+
When I click "Update"
|
|
30
|
+
Then I should see "Updated 3 times"
|
|
31
|
+
When I click "Update"
|
|
32
|
+
Then I should see "Updated 4 times"
|
|
33
|
+
When I click "Update"
|
|
34
|
+
Then I should see "Updated 5 times"
|
|
35
|
+
When I click "Update"
|
|
36
|
+
Then I should see "RuntimeError"
|
|
37
|
+
And I should see "Updated more than 5 times"
|
|
38
|
+
When I refresh the page
|
|
39
|
+
Then I should see "Updated 1 times"
|
|
40
|
+
And I quit
|
|
41
|
+
|
|
42
|
+
Scenario: View the dialog exception test page
|
|
43
|
+
Given I go to the test pages
|
|
44
|
+
When I click "Exception Test Page"
|
|
45
|
+
Then I should see "Show dialog"
|
|
46
|
+
When I click "Show dialog"
|
|
47
|
+
Then I should see "Dialog exception"
|
|
48
|
+
When I click "Close"
|
|
49
|
+
Then I should not see "Dialog exception"
|
|
50
|
+
And I quit
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: View a variety of input elements
|
|
2
|
+
|
|
3
|
+
Scenario: View the text input element
|
|
4
|
+
Given I go to the test pages
|
|
5
|
+
When I click "Input Test Page"
|
|
6
|
+
Then I should see "Enter some text below"
|
|
7
|
+
And I fill in "Text:" with "Some value" and I press enter
|
|
8
|
+
Then I should see "You entered ..."
|
|
9
|
+
And I should see "Some value"
|
|
10
|
+
When I click "Close"
|
|
11
|
+
Then I should not see "You entered ..."
|
|
12
|
+
And I quit
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Selecting from a list
|
|
2
|
+
|
|
3
|
+
Scenario: Selected from a list
|
|
4
|
+
Given I go to the test pages
|
|
5
|
+
When I click "List Test Page"
|
|
6
|
+
Then I should see "Select an item below"
|
|
7
|
+
When I click "C, See"
|
|
8
|
+
Then I should see "You selected ..."
|
|
9
|
+
And I should see "C, See"
|
|
10
|
+
When I click "Close"
|
|
11
|
+
Then I should not see "You selected ..."
|
|
12
|
+
And I quit
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Given /^I go to the test pages$/ do
|
|
2
|
+
steps %Q{
|
|
3
|
+
Given I am viewing "/"
|
|
4
|
+
Then I should see "Click here to access the test pages."
|
|
5
|
+
When I click "here"
|
|
6
|
+
Then I should see "Click one of the test pages on the left."
|
|
7
|
+
}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Then /^I quit$/ do
|
|
11
|
+
steps %Q{
|
|
12
|
+
When I click "Quit"
|
|
13
|
+
Then I should see "Click here to access the test pages."
|
|
14
|
+
}
|
|
15
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Given /^I am viewing "([^"]*)"$/ do |url|
|
|
2
|
+
visit(url)
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
When /^I refresh the page$/ do
|
|
6
|
+
visit(current_path)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then /^I should (not )?see "([^"]*)"$/ do |negative, text|
|
|
10
|
+
unless negative
|
|
11
|
+
page.should have_content(text)
|
|
12
|
+
else
|
|
13
|
+
page.should_not have_content(text)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
When /^I click "([^"]*)"$/ do |text|
|
|
18
|
+
click_on(text)
|
|
19
|
+
sleep 2
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
When /^I fill in "([^"]*)" with "([^"]*)"( and I press enter)?$/ do |field, value, enter|
|
|
23
|
+
fill_in(field, :with => value)
|
|
24
|
+
if enter
|
|
25
|
+
find_field(field).native.send_key(:enter)
|
|
26
|
+
sleep 2
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Then /^show me the page$/ do
|
|
31
|
+
save_and_open_page
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Then /^I wait "([^"]*)" seconds$/ do |interval|
|
|
35
|
+
sleep(interval.to_f)
|
|
36
|
+
end
|
data/lib/rubyapp.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "rubyapp/version"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
require 'rack'
|
|
5
|
+
|
|
6
|
+
require File.join(File.dirname(__FILE__), %w[rack logger])
|
|
7
|
+
require File.join(File.dirname(__FILE__), %w[rack locale])
|
|
8
|
+
require File.join(File.dirname(__FILE__), %w[rack duration])
|
|
9
|
+
require File.join(File.dirname(__FILE__), %w[rack route])
|
|
10
|
+
require File.join(File.dirname(__FILE__), %w[rack session])
|
|
11
|
+
require File.join(File.dirname(__FILE__), %w[session])
|
|
12
|
+
|
|
13
|
+
use Rack::ShowExceptions
|
|
14
|
+
use Rack::Session::Pool
|
|
15
|
+
use Rack::Reloader
|
|
16
|
+
use Rack::ContentLength
|
|
17
|
+
use Rack::Static, :urls => ['/favicon.ico', '/application.manifest', '/mobile'], :root => 'resources'
|
|
18
|
+
use RubyApp::Rack::Duration
|
|
19
|
+
use RubyApp::Rack::Logger
|
|
20
|
+
use RubyApp::Rack::Session, RubyApp::Session
|
|
21
|
+
use RubyApp::Rack::Locale
|
|
22
|
+
run RubyApp::Rack::Route.new
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
|
|
4
|
+
require 'ruby-event'
|
|
5
|
+
|
|
6
|
+
module RubyApp
|
|
7
|
+
|
|
8
|
+
class Element
|
|
9
|
+
|
|
10
|
+
class Event
|
|
11
|
+
attr_reader :source
|
|
12
|
+
|
|
13
|
+
def initialize(data = nil)
|
|
14
|
+
@source = data ? RubyApp::Element.get_element(data['source_id']) : nil
|
|
15
|
+
@statements = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def alert(message)
|
|
19
|
+
execute("RubyApp.alert('#{message.tr('`', '\"').tr('\'','\"')}');")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def refresh
|
|
23
|
+
execute("RubyApp.refresh();")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def show_dialog(dialog)
|
|
27
|
+
execute("RubyApp.showDialog('#{dialog.element_id}');")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def hide_dialog(dialog)
|
|
31
|
+
execute("RubyApp.hideDialog('#{dialog.element_id}');")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def update(element)
|
|
35
|
+
execute("RubyApp.update('#{element.element_id}');")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def execute(statement)
|
|
39
|
+
@statements << statement
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.from_hash(data)
|
|
43
|
+
eval(data['_class']).new(data)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_hash
|
|
47
|
+
{
|
|
48
|
+
'_class' => self.class.to_s,
|
|
49
|
+
'source_id' => @source ? @source.element_id : nil,
|
|
50
|
+
'statements' => @statements
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
class ExceptionEvent < RubyApp::Element::Event
|
|
57
|
+
|
|
58
|
+
def initialize(exception)
|
|
59
|
+
super()
|
|
60
|
+
self.alert(exception.message)
|
|
61
|
+
self.refresh
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
require 'rubyapp/mixins/render'
|
|
67
|
+
require 'rubyapp/mixins/translate'
|
|
68
|
+
|
|
69
|
+
extend RubyApp::Mixins::Translate
|
|
70
|
+
extend RubyApp::Mixins::Render
|
|
71
|
+
include RubyApp::Mixins::Render
|
|
72
|
+
|
|
73
|
+
template_path(__FILE__)
|
|
74
|
+
|
|
75
|
+
attr_reader :attributes
|
|
76
|
+
|
|
77
|
+
event :evented
|
|
78
|
+
|
|
79
|
+
def initialize
|
|
80
|
+
@attributes = {:id => element_id}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def element_id
|
|
84
|
+
"id_#{object_id}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.get_element(element_id)
|
|
88
|
+
element_id =~ /(\d+)/
|
|
89
|
+
ObjectSpace._id2ref($1.to_i)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
protected
|
|
93
|
+
|
|
94
|
+
def on_event(event)
|
|
95
|
+
evented(event)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|