watir_install 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.ruby-version +1 -1
  4. data/CHANGES.md +9 -0
  5. data/README.md +55 -2
  6. data/bin/watir +0 -0
  7. data/lib/watir_install/cli.rb +59 -7
  8. data/lib/watir_install/generators/data/spec/support/data/data.rb.tt +24 -0
  9. data/lib/watir_install/generators/data.rb +34 -0
  10. data/lib/watir_install/generators/{new_project → example}/spec/search_spec.rb.tt +2 -2
  11. data/lib/watir_install/generators/{new_project/lib/models → example/spec/support/data}/search.rb.tt +3 -3
  12. data/lib/watir_install/generators/{new_project/lib → example/spec/support}/pages/home.rb.tt +1 -1
  13. data/lib/watir_install/generators/example/spec/support/pages/results.rb.tt +14 -0
  14. data/lib/watir_install/generators/example.rb +30 -0
  15. data/lib/watir_install/generators/{new_project → new}/cucumber.yml.tt +0 -0
  16. data/lib/watir_install/generators/{new_project → new}/gemfile.rb.tt +2 -5
  17. data/lib/watir_install/generators/{new_project → new}/gitignore.rb.tt +0 -0
  18. data/lib/watir_install/generators/new/rakefile.rb.tt +5 -0
  19. data/lib/watir_install/generators/{new_project → new}/readme.rb.tt +0 -0
  20. data/lib/watir_install/generators/{new_project → new}/rspec.rb.tt +0 -0
  21. data/lib/watir_install/generators/new/ruby-version.rb.tt +1 -0
  22. data/lib/watir_install/generators/new/spec/sauce_helpers.rb.tt +22 -0
  23. data/lib/watir_install/generators/new/spec/spec_helper.rb.tt +28 -0
  24. data/lib/watir_install/generators/new/spec/support/data/base.rb.tt +19 -0
  25. data/lib/watir_install/generators/new/spec/support/pages/base.rb.tt +5 -0
  26. data/lib/watir_install/generators/new/spec/support/sauce_helpers.rb.tt +22 -0
  27. data/lib/watir_install/generators/{new_project → new}/travis.rb.tt +1 -1
  28. data/lib/watir_install/generators/new.rb +75 -0
  29. data/lib/watir_install/generators/page.rb +29 -0
  30. data/lib/watir_install/generators/pages/spec/support/pages/page.rb.tt +34 -0
  31. data/lib/watir_install/generators/test.rb +32 -0
  32. data/lib/watir_install/generators/tests/spec/crud.rb.tt +26 -0
  33. data/lib/watir_install/generators/tests/spec/spec.rb.tt +17 -0
  34. data/watir_install.gemspec +5 -6
  35. metadata +46 -63
  36. data/lib/watir_install/generators/new_project/config/data/data.yml.tt +0 -3
  37. data/lib/watir_install/generators/new_project/features/search.feature.tt +0 -6
  38. data/lib/watir_install/generators/new_project/features/step_definitions/search_steps.rb.tt +0 -13
  39. data/lib/watir_install/generators/new_project/features/support/env.rb.tt +0 -11
  40. data/lib/watir_install/generators/new_project/features/support/hooks.rb.tt +0 -9
  41. data/lib/watir_install/generators/new_project/features/support/pages/home.rb.tt +0 -19
  42. data/lib/watir_install/generators/new_project/features/support/pages/results.rb.tt +0 -13
  43. data/lib/watir_install/generators/new_project/lib/name.rb.tt +0 -5
  44. data/lib/watir_install/generators/new_project/lib/pages/results.rb.tt +0 -12
  45. data/lib/watir_install/generators/new_project/license.rb.tt +0 -21
  46. data/lib/watir_install/generators/new_project/rakefile.rb.tt +0 -16
  47. data/lib/watir_install/generators/new_project/ruby-version.rb.tt +0 -1
  48. data/lib/watir_install/generators/new_project/spec/spec_helper.rb.tt +0 -15
  49. data/lib/watir_install/generators/new_project.rb +0 -100
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11cc85ef4b1e63581703ee6a1fc226506a3ed9de
4
- data.tar.gz: 5af6288495db7b81953a0a14e10cf6ee40d8fa7d
3
+ metadata.gz: 0b1d7616e709714e853171cf89e54227aa6eb3a1
4
+ data.tar.gz: '038db3182ad033c07b53655482e1e2f7a11db91e'
5
5
  SHA512:
6
- metadata.gz: b2be72ccc1ac0899ff11b0a53361ef6eef61ea2844963f8a1a2deae75d1d75807f537483f3d6f75977b406f384cd9ad3bb23815acaa9cf823bb9cfe0d887c620
7
- data.tar.gz: 7b77625b9de6ee39fd59f425b9a78405f596603a3abcb04ff055343f840aaf878f0e97ad80f639e8fe157f047ada123f324c0ed70ab6ea4cee823fc25c50e74d
6
+ metadata.gz: d13c3fd8dc25d3f9ca9c3a086e92b5f74065a27271801dfa23e131e4eaacbbfce85a7f8bc250176087f6c89f6abb7ee03adb9f66c2b918c0a573887e3f373b8b
7
+ data.tar.gz: ee596feba54b805885cc0ac154475a583de453a607f9789562fe025ed53b4c673abb22d8714c435f23ae1ed1a520ea9002894abcdd2f2e4ee4bf6e21991002ea
data/.gitignore CHANGED
@@ -7,4 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /.idea/
10
+ /.idea/
11
+ *.gem
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.3
1
+ ruby-2.3.4
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### 0.3.0 (2017-05-23)
2
+
3
+ * Remove sample code from new command
4
+ * Add generate test
5
+ * Add generate data
6
+ * Add generate page
7
+ * Add generate scaffolding
8
+ * Lots of formatting updates and comments
9
+
1
10
  ### 0.2.1 (2017-01-03)
