watir_install 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/README.md +3 -0
- data/lib/watir_install/cli.rb +3 -2
- data/lib/watir_install/generators/data.rb +7 -1
- data/lib/watir_install/generators/new.rb +3 -1
- data/lib/watir_install/generators/new/spec/spec_helper.rb.tt +13 -6
- data/lib/watir_install/generators/new/spec/support/pages/base.rb.tt +3 -1
- data/lib/watir_install/generators/new/spec/support/site.rb.tt +15 -0
- data/lib/watir_install/generators/page.rb +8 -2
- data/lib/watir_install/generators/pages/spec/support/pages/page.rb.tt +13 -11
- data/lib/watir_install/generators/test.rb +8 -5
- data/lib/watir_install/generators/tests/spec/crud.rb.tt +15 -13
- data/lib/watir_install/generators/tests/spec/spec.rb.tt +7 -5
- data/watir_install.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89ce76e60591791aba7f5eda50f9f4c9ffde6b6b
|
4
|
+
data.tar.gz: e6168652410aa1d91c537775f67036a14e2e4d57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f980387a3ca832725133889489cd37327d121cc1c14d88621f1852308d419169951c64c298bd3268037d2481eece2598b6a6909105934dd3a54d02f059150e55
|
7
|
+
data.tar.gz: 2a2d0394cd58940f651a423e5da510b17f952e38c4a034c3c0c5472e0b70d140e22b1019d147d237b1cb514ae6ef2a1f660547007622c2148f0a28a1092fa5a2
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
data/lib/watir_install/cli.rb
CHANGED
@@ -7,9 +7,10 @@ module WatirInstall
|
|
7
7
|
|
8
8
|
desc "new <project_name>", "Create a new test project"
|
9
9
|
method_option :no_git, type: :boolean, desc: "Do not initialize project with git"
|
10
|
+
method_option :base_url, type: :string, desc: "Set a root url for the project"
|
10
11
|
|
11
12
|
def new(name)
|
12
|
-
WatirInstall::Generators::New.start([name, options[:no_git]])
|
13
|
+
WatirInstall::Generators::New.start([name, options[:base_url], options[:no_git]])
|
13
14
|
end
|
14
15
|
|
15
16
|
desc "generate <generated_type>", "Generate a new object"
|
@@ -45,7 +46,7 @@ module WatirInstall
|
|
45
46
|
|
46
47
|
desc "generate_scaffold <Class>", "Generate collection of data, pages and tests"
|
47
48
|
|
48
|
-
def generate_scaffold(klass, url,
|
49
|
+
def generate_scaffold(klass, url, _form, *args)
|
49
50
|
WatirInstall::Generators::Test.start([klass, 'true'])
|
50
51
|
|
51
52
|
WatirInstall::Generators::Data.start([klass, *args])
|
@@ -21,12 +21,18 @@ module WatirInstall
|
|
21
21
|
"#{File.dirname(__FILE__)}/data"
|
22
22
|
end
|
23
23
|
|
24
|
+
def git
|
25
|
+
@git = Git.open('./') if Dir.entries('./').include?('.git')
|
26
|
+
end
|
27
|
+
|
24
28
|
def name
|
25
29
|
Dir.pwd[/[^\/]*$/]
|
26
30
|
end
|
27
31
|
|
28
32
|
def data_files
|
29
|
-
|
33
|
+
file = "#{Dir.pwd}/spec/support/data/#{klass.downcase}.rb"
|
34
|
+
template "spec/support/data/data.rb.tt", file
|
35
|
+
@git.add(file) if @git
|
30
36
|
end
|
31
37
|
|
32
38
|
end
|
@@ -8,7 +8,8 @@ module WatirInstall
|
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
10
|
argument :name, type: :string, desc: 'The name of the test project'
|
11
|
-
argument :
|
11
|
+
argument :base_url, type: :string, required: false, default: '', desc: 'Set a root url for the project'
|
12
|
+
argument :no_git, type: :string, required: false, default: 'false', desc: 'Do not initialize project with git'
|
12
13
|
|
13
14
|
def self.source_root
|
14
15
|
"#{File.dirname(__FILE__)}/new"
|
@@ -57,6 +58,7 @@ module WatirInstall
|
|
57
58
|
|
58
59
|
def support_files
|
59
60
|
template "spec/support/sauce_helpers.rb.tt", "#{name}/spec/support/sauce_helpers.rb"
|
61
|
+
template "spec/support/site.rb.tt", "#{name}/spec/support/site.rb"
|
60
62
|
end
|
61
63
|
|
62
64
|
def bundle
|
@@ -1,28 +1,35 @@
|
|
1
|
+
ENV['USE_SAUCE'] ||= 'false'
|
2
|
+
<% unless base_url.empty? -%>
|
3
|
+
ENV['BASE_URL'] ||= "<%= base_url %>"
|
4
|
+
<% end -%>
|
5
|
+
|
1
6
|
require "watir_drops"
|
2
7
|
require "watir_model"
|
3
8
|
require "require_all"
|
4
9
|
require_rel "support/data"
|
5
10
|
require_rel "support/pages"
|
6
|
-
|
11
|
+
require_rel "support/site"
|
12
|
+
require_rel 'support/sauce_helpers' if ENV['USE_SAUCE'] == 'true'
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
14
|
+
include <%= name.split('_').map(&:capitalize).join %>
|
15
|
+
include Page
|
11
16
|
|
12
17
|
RSpec.configure do |config|
|
13
18
|
config.include SauceHelpers if ENV['USE_SAUCE'] == 'true'
|
14
19
|
|
15
|
-
config.before(:each) do
|
20
|
+
config.before(:each) do |test|
|
16
21
|
@browser = if ENV['USE_SAUCE'] == 'true'
|
17
22
|
initialize_driver(test.full_description)
|
18
23
|
else
|
19
24
|
Watir::Browser.new
|
20
25
|
end
|
21
26
|
|
22
|
-
|
27
|
+
Base.browser = @browser
|
28
|
+
Site.base_url = ENV['BASE_URL']
|
23
29
|
end
|
24
30
|
|
25
31
|
config.after(:each) do
|
32
|
+
submit_results(@browser.wd.session_id, !test.exception) if ENV['USE_SAUCE'] == 'true'
|
26
33
|
@browser.quit
|
27
34
|
end
|
28
35
|
end
|
@@ -16,12 +16,18 @@ module WatirInstall
|
|
16
16
|
"#{File.dirname(__FILE__)}/pages"
|
17
17
|
end
|
18
18
|
|
19
|
+
def git
|
20
|
+
@git = Git.open('./') if Dir.entries('./').include?('.git')
|
21
|
+
end
|
22
|
+
|
19
23
|
def name
|
20
24
|
Dir.pwd[/[^\/]*$/]
|
21
25
|
end
|
22
26
|
|
23
|
-
def
|
24
|
-
|
27
|
+
def page_files
|
28
|
+
file = "#{Dir.pwd}/spec/support/pages/#{klass.downcase.gsub('::', '/')}.rb"
|
29
|
+
template "spec/support/pages/page.rb.tt", file
|
30
|
+
@git.add(file) if @git
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|
@@ -1,22 +1,24 @@
|
|
1
|
-
module <%= name.split('_').map(&:capitalize).join
|
2
|
-
|
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
|
1
|
+
module <%= name.split('_').map(&:capitalize).join %>
|
2
|
+
class <%= klass.gsub('::', '') %> < Page::Base
|
9
3
|
|
4
|
+
<% if url.empty? -%>
|
5
|
+
# Define url represented by page object if appropriate
|
10
6
|
# page_url { }
|
11
7
|
<% else -%>
|
12
|
-
|
13
|
-
|
8
|
+
<% if url =~ %r{^(about|data|https?):}i -%>
|
9
|
+
page_url { "<%= url %>" }
|
10
|
+
<% else -%>
|
11
|
+
page_url { "#{Site.base_url}<%= url %>" }
|
12
|
+
<% end -%>
|
13
|
+
<% end -%>
|
14
|
+
|
14
15
|
|
15
16
|
<% if elements.empty? -%>
|
16
17
|
# Define elements representing contents of page
|
17
18
|
<% end -%>
|
18
19
|
# Specify full Watir locator inside block
|
19
20
|
# element(:foo) { browser.div(id: 'foo') }
|
21
|
+
|
20
22
|
<% elements.each do |element| -%>
|
21
23
|
element(:<%= element %>) { }
|
22
24
|
<% end -%>
|
@@ -24,7 +26,7 @@ page_url { "<%= url %>" }
|
|
24
26
|
element(:submit) { browser.button(visible: true) }
|
25
27
|
|
26
28
|
def submit_form(<%= form.downcase %> = nil)
|
27
|
-
<%= form.downcase %> ||=
|
29
|
+
<%= form.downcase %> ||= Data::<%= form %>.new
|
28
30
|
fill_form(<%= form.downcase %>)
|
29
31
|
submit.click
|
30
32
|
<%= form.downcase %>
|
@@ -15,16 +15,19 @@ module WatirInstall
|
|
15
15
|
"#{File.dirname(__FILE__)}/tests"
|
16
16
|
end
|
17
17
|
|
18
|
+
def git
|
19
|
+
@git = Git.open('./') if Dir.entries('./').include?('.git')
|
20
|
+
end
|
21
|
+
|
18
22
|
def name
|
19
23
|
Dir.pwd[/[^\/]*$/]
|
20
24
|
end
|
21
25
|
|
22
26
|
def data_files
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
27
|
+
file = "#{Dir.pwd}/spec/#{klass.downcase}_spec.rb"
|
28
|
+
erb = form == 'true' ? "crud" : "spec"
|
29
|
+
template "spec/#{erb}.rb.tt", file
|
30
|
+
@git.add(file) if @git
|
28
31
|
end
|
29
32
|
|
30
33
|
end
|
@@ -1,26 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module <%= name.split('_').map(&:capitalize).join %>
|
4
|
+
describe <%= name.split('_').map(&:capitalize).join %> do
|
5
|
+
let(:<%= klass.downcase %>) { Data::<%= klass %>.new }
|
5
6
|
|
6
|
-
|
7
|
+
it 'creates' do
|
7
8
|
|
8
|
-
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
it 'shows' do
|
11
12
|
|
12
|
-
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
+
it 'lists' do
|
15
16
|
|
16
|
-
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
+
it 'edits' do
|
19
20
|
|
20
|
-
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
+
it 'deletes' do
|
23
24
|
|
24
|
-
|
25
|
+
end
|
25
26
|
|
26
|
-
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module <%= name.split('_').map(&:capitalize).join %>
|
4
|
+
describe Data::<%= klass %> do
|
4
5
|
|
5
|
-
|
6
|
+
let(:<%= klass.downcase %>) { Data::<%= klass %>.new }
|
6
7
|
|
7
8
|
<% if specs.empty? -%>
|
8
|
-
|
9
|
+
# Add RSpec `it` statements
|
9
10
|
<% else -%>
|
10
11
|
<% specs.each do |spec| %>
|
11
|
-
|
12
|
+
it '<%= spec -%>' do
|
12
13
|
|
13
|
-
|
14
|
+
end
|
14
15
|
<% end -%>
|
15
16
|
<% end -%>
|
16
17
|
|
18
|
+
end
|
17
19
|
end
|
data/watir_install.gemspec
CHANGED
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.3.
|
4
|
+
version: 0.3.1
|
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-05-
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/watir_install/generators/new/spec/support/data/base.rb.tt
|
178
178
|
- lib/watir_install/generators/new/spec/support/pages/base.rb.tt
|
179
179
|
- lib/watir_install/generators/new/spec/support/sauce_helpers.rb.tt
|
180
|
+
- lib/watir_install/generators/new/spec/support/site.rb.tt
|
180
181
|
- lib/watir_install/generators/new/travis.rb.tt
|
181
182
|
- lib/watir_install/generators/page.rb
|
182
183
|
- lib/watir_install/generators/pages/spec/support/pages/page.rb.tt
|