monkey_tester 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f400a0cf206de5af8a2a70edb7ac23563f746a20
4
+ data.tar.gz: 06797fa4ef9e93f31c59cceca3ae68360cb29bca
5
+ SHA512:
6
+ metadata.gz: 2ea2cac5dc8717a85cb18308b8fe05dfa924a8b542fd1b5ea992852818650c6c4658488ecff5c5895e428c4173e55ef75ab3c684e478bead7cc89e162842d091
7
+ data.tar.gz: c709e97c9feae158cb57032a07d64e435ca6c7b1591be21e74414b740e826f614b055a2acf6a75d6b22e7a13ab03178fe8b8c9990a4e49fe29a1569fdb28220c
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in monkey_tester.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Shigeaki Matsumura
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # MonkeyTester
2
+
3
+ MonkeyTester is a mokey test library in ruby.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'monkey_tester'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install monkey_tester
20
+
21
+ ## Usage
22
+
23
+ Sample script
24
+
25
+ ```ruby
26
+ require 'monkey_tester'
27
+
28
+ MonkeyTester.setup!
29
+
30
+ walker = MonkeyTester::RandomWalker.new(
31
+ url: 'http://localhost/',
32
+ login: {
33
+ url: 'http://localhost/login',
34
+ id: {label: 'Login ID', value: 'test_id'},
35
+ password: {label: 'Password', value: 'test_pass'},
36
+ button: {label: 'Login'},
37
+ },
38
+ debug: true,
39
+ )
40
+ walker.walk
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/monkey_tester/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,17 @@
1
+ require 'capybara'
2
+ require 'capybara/dsl'
3
+ require 'capybara/poltergeist'
4
+ require "monkey_tester/version"
5
+ require "monkey_tester/random_walker"
6
+
7
+ module MonkeyTester
8
+ # Your code goes here...
9
+ def self.setup!
10
+ Capybara.register_driver :poltergeist do |app|
11
+ Capybara::Poltergeist::Driver.new(app, js_errors: false)
12
+ end
13
+
14
+ # Capybara.javascript_driver = :poltergeist
15
+ Capybara.default_driver = :poltergeist
16
+ end
17
+ end
@@ -0,0 +1,43 @@
1
+ class MonkeyTester::RandomWalker
2
+ include Capybara::DSL
3
+
4
+ def initialize(options)
5
+ @url = options[:url]
6
+ @scheme = URI.parse(@url).scheme
7
+ @host = URI.parse(@url).host
8
+ @login = options[:login]
9
+ @debug = options[:debug]
10
+ end
11
+
12
+ def walk
13
+ visit @url
14
+
15
+ while true
16
+ begin
17
+ login @login[:url] and next if page.current_url == @login[:url]
18
+ puts [page.status_code, page.current_url, page.title].join("\t")
19
+ next_link = all('a').reject{
20
+ |a| a[:href] !~ /^#{@scheme}:\/\/#{@host}/ && a[:href] =~ /:\/\//
21
+ }.sample
22
+ page.evaluate_script('window.history.back()') and next unless next_link
23
+ puts [next_link, next_link[:href], next_link.text].join("\t") if @debug
24
+ next_link.click
25
+ rescue Capybara::Poltergeist::MouseEventFailed => e
26
+ # just ignore
27
+ rescue => e
28
+ puts e
29
+ puts e.message
30
+ end
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def login(url)
37
+ visit url
38
+ fill_in @login[:id][:label], with: @login[:id][:value]
39
+ fill_in @login[:password][:label], with: @login[:password][:value]
40
+ click_button(@login[:button][:value])
41
+ end
42
+
43
+ end
@@ -0,0 +1,3 @@
1
+ module MonkeyTester
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'monkey_tester/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "monkey_tester"
8
+ spec.version = MonkeyTester::VERSION
9
+ spec.authors = ["Shigeaki Matsumura"]
10
+ spec.email = ["matsu911@gmail.com"]
11
+ spec.summary = %q{Web site mokey test library in ruby}
12
+ spec.description = %q{MonkeyTester is a web site mokey test library in ruby.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'poltergeist', '~> 1.6.0'
22
+ spec.add_dependency 'capybara', '~> 2.4.4'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monkey_tester
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shigeaki Matsumura
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: poltergeist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.4.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.4.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: MonkeyTester is a web site mokey test library in ruby.
70
+ email:
71
+ - matsu911@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/monkey_tester.rb
82
+ - lib/monkey_tester/random_walker.rb
83
+ - lib/monkey_tester/version.rb
84
+ - monkey_tester.gemspec
85
+ homepage: ''
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.14
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Web site mokey test library in ruby
109
+ test_files: []