2
11
 
3
12
  * Remove WatirSession requirement
data/README.md CHANGED
@@ -8,9 +8,58 @@ the recommended default configurations to easily create and maintain your test s
8
8
 
9
9
  $ gem install watir_install
10
10
 
11
- And then execute with the name of your project:
11
+ ## Usage
12
+
13
+ #### Create a new project
14
+
15
+ $ watir new project_name
16
+
17
+ or
18
+
19
+ $ watir new project_name --no_git true
20
+
21
+ #### Generate Test
22
+
23
+ $ watir generate test DataName
24
+
25
+ or
26
+
27
+ $ watir generate test DataName test1 test2 test3 test4
28
+
29
+
30
+ #### Generate Data
31
+
32
+ $ watir generate data DataName
33
+
34
+ or
35
+
36
+ $ watir generate data DataName key1 key2 key3 key4
37
+
38
+
39
+ #### Generate Page
40
+
41
+ $ watir generate page PageName
42
+
43
+ or
44
+
45
+ $ watir generate page PageName el1 el2 el3 el4
46
+
47
+ or
48
+
49
+ $ watir generate page PageName --url http://example.com
50
+
51
+ or
52
+
53
+ $ watir generate page PageName:DataName key1 key2 key3 key4 --form true
54
+
55
+ or
56
+
57
+ $ watir generate page PageName:DataName key1 key2 key3 key4 --form true --url http://example.com
58
+
59
+ #### Generate Scaffolding
60
+
61
+ $ watir generate scaffold ObjectName el1 el2 el3 el4 --url http://example.com/object
12
62
 
13
- $ watir_install foobar
14
63
 
15
64
  ## Contributing
16
65
 
@@ -21,3 +70,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/titusf
21
70
 
22
71
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
23
72
 
73
+ ## TODO
74
+
75
+ 1. Support Camel Case project names
76
+ 2. Add Watir-Scroll
data/bin/watir CHANGED
File without changes
@@ -1,19 +1,71 @@
1
1
  require 'thor'
2
- require 'watir_install/generators/new_project'
2
+ require 'require_all'
3
+ require_rel 'generators'
3
4
 
4
5
  module WatirInstall
5
6
  class CLI < Thor
6
7
 
7
8
  desc "new <project_name>", "Create a new test project"
8
9
  method_option :no_git, type: :boolean, desc: "Do not initialize project with git"
9
- method_option :test_runner, type: :string, desc: "Do not initialize project with git"
10
-
11
10
 
12
11
  def new(name)
13
- no_git = options[:no_git] ? 'true' : 'false'
14
- test_runner = options[:test_runner]
15
- WatirInstall::Generators::NewProject.start([name, no_git, test_runner])
12
+ WatirInstall::Generators::New.start([name, options[:no_git]])
16
13
  end
17
-
14
+
15
+ desc "generate <generated_type>", "Generate a new object"
16
+ method_option :url, type: :string, desc: "Do not initialize project with git"
17
+ method_option :form, type: :string, desc: "Do not initialize project with git"
18
+
19
+ def generate(generated_type, klass, *args)
20
+ url = options[:url] || ''
21
+ form = options[:form] || ''
22
+
23
+ send("generate_#{generated_type}", klass, url, form, *args)
24
+ end
25
+
26
+ desc "generate_data <Class>", "Generate a new data object"
27
+
28
+ def generate_data(klass, _url, _form, *args)
29
+ WatirInstall::Generators::Data.start([klass, *args])
30
+ end
31
+
32
+ desc "generate_page <Class>", "Generate a new page object"
33
+
34
+ def generate_page(klass, url, form, *args)
35
+ form = klass[/[^:]*$/] if form == 'true'
36
+ klass = klass[/^[^:]*/]
37
+ WatirInstall::Generators::Page.start([klass, url, form, *args])
38
+ end
39
+
40
+ desc "generate_test <Class>", "Generate a new test"
41
+
42
+ def generate_test(klass, _url, form, *args)
43
+ WatirInstall::Generators::Test.start([klass, form, *args])
44
+ end
45
+
46
+ desc "generate_scaffold <Class>", "Generate collection of data, pages and tests"
47
+
48
+ def generate_scaffold(klass, url, form, *args)
49
+ WatirInstall::Generators::Test.start([klass, 'true'])
50
+
51
+ WatirInstall::Generators::Data.start([klass, *args])
52
+
53
+ new_url = url.nil? ? '' : "#{url}/new"
54
+
55
+ WatirInstall::Generators::Page.start(["#{klass}::List", url, ''])
56
+ WatirInstall::Generators::Page.start(["#{klass}::New", new_url, klass, *args])
57
+ # TODO: generate dynamic url method for Show & Edit
58
+ WatirInstall::Generators::Page.start(["#{klass}::Show", '', '', *args])
59
+ WatirInstall::Generators::Page.start(["#{klass}::Edit", '', klass, *args])
60
+ end
61
+
62
+ desc "example", "Create a new test project"
63
+ method_option :no_git, type: :boolean, desc: "Do not initialize project with git"
64
+
65
+ def example
66
+ WatirInstall::Generators::New.start(['google_search', options[:no_git]])
67
+ WatirInstall::Generators::Example.start
68
+ end
69
+
18
70
  end
