lazyman 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.document +5 -0
  2. data/Gemfile +16 -0
  3. data/Gemfile.lock +63 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +55 -0
  7. data/VERSION +1 -0
  8. data/bin/lazyman +7 -0
  9. data/lib/lazyman.rb +7 -0
  10. data/lib/lazyman/cli.rb +27 -0
  11. data/lib/lazyman/errors.rb +5 -0
  12. data/lib/lazyman/generators/lazyman/.rspec +1 -0
  13. data/lib/lazyman/generators/lazyman/app/cases/examples/baidu_example_spec.rb +24 -0
  14. data/lib/lazyman/generators/lazyman/app/cases/shared/.empty_directory +0 -0
  15. data/lib/lazyman/generators/lazyman/app/cases/spec_helper.rb.tt +18 -0
  16. data/lib/lazyman/generators/lazyman/app/matchers/.empty_directory +5 -0
  17. data/lib/lazyman/generators/lazyman/app/pages/%app_name%_navigator.rb.tt +4 -0
  18. data/lib/lazyman/generators/lazyman/app/pages/%app_name%_page.rb.tt +4 -0
  19. data/lib/lazyman/generators/lazyman/app/pages/baidu/baidu_page.rb.tt +24 -0
  20. data/lib/lazyman/generators/lazyman/app/pages/baidu/search_result_page.rb.tt +4 -0
  21. data/lib/lazyman/generators/lazyman/app/pages/components/.empty_directory +5 -0
  22. data/lib/lazyman/generators/lazyman/app/reports/.empty_directory +5 -0
  23. data/lib/lazyman/generators/lazyman/config/config.yml +3 -0
  24. data/lib/lazyman/lazy_config.rb +21 -0
  25. data/lib/lazyman/lazy_initializer.rb +48 -0
  26. data/lib/lazyman/lazy_navigator.rb +55 -0
  27. data/lib/lazyman/lazy_page.rb +6 -0
  28. data/spec/app/pages/components/footer.rb +3 -0
  29. data/spec/app/pages/components/sub/sub_footer.rb +3 -0
  30. data/spec/app/pages/module1/module1_page.rb +6 -0
  31. data/spec/app/pages/module1/sub_test_page.rb +4 -0
  32. data/spec/app/pages/test_navigator.rb +4 -0
  33. data/spec/app/pages/test_page.rb +4 -0
  34. data/spec/config/config.yml +3 -0
  35. data/spec/config/wrong_config.yml +5 -0
  36. data/spec/lazy_config_spec.rb +28 -0
  37. data/spec/lazy_initializer_spec.rb +28 -0
  38. data/spec/lazy_navigator_spec.rb +36 -0
  39. data/spec/pages/components/footer.rb +2 -0
  40. data/spec/pages/test_page.rb +5 -0
  41. data/spec/spec_helper.rb +20 -0
  42. metadata +169 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://ruby.taobao.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rdoc", "~> 3.12"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.8.4"
