itest 0.0.1

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/bin/itest ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'itest'
5
+
6
+ Itest::CommandLineTool.new.process ARGV
data/etc/config.yaml ADDED
@@ -0,0 +1,21 @@
1
+ test_page: local
2
+ test_server: local
3
+ test_servers:
4
+ local: http://127.0.0.1:4444/wd/hub
5
+ remote: http://10.13.190.105:4444/wd/hub
6
+
7
+ capabilities:
8
+ :browser_name: firefox
9
+ :css_selectors_enabled: true
10
+ :javascript_enabled: true
11
+ :takes_screenshot: true
12
+ :native_events: false
13
+ :version:
14
+ :platform: :any
15
+
16
+ pages:
17
+ confirm_order:
18
+ local: 'http://127.0.0.1:3000/confirm_order'
19
+ demo: 'http://demo.ued.taobao.net/xingdou/projects/taoyuan/demo/confirm_order.htm'
20
+ daily:
21
+ online:
@@ -0,0 +1,28 @@
1
+ module Itest
2
+ class CommandLineTool
3
+ def cwd
4
+ File.expand_path(File.join(File.dirname(__FILE__), '../'))
5
+ end
6
+
7
+ def expand(*paths)
8
+ File.expand_path(File.join(*paths))
9
+ end
10
+
11
+ def dest_path(filepath)
12
+ expand(Dir.pwd, filepath)
13
+ end
14
+
15
+ def copy_unless_exists(relative_path, dest_path = nil)
16
+ unless File.exist?(dest_path(relative_path))
17
+ FileUtils.copy(expand(cwd, relative_path), dest_path(dest_path || relative_path))
18
+ end
19
+ end
20
+
21
+ def process(argv)
22
+ if argv[0] == 'init'
23
+ require 'fileutils'
24
+ copy_unless_exists('etc/config.yaml', 'test/config.yaml')
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/itest.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'spec_helper.rb'
2
+ require 'command_line_tool.rb'
@@ -0,0 +1,10 @@
1
+ require 'selenium-webdriver'
2
+ class Selenium::WebDriver::Element
3
+ def class_name
4
+ self.attribute(:class).split(/ +/)
5
+ end
6
+
7
+ def has_class? cls
8
+ self.class_name.include? cls
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ if Module.constants.include? 'RSpec'
2
+ require 'selenium-webdriver'
3
+ require 'itest_helper'
4
+ require 'yaml'
5
+
6
+ RSpec.configure do |config|
7
+ config.before(:all) do
8
+ @cfg = YAML.load_file('config.yaml')
9
+ cap = Selenium::WebDriver::Remote::Capabilities.new(@cfg['capabilities'])
10
+ @browser = Selenium::WebDriver.for(:remote, :url=>@cfg['test_servers'][@cfg['test_server']], :desired_capabilities => cap)
11
+ end
12
+
13
+ config.before(:each) do
14
+ @browser.get(@cfg['pages']['confirm_order'][@cfg['test_page']]+"?t"+(rand * 10000000000000.round).to_s)
15
+ end
16
+
17
+ config.after(:each) do
18
+ #@browser.close #如果果最后一个TAB则会关闭浏览器
19
+ end
20
+
21
+ config.after(:all) do
22
+ @browser.quit
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itest
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - ZhongXingDou
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-30 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: !binary |
23
+ ICAgIOWJjeerr+a1i+ivlUhFTFBFUuexu+W6kyAK
24
+
25
+ email: zhongxingdou@gmail.com
26
+ executables:
27
+ - itest
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - lib/itest.rb
34
+ - lib/spec_helper.rb
35
+ - lib/itest_helper.rb
36
+ - lib/command_line_tool.rb
37
+ - etc/config.yaml
38
+ - bin/itest
39
+ has_rdoc: true
40
+ homepage:
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: itest
73
+ test_files: []
74
+