19
71
  end
@@ -0,0 +1,24 @@
1
+ module <%= name.split('_').map(&:capitalize).join %>
2
+ module Data
3
+ class <%= klass %> < Base
4
+
5
+ # Specify default data for each key inside block
6
+
7
+ <% if keys.empty? -%>
8
+ # Define keys representing desired data
9
+ # key(:foo) { 'Example Default String' }
10
+ <% else -%>
11
+ <% keys.each do |key| -%>
12
+ <% data_type = key.include?(':') ? key[/[^:]*$/].to_sym : key.to_sym -%>
13
+ <% key = key[/^[^:]*/] -%>
14
+ <% if TRANSLATIONS.include? data_type -%>
15
+ key(:<%= key %>) { Defaults.translate :<%= data_type %> }
16
+ <% else -%>
17
+ key(:<%= key %>) { }
18
+ <% end -%>
19
+ <% end -%>
20
+ <% end -%>
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ require 'thor/group'
2
+ require 'git'
3
+ require 'active_support/inflector'
4
+ require 'data_magic/standard_translation'
5
+
6
+ module WatirInstall
7
+ module Generators
8
+ class Data < Thor::Group
9
+ include Thor::Actions
10
+
11
+ TRANSLATIONS = %i(full_name first_name last_name name_prefix name_suffix
12
+ title street_address secondary_address city state state_abbr zip_code
13
+ country company_name catch_phrase credit_card_number credit_card_type
14
+ words sentence sentences paragraphs characters email_address domain_name
15
+ url user_name phone_number cell_phone password).freeze
16
+
17
+ argument :klass, type: :string, desc: 'The data object being created'
18
+ argument :keys, required: false, default: [], type: :array, desc: 'These are keys for data'
19
+
20
+ def self.source_root
21
+ "#{File.dirname(__FILE__)}/data"
22
+ end
23
+
24
+ def name
25
+ Dir.pwd[/[^\/]*$/]
26
+ end
27
+
28
+ def data_files
29
+ template "spec/support/data/data.rb.tt", "#{Dir.pwd}/spec/support/data/#{klass.downcase}.rb"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -2,11 +2,11 @@ require "spec_helper"
2
2
 
3
3
  describe <%= name.split('_').map(&:capitalize).join %> do
4
4
  it "submits a search" do
5
- search_data = <%= name.split('_').map(&:capitalize).join %>::Model::Search.new
5
+ search_data = <%= name.split('_').map(&:capitalize).join %>::Data::Search.new
6
6
  search_page = <%= name.split('_').map(&:capitalize).join %>::Home.visit
7
7
 
8
8
  search_page.search(search_data)
9
9
 
10
- expect(<%= name.split('_').map(&:capitalize).join %>::Results.new.first_result).to include search_data.first_result
10
+ expect(<%= name.split('_').map(&:capitalize).join %>::Results.new.title?(search_data.wikipedia_result)).to eq true
11
11
  end
12
12
  end
@@ -1,9 +1,9 @@
1
1
  module <%= name.split('_').map(&:capitalize).join %>
2
- module Model
3
- class Search < WatirModel
2
+ module Data
3
+ class Search < Base
4
4
 
5
5
  key(:search_term) { 'foo' }
6
- key(:first_result) { 'Foobar - Wikipedia' }
6
+ key(:wikipedia_result) { 'Foobar - Wikipedia' }
7
7
 
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module <%= name.split('_').map(&:capitalize).join %>
2
- class Home < WatirDrops::PageObject
2
+ class Home < Base
3
3
 
4
4
  element(:search_term) { browser.text_field(name: 'q')}
5
5
  element(:submit) { browser.button(name: 'btnG') }