12
+ gem "rspec"
13
+ gem "page-object"
14
+ gem "watir-webdriver"
15
+ gem "active_support"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ GEM
2
+ remote: http://ruby.taobao.org/
3
+ specs:
4
+ active_support (3.0.0)
5
+ activesupport (= 3.0.0)
6
+ activesupport (3.0.0)
7
+ childprocess (0.3.9)
8
+ ffi (~> 1.0, >= 1.0.11)
9
+ data_magic (0.14)
10
+ faker (>= 1.1.2)
11
+ yml_reader (>= 0.2)
12
+ diff-lcs (1.2.2)
13
+ faker (1.1.2)
14
+ i18n (~> 0.5)
15
+ ffi (1.6.0-x86-mingw32)
16
+ git (1.2.5)
17
+ i18n (0.6.4)
18
+ jeweler (1.8.4)
19
+ bundler (~> 1.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ rdoc
23
+ json (1.7.7)
24
+ multi_json (1.7.2)
25
+ page-object (0.8.6.1)
26
+ page_navigation (>= 0.7)
27
+ selenium-webdriver (>= 2.31.0)
28
+ watir-webdriver (>= 0.6.2)
29
+ page_navigation (0.7)
30
+ data_magic (>= 0.14)
31
+ rake (10.0.4)
32
+ rdoc (3.12.2)
33
+ json (~> 1.4)
34
+ rspec (2.13.0)
35
+ rspec-core (~> 2.13.0)
36
+ rspec-expectations (~> 2.13.0)
37
+ rspec-mocks (~> 2.13.0)
38
+ rspec-core (2.13.1)
39
+ rspec-expectations (2.13.0)
40
+ diff-lcs (>= 1.1.3, < 2.0)
41
+ rspec-mocks (2.13.0)
42
+ rubyzip (0.9.9)
43
+ selenium-webdriver (2.31.0)
44
+ childprocess (>= 0.2.5)
45
+ multi_json (~> 1.0)
46
+ rubyzip
47
+ websocket (~> 1.0.4)
48
+ watir-webdriver (0.6.2)
49
+ selenium-webdriver (>= 2.18.0)
50
+ websocket (1.0.7)
51
+ yml_reader (0.2)
52
+
53
+ PLATFORMS
54
+ x86-mingw32
55
+
56
+ DEPENDENCIES
57
+ active_support
58
+ bundler (~> 1.0.0)
59
+ jeweler (~> 1.8.4)
60
+ page-object
61
+ rdoc (~> 3.12)
62
+ rspec
63
+ watir-webdriver
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 easonhan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = lazyman
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to lazyman
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 easonhan. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "lazyman"
18
+ gem.homepage = "http://github.com/nbkhic@qq.com/lazyman"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A simple web automation test framework}
21
+ gem.description = %Q{A test framework using watir-webdriver rspec and page-object}
22
+ gem.email = "nbkhic@qq.com"
23
+ gem.authors = ["easonhan"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ =begin
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test
45
+ =end
46
+
47
+ require 'rdoc/task'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "lazyman #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/lazyman ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lazyman_path = File.expand_path('../../lib', __FILE__)
4
+ puts lazyman_path
5
+ $:.unshift(lazyman_path)
6
+
7
+ require 'Lazyman/cli'
data/lib/lazyman.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'active_support/all' # need be replaced, only required string of active support
2
+ require 'watir-webdriver'
3
+ require 'page-object'
4
+ require 'lazyman/lazy_config'
5
+ require 'lazyman/lazy_page'
6
+ require 'lazyman/lazy_navigator'
7
+ require 'lazyman/lazy_initializer'
@@ -0,0 +1,27 @@
1
+ require 'thor'
2
+
3
+ module Lazyman
4
+ class CLI < Thor
5
+ include Thor::Actions
6
+
7
+ argument :app_name, required: false
8
+
9
+ def self.source_root
10
+ File.join File.dirname(__FILE__), 'generators'
11
+ end
12
+
13
+ desc 'create project', 'create a lazyman project'
14
+
15
+ def new
16
+ if app_name
17
+ directory 'lazyman', app_name
18
+ else
19
+ say 'no app name'
20
+ end
21
+ end
22
+
23
+ end
24
+ CLI.start
25
+
26
+ end #Lazyman
27
+
@@ -0,0 +1,5 @@
1
+ module Lazyman
2
+ class LasymanError < StandardError; end
3
+ class ConfigFileMissingError < LasymanError; end
4
+ class IncorrectConfigFileError < LasymanError; end
5
+ end #Lazyman
@@ -0,0 +1 @@
1
+ --default-path=./app/cases
@@ -0,0 +1,24 @@
1
+ #encoding: utf-8
2
+ require File.expand_path 'app/cases/spec_helper'
3
+
4
+ describe 'An example show you how to use lazyman' do
5
+
6
+ before :all do
7
+ @keyword = 'watir-webdriver'
8
+ end
9
+
10
+ it 'should search baidu using key word' do
11
+ baidu_page = @navi.goto_baidu_page
12
+ baidu_page.keyword = @keyword
13
+ baidu_page.search_element.click
14
+ result_page = SearchResultPage.new baidu_page.browser
15
+ result_page.first_result.should eq 'watir-webdriver_百度百科'
16
+ end
17
+
18
+ it 'should have correct search result' do
19
+ baidu_page = @navi.goto_baidu_page
20
+ result_page = baidu_page.search_for @keyword
21
+ result_page.first_result.should eq 'watir-webdriver_百度百科'
22
+ end
23
+
24
+ end
@@ -0,0 +1,18 @@
1
+ begin
2
+ require 'lazyman'
3
+ rescue LoadError
4
+ puts 'you need using "gem install lazyman" to install lazyman first'
5
+ end
6
+ <% require 'active_support/all' %>
7
+ Lazyman::Initializer.new(File.expand_path(File.join('.')), '<%= app_name %>')
8
+ $:.unshift(File.expand_path File.join('.'))
9
+
10
+ RSpec.configure do |c|
11
+ c.before(:all) do
12
+ @navi = <%= app_name.camelize %>Navigator.new $config
13
+ end
14
+
15
+ c.after(:all) do
16
+ @navi.close
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ -
3
+ README.md
4
+ License.txt
5
+ Changelog.md
@@ -0,0 +1,4 @@
1
+ #encoding: utf-8
2
+ <% require 'active_support/all' %>
3
+ class <%= app_name.camelize %>Navigator < Lazyman::Navigator
4
+ end
@@ -0,0 +1,4 @@
1
+ #encoding: utf-8
2
+ <% require 'active_support/all' %>
3
+ class <%= app_name.camelize%>Page < Lazyman::Page
4
+ end
@@ -0,0 +1,24 @@
1
+ #encoding: utf-8
2
+ require File.expand_path 'app/pages/baidu/search_result_page'
3
+
4
+ class BaiduPage < <%= app_name.camelize%>Page
5
+ page_url 'www.baidu.com'
6
+
7
+ text_field 'keyword', id: 'kw'
8
+ button 'search', id: 'su'
9
+
10
+ def keyword_text_field
11
+ @browser.text_field(id: 'kw')
12
+ end
13
+
14
+ def search_button
15
+ @browser.button(id: 'su')
16
+ end
17
+
18
+ def search_for kw
19
+ keyword_text_field.set kw
20
+ search_button.click
21
+ SearchResultPage.new @browser
22
+ end
23
+
24
+ end
@@ -0,0 +1,4 @@
1
+ #encoding: utf-8
2
+ class SearchResultPage < <%= app_name.camelize%>Page
3
+ h3 'first_result', index: 0
4
+ end
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ -
3
+ README.md
4
+ License.txt
5
+ Changelog.md
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ -
3
+ README.md
4
+ License.txt
5
+ Changelog.md
@@ -0,0 +1,3 @@
1
+ ---
2
+ browser: chrome
3
+ host: www.baidu.com
@@ -0,0 +1,21 @@
1
+ require 'yaml'
2
+ require 'lazyman/errors'
3
+ require 'ostruct'
4
+
5
+ module Lazyman
6
+ class Config
7
+ attr_reader :hash_content, :content
8
+
9
+ def initialize filepath
10
+ @f ||= filepath if valid?(filepath)
11
+ File.open(@f) {|handle| @hash_content = YAML.load(handle)}
12
+ @content = OpenStruct.new(@hash_content)
13
+ end
14
+
15
+ def valid?(filepath)
16
+ raise ConfigFileMissingError unless File.exists?(filepath)
17
+ true
18
+ end
19
+
20
+ end
21
+ end #Lazyman
@@ -0,0 +1,48 @@
1
+ module Lazyman
2
+ class Initializer
3
+ def initialize root, app_name
4
+ @root ||= root
5
+ @app_name ||= app_name
6
+ load_app_page_and_navigator
7
+ load_all_components
8
+ load_all_pages
9
+ load_config
10
+ generate_pathes
11
+ end
12
+
13
+ def load_app_page_and_navigator
14
+ @pages_path = File.join(@root, 'app', 'pages')
15
+ $:.unshift(@pages_path)
16
+ require File.join(@pages_path, "#{@app_name}_page")
17
+ require File.join(@pages_path, "#{@app_name}_navigator")
18
+ end
19
+
20
+ def load_all_components
21
+ @components_path = File.join(@pages_path, 'components')
22
+ Dir.glob(File.join @components_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.each do |c|
23
+ puts c if $debug
24
+ require "#{c}"
25
+ end #each
26
+ end
27
+
28
+ def load_all_pages
29
+ Dir.glob(File.join @pages_path, '**', '*.rb').select { |p| p =~ /page\.rb$/ }.each do |page|
30
+ puts "#{page}" if $debug
31
+ require "#{page}"
32
+ end #each
33
+ end
34
+
35
+ def load_config
36
+ # hard code config file name here
37
+ @config_file = File.join @root, 'config', 'config.yml'
38
+ $config = Config.new(@config_file).content
39
+ end
40
+
41
+ def generate_pathes
42
+ $root = @root
43
+ $pages = @pages_path
44
+ $components = @components_path
45
+ end
46
+
47
+ end
48
+ end #Lazyman
@@ -0,0 +1,55 @@
1
+ require 'Lazyman/errors'
2
+ module Lazyman
3
+ class Navigator
4
+
5
+ def initialize config
6
+ @config = config.clone
7
+ defined_browser?
8
+ @browser = start_browser
9
+ define_goto_methods
10
+ end
11
+
12
+ def defined_browser?
13
+ if !@config.respond_to?(:browser) || @config.browser.empty?
14
+ raise IncorrectConfigFileError, 'you should define browser in your config file'
15
+ end #if
16
+ end
17
+
18
+ def start_browser
19
+ Watir::Browser.new @config.browser.to_sym
20
+ end
21
+
22
+ def define_goto_methods
23
+ p Module.constants.grep(/Page$/) if $debug
24
+ Module.constants.grep(/Page$/).each do |page_klass|
25
+ if lazyman_page?(page_klass)
26
+ # define_method is private,so using send
27
+ self.class.send :define_method, "goto_#{page_klass.to_s.underscore}" do
28
+ page = Module.const_get(page_klass).new(@browser)
29
+ page.goto
30
+ page
31
+ end #define_method
32
+ puts "defined goto_#{page_klass.to_s.underscore}" if $debug
33
+ end #if
34
+ end #each
35
+ end
36
+
37
+ def valid_page_klass? klass
38
+ # skip Lazyman::Page
39
+ return false if klass.eql?(:Page)
40
+ Module.const_get(klass) < Lazyman::Page
41
+ end
42
+ alias_method :lazyman_page?, :valid_page_klass?
43
+
44
+ def method_missing(m, *args, &blk)
45
+ if @browser.respond_to? m
46
+ @browser.send(m, *args, &blk)
47
+ else
48
+ super
49
+ end #if
50
+ end
51
+
52
+
53
+ end
54
+
55
+ end #Lazyman
@@ -0,0 +1,6 @@
1
+ module Lazyman
2
+ class Page
3
+ include PageObject
4
+ end
5
+
6
+ end #Lazyman
@@ -0,0 +1,3 @@
1
+ puts 'required files in components' if $debug
2
+ module Footer
3
+ end
@@ -0,0 +1,3 @@
1
+ puts 'required files in sub footer' if $debug
2
+ module SubFooter
3
+ end
@@ -0,0 +1,6 @@
1
+ puts 'required files in module1' if $debug
2
+ class Module1Page < Lazyman::Page
3
+ end
4
+
5
+ class CustomModule1Page < Lazyman::Page
6
+ end
@@ -0,0 +1,4 @@
1
+ puts 'required files in sub test page' if $debug
2
+ class SubTestPage < TestPage
3
+ end
4
+
@@ -0,0 +1,4 @@
1
+ puts 'required app navigator' if $debug
2
+ class TestNavigator < Lazyman::Navigator
3
+ end
4
+
@@ -0,0 +1,4 @@
1
+ puts 'required app pages' if $debug
2
+ class TestPage < Lazyman::Page
3
+ end
4
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ host: www.example.com
3
+
@@ -0,0 +1,5 @@
1
+ ---
2
+ incorrect
3
+ wrong:
4
+ ok
5
+
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lazyman::Config do
4
+ before do
5
+ @valid_file = config_file('config.yml')
6
+ @wrong_format = config_file('wrong_config.yml')
7
+ @content = {host: 'www.example.com'}
8
+ end
9
+
10
+ it 'should raise error when initialized with a missing file' do
11
+ lambda {Lazyman::Config.new('not_exist_file')}.should raise_error(Lazyman::ConfigFileMissingError)
12
+ end
13
+
14
+ it 'should NOT raise error when initialized with an exist file' do
15
+ lambda {Lazyman::Config.new(@valid_file)}.should_not raise_error(Lazyman::ConfigFileMissingError)
16
+ end
17
+
18
+ it 'should load yaml file correctly' do
19
+ Lazyman::Config.new(@valid_file).hash_content['host'].should eql('www.example.com')
20
+ end
21
+
22
+ it 'should init an OpenStruct object correctly' do
23
+ c = Lazyman::Config.new(@valid_file).content
24
+ c.host.should eql('www.example.com')
25
+ c.is_a?(OpenStruct).should be_true
26
+ end
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lazyman::Initializer do
4
+ before do
5
+ @app_name = 'test'
6
+ Lazyman::Initializer.new File.dirname(__FILE__), @app_name
7
+ end
8
+
9
+ it 'should load app page and navigator' do
10
+ lambda {TestPage}.should_not raise_error
11
+ lambda {TestNavigator}.should_not raise_error
12
+ end
13
+
14
+ it 'should load all components' do
15
+ lambda {Footer}.should_not raise_error
16
+ lambda {SubFooter}.should_not raise_error
17
+ end
18
+
19
+ it 'should load all pages' do
20
+ lambda {Module1Page}.should_not raise_error
21
+ lambda {CustomModule1Page}.should_not raise_error
22
+ end
23
+
24
+ it 'should load config' do
25
+ $config.host.should eq('www.example.com')
26
+ end
27
+
28
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require 'ostruct'
3
+ require 'pages/test_page'
4
+
5
+ describe Lazyman::Navigator do
6
+ before do
7
+ @config = OpenStruct.new( browser: 'chrome')
8
+ end
9
+
10
+ it 'should raise error when config file does not define browser attribute' do
11
+ lambda {Lazyman::Navigator.new(Object.new)}.should raise_error(Lazyman::IncorrectConfigFileError)
12
+ end
13
+
14
+ it 'should start browser successfully' do
15
+ Watir::Browser.stub(:new)
16
+ Watir::Browser.should_receive(:new)
17
+ Lazyman::Navigator.new(@config)
18
+ end
19
+
20
+ it "should be lazyman page" do
21
+ Watir::Browser.stub(:new)
22
+ Watir::Browser.should_receive(:new)
23
+ navi = Lazyman::Navigator.new(@config)
24
+ navi.lazyman_page?(:CustomTestPage).should be_true
25
+ navi.lazyman_page?(:TestPage).should be_true
26
+ end
27
+
28
+ it 'should define goto methods for navigator' do
29
+ Watir::Browser.stub(:new)
30
+ Watir::Browser.should_receive(:new)
31
+ navi = Lazyman::Navigator.new(@config)
32
+ navi.should respond_to(:goto_test_page)
33
+ navi.should respond_to(:goto_custom_test_page)
34
+ end
35
+
36
+ end
@@ -0,0 +1,2 @@
1
+ module Footer
2
+ end
@@ -0,0 +1,5 @@
1
+ class TestPage < Lazyman::Page
2
+ end
3
+
4
+ class CustomTestPage < Lazyman::Page
5
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler'
2
+ require 'pp'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'lazyman'
11
+ require 'rspec'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+
16
+ def config_file(name)
17
+ File.join(File.dirname(__FILE__), 'config', name)
18
+ end
19
+
20
+
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lazyman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - easonhan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: &18142800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.12'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *18142800
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &18142272 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *18142272
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &18141900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.8.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *18141900
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &18140976 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *18140976
58
+ - !ruby/object:Gem::Dependency
59
+ name: page-object
60
+ requirement: &23350284 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *23350284
69
+ - !ruby/object:Gem::Dependency
70
+ name: watir-webdriver
71
+ requirement: &23349960 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *23349960
80
+ - !ruby/object:Gem::Dependency
81
+ name: active_support
82
+ requirement: &23349636 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *23349636
91
+ description: A test framework using watir-webdriver rspec and page-object
92
+ email: nbkhic@qq.com
93
+ executables:
94
+ - lazyman
95
+ extensions: []
96
+ extra_rdoc_files:
97
+ - LICENSE.txt
98
+ - README.rdoc
99
+ files:
100
+ - .document
101
+ - Gemfile
102
+ - Gemfile.lock
103
+ - LICENSE.txt
104
+ - README.rdoc
105
+ - Rakefile
106
+ - VERSION
107
+ - bin/lazyman
108
+ - lib/lazyman.rb
109
+ - lib/lazyman/cli.rb
110
+ - lib/lazyman/errors.rb
111
+ - lib/lazyman/generators/lazyman/.rspec
112
+ - lib/lazyman/generators/lazyman/app/cases/examples/baidu_example_spec.rb
113
+ - lib/lazyman/generators/lazyman/app/cases/shared/.empty_directory
114
+ - lib/lazyman/generators/lazyman/app/cases/spec_helper.rb.tt
115
+ - lib/lazyman/generators/lazyman/app/matchers/.empty_directory
116
+ - lib/lazyman/generators/lazyman/app/pages/%app_name%_navigator.rb.tt
117
+ - lib/lazyman/generators/lazyman/app/pages/%app_name%_page.rb.tt
118
+ - lib/lazyman/generators/lazyman/app/pages/baidu/baidu_page.rb.tt
119
+ - lib/lazyman/generators/lazyman/app/pages/baidu/search_result_page.rb.tt
120
+ - lib/lazyman/generators/lazyman/app/pages/components/.empty_directory
121
+ - lib/lazyman/generators/lazyman/app/reports/.empty_directory
122
+ - lib/lazyman/generators/lazyman/config/config.yml
123
+ - lib/lazyman/lazy_config.rb
124
+ - lib/lazyman/lazy_initializer.rb
125
+ - lib/lazyman/lazy_navigator.rb
126
+ - lib/lazyman/lazy_page.rb
127
+ - spec/app/pages/components/footer.rb
128
+ - spec/app/pages/components/sub/sub_footer.rb
129
+ - spec/app/pages/module1/module1_page.rb
130
+ - spec/app/pages/module1/sub_test_page.rb
131
+ - spec/app/pages/test_navigator.rb
132
+ - spec/app/pages/test_page.rb
133
+ - spec/config/config.yml
134
+ - spec/config/wrong_config.yml
135
+ - spec/lazy_config_spec.rb
136
+ - spec/lazy_initializer_spec.rb
137
+ - spec/lazy_navigator_spec.rb
138
+ - spec/pages/components/footer.rb
139
+ - spec/pages/test_page.rb
140
+ - spec/spec_helper.rb
141
+ homepage: http://github.com/nbkhic@qq.com/lazyman
142
+ licenses:
143
+ - MIT
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
155
+ - 0
156
+ hash: 882304817
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 1.8.16
166
+ signing_key:
167
+ specification_version: 3
168
+ summary: A simple web automation test framework
169
+ test_files: []