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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b1d7616e709714e853171cf89e54227aa6eb3a1
4
- data.tar.gz: '038db3182ad033c07b53655482e1e2f7a11db91e'
3
+ metadata.gz: 89ce76e60591791aba7f5eda50f9f4c9ffde6b6b
4
+ data.tar.gz: e6168652410aa1d91c537775f67036a14e2e4d57
5
5
  SHA512:
6
- metadata.gz: d13c3fd8dc25d3f9ca9c3a086e92b5f74065a27271801dfa23e131e4eaacbbfce85a7f8bc250176087f6c89f6abb7ee03adb9f66c2b918c0a573887e3f373b8b
7
- data.tar.gz: ee596feba54b805885cc0ac154475a583de453a607f9789562fe025ed53b4c673abb22d8714c435f23ae1ed1a520ea9002894abcdd2f2e4ee4bf6e21991002ea
6
+ metadata.gz: f980387a3ca832725133889489cd37327d121cc1c14d88621f1852308d419169951c64c298bd3268037d2481eece2598b6a6909105934dd3a54d02f059150e55
7
+ data.tar.gz: 2a2d0394cd58940f651a423e5da510b17f952e38c4a034c3c0c5472e0b70d140e22b1019d147d237b1cb514ae6ef2a1f660547007622c2148f0a28a1092fa5a2
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 0.3.1 (2017-05-25)
2
+
3
+ * Fix name spacing
4
+ * Fix Sauce issues
5
+ * Add base_url support to new command
6
+ * Add git tracking for generated files
7
+
1
8
  ### 0.3.0 (2017-05-23)
2
9
 
3
10
  * Remove sample code from new command
data/README.md CHANGED
@@ -60,6 +60,9 @@ the recommended default configurations to easily create and maintain your test s
60
60
 
61
61
  $ watir generate scaffold ObjectName el1 el2 el3 el4 --url http://example.com/object
62
62
 
63
+ ## See Example Project
64
+
65
+ $ watir example
63
66
 
64
67
  ## Contributing
65
68
 
@@ -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, form, *args)
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
- template "spec/support/data/data.rb.tt", "#{Dir.pwd}/spec/support/data/#{klass.downcase}.rb"
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 :no_git, type: :string, default: 'false', desc: 'Do not initialize project with git'
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
- include <%= name.split('_').map(&:capitalize).join %>
11
+ require_rel "support/site"
12
+ require_rel 'support/sauce_helpers' if ENV['USE_SAUCE'] == 'true'
7
13
 
8
- if ENV['USE_SAUCE'] == 'true'
9
- require_rel 'support/sauce_helpers'
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
- WatirDrops::PageObject.browser = @browser
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
@@ -1,5 +1,7 @@
1
1
  module <%= name.split('_').map(&:capitalize).join %>
2
- class Base < WatirDrops::PageObject
2
+ module Page
3
+ class Base < WatirDrops::PageObject
3
4
 
5
+ end
4
6
  end
5
7
  end
@@ -0,0 +1,15 @@
1
+ module <%= name.split('_').map(&:capitalize).join %>
2
+ class Site
3
+
4
+ class << self
5
+ def base_url=(base_url)
6
+ @@base_url = base_url
7
+ end
8
+
9
+ def base_url
10
+ @@base_url
11
+ end
12
+ end
13
+
14
+ end
15
+ 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 data_files
24
- template "spec/support/pages/page.rb.tt", "#{Dir.pwd}/spec/support/pages/#{klass.downcase.gsub('::', '/')}.rb"
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
- <% 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
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
- page_url { "<%= url %>" }
13
- <% end %>
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 %> ||= <%= name.split('_').map(&:capitalize).join %>::Data::<%= form %>.new
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
- 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
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
- describe <%= name.split('_').map(&:capitalize).join %> do
4
- let(:<%= klass.downcase %>) { <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %>.new }
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
- it 'creates' do
7
+ it 'creates' do
7
8
 
8
- end
9
+ end
9
10
 
10
- it 'shows' do
11
+ it 'shows' do
11
12
 
12
- end
13
+ end
13
14
 
14
- it 'lists' do
15
+ it 'lists' do
15
16
 
16
- end
17
+ end
17
18
 
18
- it 'edits' do
19
+ it 'edits' do
19
20
 
20
- end
21
+ end
21
22
 
22
- it 'deletes' do
23
+ it 'deletes' do
23
24
 
24
- end
25
+ end
25
26
 
26
- end
27
+ end
28
+ end
@@ -1,17 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %> do
3
+ module <%= name.split('_').map(&:capitalize).join %>
4
+ describe Data::<%= klass %> do
4
5
 
5
- let(:<%= klass.downcase %>) { <%= name.split('_').map(&:capitalize).join %>::Data::<%= klass %>.new }
6
+ let(:<%= klass.downcase %>) { Data::<%= klass %>.new }
6
7
 
7
8
  <% if specs.empty? -%>
8
- # Add RSpec `it` statements
9
+ # Add RSpec `it` statements
9
10
  <% else -%>
10
11
  <% specs.each do |spec| %>
11
- it '<%= spec -%>' do
12
+ it '<%= spec -%>' do
12
13
 
13
- end
14
+ end
14
15
  <% end -%>
15
16
  <% end -%>
16
17
 
18
+ end
17
19
  end
@@ -4,7 +4,7 @@ $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.3.0"
7
+ spec.version = "0.3.1"
8
8
  spec.authors = ["Titus Fortner"]
9
9
  spec.email = ["titusfortner@gmail.com"]
10
10
 
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.0
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-23 00:00:00.000000000 Z
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