@@ -0,0 +1,14 @@
1
+ module <%= name.split('_').map(&:capitalize).join %>
2
+ class Results < Base
3
+
4
+ element(:titles) { |text| browser.h3(text: /#{text}/) }
5
+
6
+ def title?(text)
7
+ titles(text).wait_until(&:present?)
8
+ true
9
+ rescue Watir::Wait::TimeoutError
10
+ false
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ require 'thor/group'
2
+
3
+ module WatirInstall
4
+ module Generators
5
+ class Example < Thor::Group
6
+ include Thor::Actions
7
+
8
+ def self.source_root
9
+ "#{File.dirname(__FILE__)}/example"
10
+ end
11
+
12
+ def name
13
+ 'google_search'
14
+ end
15
+
16
+ def support_files
17
+ template "spec/support/pages/home.rb.tt", "spec/support/pages/home.rb"
18
+ template "spec/support/pages/results.rb.tt", "spec/support/pages/results.rb"
19
+ end
20
+
21
+ def data_files
22
+ template "spec/support/data/search.rb.tt", "spec/support/data/search.rb"
23
+ end
24
+
25
+ def test_files
26
+ template "spec/search_spec.rb.tt", "spec/search_spec.rb"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,14 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem "bundler", "~> 1.13"
4
4
  gem "rake", "~> 10.0"
5
- <% if test_runner == 'cucumber' -%>
6
- gem "cucumber", "~> 2.0"
7
- <% end %>
8
5
  gem "rspec", "~> 3.0"
9
6
  gem "watir", "~> 6.0"
10
7
  gem "webdrivers", "~> 2.1"
11
- gem "watir_drops", "~> 0.5.0"
8
+ gem "watir_drops", "~> 0.7"
12
9
  gem 'watir_model', "~> 0.2"
13
- gem "page-object", "~> 2.0"
14
10
  gem "data_magic"
15
11
  gem "require_all"
12
+ gem "sauce_whisk"
@@ -0,0 +1,5 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => :spec
@@ -0,0 +1 @@
1
+ ruby-2.3.4
@@ -0,0 +1,22 @@
1
+ require 'sauce_whisk'
2
+
3
+ module SauceHelpers
4
+ def initialize_driver(name = nil)
5
+ @name = name || "Unknown Test at #{Time.now.to_i}"
6
+ capabilities = {name: @name,
7
+ build: ENV['BUILD_TAG'] ||= "Unknown Build at #{Time.now.to_i}"}
8
+ capabilities[:browserName] = ENV['browserName'] || :chrome
9
+
10
+ capabilities[:platform] = ENV['platform'] if ENV['platform']
11
+ capabilities[:version] = ENV['version'] if ENV['version']
12
+
13
+ url = "https://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:443/wd/hub".strip
14
+ @browser = Watir::Browser.new :remote, {url: url,
15
+ desired_capabilities: capabilities}
16
+ end
17
+
18
+ def submit_results(session_id, result)
19
+ SauceWhisk::Jobs.change_status(session_id, result)
20
+ end
21
+
22
+ end
@@ -0,0 +1,28 @@
1
+ require "watir_drops"
2
+ require "watir_model"
3
+ require "require_all"
4
+ require_rel "support/data"
5
+ require_rel "support/pages"
6
+ include <%= name.split('_').map(&:capitalize).join %>
7
+
8
+ if ENV['USE_SAUCE'] == 'true'
9
+ require_rel 'support/sauce_helpers'
10
+ end
11
+
12
+ RSpec.configure do |config|
13
+ config.include SauceHelpers if ENV['USE_SAUCE'] == 'true'
14
+
15
+ config.before(:each) do
16
+ @browser = if ENV['USE_SAUCE'] == 'true'
17
+ initialize_driver(test.full_description)
18
+ else
19
+ Watir::Browser.new
20
+ end
21
+
22
+ WatirDrops::PageObject.browser = @browser
23
+ end
24
+
25
+ config.after(:each) do
26
+ @browser.quit
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ require 'faker'
2
+ require 'data_magic/standard_translation'
3
+
4
+ module <%= name.split('_').map(&:capitalize).join %>
5
+ module Data
6
+ class Base < WatirModel
7
+
8
+ end
9
+
10
+ class Defaults
11
+ include DataMagic::StandardTranslation
12
+
13
+ def self.translate(key)
14
+ return new.send(:characters, 10) if key == :password
15
+ new.send(key)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module <%= name.split('_').map(&:capitalize).join %>
2
+ class Base < WatirDrops::PageObject
3
+
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'sauce_whisk'
2
+
3
+ module SauceHelpers
4
+ def initialize_driver(name = nil)
5
+ @name = name || "Unknown Test at #{Time.now.to_i}"
6
+ capabilities = {name: @name,
7
+ build: ENV['BUILD_TAG'] ||= "Unknown Build at #{Time.now.to_i}"}
8
+ capabilities[:browserName] = ENV['browserName'] || :chrome
9
+
10
+ capabilities[:platform] = ENV['platform'] if ENV['platform']
11
+ capabilities[:version] = ENV['version'] if ENV['version']
12
+
13
+ url = "https://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:443/wd/hub".strip
14
+ @browser = Watir::Browser.new :remote, {url: url,
15
+ desired_capabilities: capabilities}
16
+ end
17
+
18
+ def submit_results(session_id, result)
19
+ SauceWhisk::Jobs.change_status(session_id, result)
20
+ end
21
+
22
+ end
@@ -4,7 +4,7 @@ language: ruby
4
4
  addons:
5
5
  firefox: latest
6
6
  rvm:
7
- - 2.2.6
7
+ - 2.3.3
8
8
  cache: bundler
9
9
  before_script:
10
10
  - export CHROME_BIN=/usr/bin/google-chrome
@@ -0,0 +1,75 @@
1
+ require 'thor/group'
2
+ require 'git'
3
+ require 'active_support/inflector'
4
+
5
+ module WatirInstall
6
+ module Generators
7
+ class New < Thor::Group
8
+ include Thor::Actions
9
+
10
+ argument :name, type: :string, desc: 'The name of the test project'
11
+ argument :no_git, type: :string, default: 'false', desc: 'Do not initialize project with git'
12
+
13
+ def self.source_root
14
+ "#{File.dirname(__FILE__)}/new"
15
+ end
16
+
17
+ def user_name
18
+ if no_git == 'false'
19
+ @git = Git.init(name)
20
+ @user_name ||= @git.config["user.name"]
21
+ @user_name ||= ask "Enter your Name: "
22
+ @git.config('user.name', @user_name)
23
+ @user_name
24
+ end
25
+ end
26
+
27
+ def user_email
28
+ if no_git == 'false'
29
+ @user_email ||= @git.config["user.email"]
30
+ @user_email ||= ask "Enter your Email: "
31
+ @git.config('user.email', @user_email)
32
+ @user_email
33
+ end
34
+ end
35
+
36
+ def root_files
37
+ template "gemfile.rb.tt", "#{name}/Gemfile"
38
+ template "gitignore.rb.tt", "#{name}/.gitignore"
39
+ template "rakefile.rb.tt", "#{name}/Rakefile"
40
+ template "readme.rb.tt", "#{name}/README.md"
41
+ template "ruby-version.rb.tt", "#{name}/.ruby-version"
42
+ template "travis.rb.tt", "#{name}/.travis.yml"
43
+ template "rspec.rb.tt", "#{name}/.rspec"
44
+ end
45
+
46
+ def test_files
47
+ template "spec/spec_helper.rb.tt", "#{name}/spec/spec_helper.rb"
48
+ end
49
+
50
+ def data_files
51
+ template "spec/support/data/base.rb.tt", "#{name}/spec/support/data/base.rb"
52
+ end
53
+
54
+ def page_files
55
+ template "spec/support/pages/base.rb.tt", "#{name}/spec/support/pages/base.rb"
56
+ end
57
+
58
+ def support_files
59
+ template "spec/support/sauce_helpers.rb.tt", "#{name}/spec/support/sauce_helpers.rb"
60
+ end
61
+
62
+ def bundle
63
+ Dir.chdir(name)
64
+ system 'bundle install'
65
+ end
66
+
67
+ def initial_commit
68
+ if no_git == 'false'
69
+ @git.lib.add('.', all: true)
70
+ @git.commit("initial commit", {all: true})
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,29 @@
1
+ require 'thor/group'
2
+ require 'git'
3
+ require 'active_support/inflector'
4
+
5
+ module WatirInstall
6
+ module Generators
7
+ class Page < Thor::Group
8
+ include Thor::Actions
9
+
10
+ argument :klass, type: :string, desc: 'The page object being created'
11
+ argument :url, type: :string, default: '', desc: 'The Page URL'
12
+ argument :form, type: :string, default: '', desc: 'Generates #submit_form'
13
+ argument :elements, required: false, default: [], type: :array, desc: 'These are elements on page'
14
+
15
+ def self.source_root
16
+ "#{File.dirname(__FILE__)}/pages"
17
+ end
18
+
19
+ def name
20
+ Dir.pwd[/[^\/]*$/]
21
+ end
22
+
23
+ def data_files
24
+ template "spec/support/pages/page.rb.tt", "#{Dir.pwd}/spec/support/pages/#{klass.downcase.gsub('::', '/')}.rb"
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,34 @@
1
+ module <%= name.split('_').map(&:capitalize).join -%>
2
+ <% if klass.include?(':') -%>
3
+ ::<%= klass[/^[^:]*/] -%>
4
+ <% end %>
5
+ class <%= klass[/[^:]*$/] %> < <%= name.split('_').map(&:capitalize).join %>::Base
6
+
7
+ <% if url.empty? -%>
8
+ # Define url represented by page object if appropriate
9
+
10
+ # page_url { }
11
+ <% else -%>
12
+ page_url { "<%= url %>" }
13
+ <% end %>
14
+
15
+ <% if elements.empty? -%>
16
+ # Define elements representing contents of page
17
+ <% end -%>
18
+ # Specify full Watir locator inside block
19
+ # element(:foo) { browser.div(id: 'foo') }
20
+ <% elements.each do |element| -%>
21
+ element(:<%= element %>) { }
22
+ <% end -%>
23
+ <% unless form.empty? -%>
24
+ element(:submit) { browser.button(visible: true) }
25
+
26
+ def submit_form(<%= form.downcase %> = nil)
27
+ <%= form.downcase %> ||= <%= name.split('_').map(&:capitalize).join %>::Data::<%= form %>.new
28
+ fill_form(<%= form.downcase %>)
29
+ submit.click
30
+ <%= form.downcase %>
31
+ end
32
+ <% end %>
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ require 'thor/group'
2
+ require 'git'
3
+ require 'active_support/inflector'
4
+
5
+ module WatirInstall
6
+ module Generators
7
+ class Test < Thor::Group
8
+ include Thor::Actions
9
+
10
+ argument :klass, type: :string, desc: 'The data object being created'
11
+ argument :form, type: :string, default: '', desc: 'Generates #submit_form'
12
+ argument :specs, required: false, default: [], type: :array, desc: 'Specs for'
13
+
14
+ def self.source_root
15
+ "#{File.dirname(__FILE__)}/tests"
16
+ end
17
+
18
+ def name
19
+ Dir.pwd[/[^\/]*$/]
20
+ end
21
+
22
+ def data_files
23
+ if form == 'true'
24
+ template "spec/crud.rb.tt", "#{Dir.pwd}/spec/#{klass.downcase}_spec.rb"
25
+ else
26
+ template "spec/spec.rb.tt", "#{Dir.pwd}/spec/#{klass.downcase}_spec.rb"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= name.split('_').map(&:capitalize).join %> do
4
+ let(:<%= klass.downcase %>) { <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %>.new }
5
+
6
+ it 'creates' do
7
+
8
+ end
9
+
10
+ it 'shows' do
11
+
12
+ end
13
+
14
+ it 'lists' do
15
+
16
+ end
17
+
18
+ it 'edits' do
19
+
20
+ end
21
+
22
+ it 'deletes' do
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %> do
4
+
5
+ let(:<%= klass.downcase %>) { <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %>.new }
6
+
7
+ <% if specs.empty? -%>
8
+ # Add RSpec `it` statements
9
+ <% else -%>
10
+ <% specs.each do |spec| %>
11
+ it '<%= spec -%>' do
12
+
13
+ end
14
+ <% end -%>
15
+ <% end -%>
16
+
17
+ end
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "watir_install"
7
- spec.version = "0.2.1"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Titus Fortner"]
9
9
  spec.email = ["titusfortner@gmail.com"]
10
10
 
11
11
  spec.summary = %q{UI Test Automation Framework}
12
- spec.description = %q{"Watir Framework provides everything necessary to quickly create maintainable automated test suites in an understandable and enjoyable way."}
12
+ spec.description = %q{"Watir Install provides everything necessary to quickly create maintainable automated test suites in an understandable and enjoyable way."}
13
13
  spec.homepage = "https://github.com/titusfortner/watir_install"
14
14
  spec.license = "MIT"
15
15
 
@@ -32,12 +32,11 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "bundler", "~> 1.13"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
34
  spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "require_all"
35
36
 
36
37
  spec.add_dependency 'thor', '~> 0.19.1'
37
- spec.add_dependency 'selenium-webdriver', '~> 3.0', '>= 3.0.3'
38
- spec.add_dependency "watir_drops", "~> 0.5"
39
- spec.add_dependency 'watir_model', "~> 0.2"
40
- spec.add_dependency "watir_session", "~> 0.2"
38
+ spec.add_dependency 'data_magic'
39
+ spec.add_dependency 'activesupport'
41
40
  spec.add_dependency "git", "~> 1.3"
42
41
  spec.add_dependency "webdrivers", "~> 2.3"
43
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir_install
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Titus Fortner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,81 +53,61 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: thor
56
+ name: require_all
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.19.1
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.19.1
69
- - !ruby/object:Gem::Dependency
70
- name: selenium-webdriver
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
59
  - - ">="
77
60
  - !ruby/object:Gem::Version
78
- version: 3.0.3
79
- type: :runtime
61
+ version: '0'
62
+ type: :development
80
63
  prerelease: false
81
64
  version_requirements: !ruby/object:Gem::Requirement
82
65
  requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '3.0'
86
66
  - - ">="
87
67
  - !ruby/object:Gem::Version
88
- version: 3.0.3
68
+ version: '0'
89
69
  - !ruby/object:Gem::Dependency
90
- name: watir_drops
70
+ name: thor
91
71
  requirement: !ruby/object:Gem::Requirement
92
72
  requirements:
93
73
  - - "~>"
94
74
  - !ruby/object:Gem::Version
95
- version: '0.5'
75
+ version: 0.19.1
96
76
  type: :runtime
97
77
  prerelease: false
98
78
  version_requirements: !ruby/object:Gem::Requirement
99
79
  requirements:
100
80
  - - "~>"
101
81
  - !ruby/object:Gem::Version
102
- version: '0.5'
82
+ version: 0.19.1
103
83
  - !ruby/object:Gem::Dependency
104
- name: watir_model
84
+ name: data_magic
105
85
  requirement: !ruby/object:Gem::Requirement
106
86
  requirements:
107
- - - "~>"
87
+ - - ">="
108
88
  - !ruby/object:Gem::Version
109
- version: '0.2'
89
+ version: '0'
110
90
  type: :runtime
111
91
  prerelease: false
112
92
  version_requirements: !ruby/object:Gem::Requirement
113
93
  requirements:
114
- - - "~>"
94
+ - - ">="
115
95
  - !ruby/object:Gem::Version
116
- version: '0.2'
96
+ version: '0'
117
97
  - !ruby/object:Gem::Dependency
118
- name: watir_session
98
+ name: activesupport
119
99
  requirement: !ruby/object:Gem::Requirement
120
100
  requirements:
121
- - - "~>"
101
+ - - ">="
122
102
  - !ruby/object:Gem::Version
123
- version: '0.2'
103
+ version: '0'
124
104
  type: :runtime
125
105
  prerelease: false
126
106
  version_requirements: !ruby/object:Gem::Requirement
127
107
  requirements:
128
- - - "~>"
108
+ - - ">="
129
109
  - !ruby/object:Gem::Version
130
- version: '0.2'
110
+ version: '0'
131
111
  - !ruby/object:Gem::Dependency
132
112
  name: git
133
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +136,7 @@ dependencies:
156
136
  - - "~>"
157
137
  - !ruby/object:Gem::Version
158
138
  version: '2.3'
159
- description: '"Watir Framework provides everything necessary to quickly create maintainable
139
+ description: '"Watir Install provides everything necessary to quickly create maintainable
160
140
  automated test suites in an understandable and enjoyable way."'
161
141
  email:
162
142
  - titusfortner@gmail.com
@@ -177,29 +157,32 @@ files:
177
157
  - bin/watir
178
158
  - lib/watir_install.rb
179
159
  - lib/watir_install/cli.rb
180
- - lib/watir_install/generators/new_project.rb
181
- - lib/watir_install/generators/new_project/config/data/data.yml.tt
182
- - lib/watir_install/generators/new_project/cucumber.yml.tt
183
- - lib/watir_install/generators/new_project/features/search.feature.tt
184
- - lib/watir_install/generators/new_project/features/step_definitions/search_steps.rb.tt
185
- - lib/watir_install/generators/new_project/features/support/env.rb.tt
186
- - lib/watir_install/generators/new_project/features/support/hooks.rb.tt
187
- - lib/watir_install/generators/new_project/features/support/pages/home.rb.tt
188
- - lib/watir_install/generators/new_project/features/support/pages/results.rb.tt
189
- - lib/watir_install/generators/new_project/gemfile.rb.tt
190
- - lib/watir_install/generators/new_project/gitignore.rb.tt
191
- - lib/watir_install/generators/new_project/lib/models/search.rb.tt
192
- - lib/watir_install/generators/new_project/lib/name.rb.tt
193
- - lib/watir_install/generators/new_project/lib/pages/home.rb.tt
194
- - lib/watir_install/generators/new_project/lib/pages/results.rb.tt
195
- - lib/watir_install/generators/new_project/license.rb.tt
196
- - lib/watir_install/generators/new_project/rakefile.rb.tt
197
- - lib/watir_install/generators/new_project/readme.rb.tt
198
- - lib/watir_install/generators/new_project/rspec.rb.tt
199
- - lib/watir_install/generators/new_project/ruby-version.rb.tt
200
- - lib/watir_install/generators/new_project/spec/search_spec.rb.tt
201
- - lib/watir_install/generators/new_project/spec/spec_helper.rb.tt
202
- - lib/watir_install/generators/new_project/travis.rb.tt
160
+ - lib/watir_install/generators/data.rb
161
+ - lib/watir_install/generators/data/spec/support/data/data.rb.tt
162
+ - lib/watir_install/generators/example.rb
163
+ - lib/watir_install/generators/example/spec/search_spec.rb.tt
164
+ - lib/watir_install/generators/example/spec/support/data/search.rb.tt
165
+ - lib/watir_install/generators/example/spec/support/pages/home.rb.tt
166
+ - lib/watir_install/generators/example/spec/support/pages/results.rb.tt
167
+ - lib/watir_install/generators/new.rb
168
+ - lib/watir_install/generators/new/cucumber.yml.tt
169
+ - lib/watir_install/generators/new/gemfile.rb.tt
170
+ - lib/watir_install/generators/new/gitignore.rb.tt
171
+ - lib/watir_install/generators/new/rakefile.rb.tt
172
+ - lib/watir_install/generators/new/readme.rb.tt
173
+ - lib/watir_install/generators/new/rspec.rb.tt
174
+ - lib/watir_install/generators/new/ruby-version.rb.tt
175
+ - lib/watir_install/generators/new/spec/sauce_helpers.rb.tt
176
+ - lib/watir_install/generators/new/spec/spec_helper.rb.tt
177
+ - lib/watir_install/generators/new/spec/support/data/base.rb.tt
178
+ - lib/watir_install/generators/new/spec/support/pages/base.rb.tt
179
+ - lib/watir_install/generators/new/spec/support/sauce_helpers.rb.tt
180
+ - lib/watir_install/generators/new/travis.rb.tt
181
+ - lib/watir_install/generators/page.rb
182
+ - lib/watir_install/generators/pages/spec/support/pages/page.rb.tt
183
+ - lib/watir_install/generators/test.rb
184
+ - lib/watir_install/generators/tests/spec/crud.rb.tt
185
+ - lib/watir_install/generators/tests/spec/spec.rb.tt
203
186
  - watir_install.gemspec
204
187
  homepage: https://github.com/titusfortner/watir_install
205
188
  licenses:
@@ -1,3 +0,0 @@
1
- search:
2
- search_input: 'foo'
3
- first_result: 'Foobar - Wikipedia'
@@ -1,6 +0,0 @@
1
- Feature: Google
2
-
3
- Scenario: Search Results Found
4
- Given I am on the Google Home Page
5
- When I submit a search
6
- Then I should see the results displayed
@@ -1,13 +0,0 @@
1
- Given 'I am on the Google Home Page' do
2
- @search_page = visit <%= name.split('_').map(&:capitalize).join %>::Home
3
- @search_data = @search_page.data_for(:search)
4
- end
5
-
6
- When 'I submit a search' do
7
- @search_page.search(@search_data['search_input'])
8
- end
9
-
10
- Then 'I should see the results displayed' do
11
- results_page = on <%= name.split('_').map(&:capitalize).join %>::Results
12
- expect(results_page.first_result).to include @search_data['first_result']
13
- end
@@ -1,11 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
-
3
- require 'cucumber'
4
- require 'rspec'
5
- require 'page-object'
6
- require 'require_all'
7
- require 'data_magic'
8
-
9
- DataMagic.load 'data.yml'
10
-
11
- World(PageObject::PageFactory)
@@ -1,9 +0,0 @@
1
- require 'watir'
2
-
3
- Before do
4
- @browser = Watir::Browser.new :chrome
5
- end
6
-
7
- After do
8
- @browser.close
9
- end
@@ -1,19 +0,0 @@
1
- require 'page-object'
2
-
3
- module <%= name.split('_').map(&:capitalize).join %>
4
- class Home
5
- include PageObject
6
- include DataMagic
7
-
8
- page_url "https://www.google.com/"
9
-
10
- text_field(:search_input, name: 'q')
11
- button(:submit, name: 'btnG')
12
-
13
- def search(data)
14
- populate_page_with data_for :search
15
- self.submit
16
- end
17
- end
18
- end
19
-
@@ -1,13 +0,0 @@
1
- module <%= name.split('_').map(&:capitalize).join %>
2
- class Results
3
- include PageObject
4
-
5
- button(:submit, name: 'btnG')
6
- h3(:result, css: '.g h3')
7
-
8
- def first_result
9
- self.result
10
- end
11
-
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- require "watir_drops"
2
- require "watir_model"
3
- require '<%= name.downcase %>/pages/home'
4
- require '<%= name.downcase %>/pages/results'
5
- require '<%= name.downcase %>/models/search'
@@ -1,12 +0,0 @@
1
- module <%= name.split('_').map(&:capitalize).join %>
2
- class Results < WatirDrops::PageObject
3
-
4
- elements(:results) { browser.divs(class: 'g') }
5
- element(:title) { |element| element.h3 }
6
-
7
- def first_result
8
- title(results.first).text
9
- end
10
-
11
- end
12
- end
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 <%= user_name %>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,16 +0,0 @@
1
- <% if test_runner == 'cucumber' -%>
2
- require 'cucumber'
3
- require 'cucumber/rake/task'
4
-
5
- Cucumber::Rake::Task.new(:features) do |t|
6
- t.cucumber_opts = "features --format pretty"
7
- end
8
-
9
- task :default => :features
10
- <% else -%>
11
- require "rspec/core/rake_task"
12
-
13
- RSpec::Core::RakeTask.new(:spec)
14
-
15
- task :default => :spec
16
- <% end -%>
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
- require "<%= name.downcase %>"
3
-
4
- include <%= name.split('_').map(&:capitalize).join %>
5
-
6
- RSpec.configure do |config|
7
- config.before(:each) do
8
- @browser = Watir::Browser.new
9
- WatirDrops::PageObject.browser = @browser
10
- end
11
-
12
- config.after(:each) do
13
- @browser.quit
14
- end
15
- end
@@ -1,100 +0,0 @@
1
- require 'thor/group'
2
- require 'git'
3
- require 'active_support/inflector'
4
-
5
- module WatirInstall
6
- module Generators
7
- class NewProject < Thor::Group
8
- include Thor::Actions
9
-
10
- argument :name, type: :string, desc: 'The name of the test project'
11
- argument :no_git, type: :string, default: 'false', desc: 'Do not initialize project with git'
12
- argument :test_runner, type: :string, default: 'rspec', desc: 'Specify RSpec or Cucumber'
13
-
14
- def self.source_root
15
- "#{File.dirname(__FILE__)}/new_project"
16
- end
17
-
18
- def git
19
- @git ||= Git.init(name)
20
- end
21
-
22
- def user_name
23
- @user_name ||= git.config["user.name"] if git?
24
- @user_name ||= ask "Enter your Name: "
25
- @git.config('user.name', @user_name) if git?
26
- @user_name
27
- end
28
-
29
- def user_email
30
- @user_email ||= git.config["user.email"] if git?
31
- @user_email ||= ask "Enter your Email: "
32
- @git.config('user.email', @user_email) if git?
33
- @user_email
34
- end
35
-
36
- def root_files
37
- template "gemfile.rb.tt", "#{name}/Gemfile"
38
- template "gitignore.rb.tt", "#{name}/.gitignore"
39
- template "license.rb.tt", "#{name}/LICENSE.txt"
40
- template "rakefile.rb.tt", "#{name}/Rakefile"
41
- template "readme.rb.tt", "#{name}/README.md"
42
- template "ruby-version.rb.tt", "#{name}/.ruby-version"
43
- template "travis.rb.tt", "#{name}/.travis.yml"
44
- if test_runner == 'cucumber'
45
- template "cucumber.yml.tt", "#{name}/.cucumber.yml"
46
- else
47
- template "rspec.rb.tt", "#{name}/.rspec"
48
- end
49
- end
50
-
51
- def lib_files
52
- if test_runner == 'cucumber'
53
- template "features/support/pages/home.rb.tt", "#{name}/features/support/pages/home.rb.rb"
54
- template "features/support/pages/results.rb.tt", "#{name}/features/support/pages/results.rb"
55
- else
56
- template "lib/name.rb.tt", "#{name}/lib/#{name}.rb"
57
- template "lib/pages/home.rb.tt", "#{name}/lib/#{name}/pages/home.rb"
58
- template "lib/pages/results.rb.tt", "#{name}/lib/#{name}/pages/results.rb"
59
- end
60
- end
61
-
62
- def data_files
63
- if test_runner == 'cucumber'
64
- template "config/data/data.yml.tt", "#{name}/config/data/data.yml"
65
- else
66
- template "lib/models/search.rb.tt", "#{name}/lib/#{name}/models/search.rb"
67
- end
68
- end
69
-
70
- def test_files
71
- if test_runner == 'cucumber'
72
- template "features/support/env.rb.tt", "#{name}/features/support/env.rb"
73
- template "features/support/hooks.rb.tt", "#{name}/features/support/hooks.rb"
74
- template "features/step_definitions/search_steps.rb.tt", "#{name}/features/step_definitions/search_steps.rb"
75
- template "features/search.feature.tt", "#{name}/features/search.feature"
76
-
77
- else
78
- template "spec/search_spec.rb.tt", "#{name}/spec/search_spec.rb"
79
- template "spec/spec_helper.rb.tt", "#{name}/spec/spec_helper.rb"
80
- end
81
- end
82
-
83
- def bundle
84
- Dir.chdir(name)
85
- system 'bundle install'
86
- end
87
-
88
- def initial_commit
89
- if git?
90
- git.lib.add('.', all: true)
91
- git.commit("initial commit", {all: true})
92
- end
93
- end
94
-
95
- def git?
96
- no_git != 'true'
97
- end
98
- end
99
- end
100
- end