bret-watircraft 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,27 @@
1
+ === 0.5.0 / 2009-04-10
2
+
3
+ This release adds a new artifact to your project: methods libraries. It also
4
+ adds commands for use in script\console.
5
+
6
+ You will need to update your project using "watircraft ." to use this
7
+ release.
8
+
9
+ New Features
10
+
11
+ * New generator: "methods". This creates templates for methods that can be
12
+ be used with both rspec (specs) and cucumber (steps). Use
13
+ "script\generate methods" for details.
14
+ * Added commands to navigate tables in script\console. The page.tables method
15
+ will return a list of the tables defined on the page. The table.fields and
16
+ table.elements methods return lists of fields and elements defined for the
17
+ table.
18
+
19
+ But Fixes
20
+
21
+ * When using Rspec 1.2.x, you should be able to execute specs simply by
22
+ "running" the file with Ruby. This worked pre 1.2 and now works with 1.2.
23
+ (Fixed both project specs and WatirCraft's own unit tests.)
24
+
1
25
  === 0.4.5 / 2009-04-07
2
26
 
3
27
  New Features
@@ -32,6 +32,7 @@ spec/fake_table.rb
32
32
  spec/fixtures_spec.rb
33
33
  spec/fixture_spec.rb
34
34
  spec/hash_spec.rb
35
+ spec/method_generator_spec.rb
35
36
  spec/object_spec.rb
36
37
  spec/page_generator_spec.rb
37
38
  spec/page_spec.rb
@@ -49,6 +50,8 @@ spec/sandbox/fixtures/users.yml
49
50
  spec/sandbox/flows
50
51
  spec/sandbox/flows/batman.rb
51
52
  spec/sandbox/flows/robin.rb
53
+ spec/sandbox/methods
54
+ spec/sandbox/methods/spiderman.rb
52
55
  spec/sandbox/pages
53
56
  spec/sandbox/pages/foo
54
57
  spec/sandbox/pages/foo/bar_page.rb
@@ -83,6 +86,11 @@ app_generators/watircraft/templates/spec_initialize.rb
83
86
  app_generators/watircraft/templates/world.rb
84
87
  app_generators/watircraft/USAGE
85
88
  app_generators/watircraft/watircraft_generator.rb
89
+ watircraft_generators/method
90
+ watircraft_generators/method/method_generator.rb
91
+ watircraft_generators/method/templates
92
+ watircraft_generators/method/templates/method.rb.erb
93
+ watircraft_generators/method/USAGE
86
94
  watircraft_generators/page
87
95
  watircraft_generators/page/page_generator.rb
88
96
  watircraft_generators/page/templates
@@ -9,22 +9,6 @@ An example test suite for this framework can be found in the framework
9
9
  examples project on github. Look in the +watircraft+ directory.
10
10
  * http://github.com/bret/framework-examples
11
11
 
12
- == QUESTIONS AND FEEDBACK
13
-
14
- Known bugs and road map. You can report bugs and request features here.
15
- * http://watircraft.lighthouseapp.com/projects/28400-watircraft/overview
16
-
17
- Join our mailing list for WatirCraft users.
18
- * http://tech.groups.yahoo.com/group/watir-framework
19
-
20
- The WatirCraft framework is developed by WatirCraft LLC, based on Taza[http://github.com/scudco/taza/wikis].
21
- Please send your comments to us at feedback@watircraft.com[mailto:feedback@watircraft.com]
22
- We love getting your emails.
23
-
24
- WatirCraft LLC provides training and consulting for Watir, Ruby and the
25
- WatirCraft framework.
26
- * http://www.watircraft.com
27
-
28
12
  == LICENSE
29
13
 
30
14
  (The MIT License)
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 4
3
- :patch: 5
2
+ :minor: 5
3
+ :patch: 0
4
4
  :major: 0
@@ -11,7 +11,7 @@ WatirCraft allows you to create Rspec tests, Cucumber tests or both.
11
11
 
12
12
  Rspec Tests
13
13
 
14
- 4. Create Test: script\generate spec testname
14
+ 4. Create a test: script\generate spec testname
15
15
  5. Edit the file, adding Watir commands where specified.
16
16
  6. Run one test: ruby test\specs\testname_spec.rb
17
17
  Or you can just use F5 if using the Scite editor.
@@ -19,7 +19,7 @@ Rspec Tests
19
19
 
20
20
  Cucumber Tests
21
21
 
22
- 8. Create Feature. Place your feature-tests in the test\features directory.
22
+ 8. Create a feature. Place your feature-tests in the test\features directory.
23
23
  They should follow the standard cucumber format.
24
24
  9. Create Steps File: script\generate steps filename
25
25
  10. Dry Run: cucumber test\features\featurename
@@ -34,5 +34,11 @@ Pages are optional and can be used with either Rspec or Cucumber tests.
34
34
  15. Create a page: script\generate page pagename
35
35
  16. Pages can be referenced from rspec tests or cucumber steps.
36
36
 
37
+ Methods are optional cna be used with either Rspec or Cucumber tests.
38
+
39
+ 17. Create a method: script\generate method methodname
40
+ 18. Methods can be referenced from rspec tests, cucumber steps or from
41
+ other methods.
42
+
37
43
  Enter "script\generate" to see a complete list of WatirCraft files that
38
44
  you can create.
@@ -4,6 +4,13 @@
4
4
  require 'init/site_start'
5
5
  require 'spec'
6
6
  require 'mocha'
7
+ begin
8
+ # Needed for rspec 1.2.x. (Allows "ruby" to run specs.)
9
+ # But not available before that.
10
+ require 'spec/autorun'
11
+ rescue LoadError
12
+ nil
13
+ end
7
14
 
8
15
  Spec::Runner.configure do |config|
9
16
  config.mock_with :mocha
@@ -69,6 +69,7 @@ class WatircraftGenerator < RubiGen::Base
69
69
  lib/init
70
70
  lib/pages
71
71
  lib/steps
72
+ lib/methods
72
73
  test
73
74
  test/specs
74
75
  test/features
@@ -29,10 +29,14 @@ module Taza
29
29
  def filters # :nodoc:
30
30
  @filters ||= Hash.new { [] }
31
31
  end
32
-
32
+
33
33
  def fields # :nodoc:
34
34
  @fields ||= []
35
35
  end
36
+
37
+ def tables # :nodoc:
38
+ @tables ||= []
39
+ end
36
40
 
37
41
  def url string=nil
38
42
  if string.nil?
@@ -141,6 +145,7 @@ module Taza
141
145
  # subclass and then allows its class methods to define fields and
142
146
  # elements on the table.
143
147
  def table(name, &block)
148
+ tables << name
144
149
  # create subclass for the table
145
150
  sub_class = Class.new(WatirCraft::Table)
146
151
  sub_class.class_eval &block
@@ -221,6 +226,11 @@ module Taza
221
226
  self.class.fields.map &:to_s
222
227
  end
223
228
 
229
+ # Return the names of the tables defined for the page.
230
+ def tables
231
+ self.class.tables.map &:to_s
232
+ end
233
+
224
234
  # Returns a hash with the names and values of the specified fields.
225
235
  # If no fields are specifieds, all fields on the page are used.
226
236
  def values field_names=fields
@@ -27,8 +27,8 @@ module Taza
27
27
 
28
28
  # Because of the way #merge works, the settings at the bottom of the list
29
29
  # trump those at the top.
30
- settings = environment_settings.merge(
31
- default_settings.merge(
30
+ settings = default_settings.merge(
31
+ environment_settings.merge(
32
32
  config_file.merge(
33
33
  env_settings)))
34
34
 
@@ -44,8 +44,6 @@ module Taza
44
44
  end
45
45
 
46
46
  end
47
- include Spec::Matchers
48
-
49
47
 
50
48
  @@before_browser_closes = Proc.new() {}
51
49
  # Use this to do something with the browser before it closes, but note that it is a class method which
@@ -79,15 +77,19 @@ module Taza
79
77
  # (not sure if this is a useful feature or not)
80
78
  def initialize(params={}, &block)
81
79
  @site = self
82
- @module_name = self.class.parent.to_s
80
+ @parent_module = self.class.parent
81
+ @module_name = @parent_module.to_s
83
82
  @class_name = self.class.to_s.split("::").last
84
83
 
85
84
  define_flows
86
-
85
+ load_methods_files
86
+
87
87
  page_loader = PageLoader.new(@module_name, pages_path)
88
88
  @pages = page_loader.page_names
89
89
  @methods_module = page_loader.page_methods
90
90
  @methods_module.send(:include, Methods)
91
+ @methods_module.send(:include, Spec::Matchers)
92
+ @methods_module.send(:include, @parent_module::Methods) if defined?(@parent_module::Methods)
91
93
  self.extend(@methods_module)
92
94
 
93
95
  @browser = params[:browser]
@@ -160,7 +162,6 @@ module Taza
160
162
 
161
163
  def initialize_context!(context)
162
164
  context.extend @methods_module
163
- context.extend Spec::Matchers
164
165
  context.site = @site
165
166
  context.browser = @site.browser
166
167
  context
@@ -176,32 +177,20 @@ module Taza
176
177
  require file
177
178
  end
178
179
  end
180
+
181
+ def load_methods_files # :nodoc:
182
+ Dir.glob(methods_path) do |file|
183
+ require file
184
+ end
185
+ end
179
186
 
180
- # This is used to call a flow belonging to the site
181
- #
182
- # Example:
183
- # Google.new do |google|
184
- # google.flow(:perform_search, :query => "taza")
185
- # end
186
- #
187
- # Where the flow would be defined under lib/sites/google/flows/perform_search.rb and look like:
188
- # class PerformSearch < Taza::Flow
189
- # alias :google :site
190
- #
191
- # def run(params={})
192
- # google.search.set params[:query]
193
- # google.submit.click
194
- # end
195
- # end
196
-
197
- #
198
- # methods that neither depend on or modify state
199
- #
200
-
201
- private
202
187
  def flows_path # :nodoc:
203
188
  File.join(path,'flows','*.rb')
204
189
  end
190
+
191
+ def methods_path # :nodoc:
192
+ File.join(path,'methods','*.rb')
193
+ end
205
194
 
206
195
  def path # :nodoc:
207
196
  File.join(base_path,'lib')
@@ -1,27 +1,30 @@
1
- require 'taza/settings'
2
-
3
- module WatirCraft
4
- # Assumes #site_name and #destination_root and #usage methods are defined.
5
- module GeneratorHelper
6
- protected
7
- def configured_validated_site
8
- site = configured_site
9
- check_if_site_exists site
10
- site
11
- end
12
- def configured_site
13
- site_name = Taza::Settings.config_file[:site]
14
- end
15
- def check_if_site_exists site_name=@site_name
16
- if site_name.nil?
17
- raise RubiGen::UsageError,
18
- "Error. A site must first be specified in config.yml"
19
- end
20
- site_file = File.join(destination_root,'lib',"#{site_name.underscore}.rb")
21
- unless File.exists?(site_file)
22
- raise RubiGen::UsageError,
23
- "Error. Site file #{site_file} not found. (Check config.yml)"
24
- end
25
- end
26
- end
1
+ require 'taza/settings'
2
+
3
+ module WatirCraft
4
+ # Assumes #site_name and #destination_root and #usage methods are defined.
5
+ module GeneratorHelper
6
+ def site_module
7
+ @site_name.camelize
8
+ end
9
+ protected
10
+ def configured_validated_site
11
+ site = configured_site
12
+ check_if_site_exists site
13
+ site
14
+ end
15
+ def configured_site
16
+ site_name = Taza::Settings.config_file[:site]
17
+ end
18
+ def check_if_site_exists site_name=@site_name
19
+ if site_name.nil?
20
+ raise RubiGen::UsageError,
21
+ "Error. A site must first be specified in config.yml"
22
+ end
23
+ site_file = File.join(destination_root,'lib',"#{site_name.underscore}.rb")
24
+ unless File.exists?(site_file)
25
+ raise RubiGen::UsageError,
26
+ "Error. Site file #{site_file} not found. (Check config.yml)"
27
+ end
28
+ end
29
+ end
27
30
  end
@@ -25,16 +25,27 @@ module WatirCraft
25
25
  end
26
26
  nil
27
27
  end
28
+ def fields
29
+ self.class.row_class.fields.map &:to_s
30
+ end
31
+ def elements
32
+ self.class.row_class.elements.map &:to_s
33
+ end
28
34
  end
29
35
 
30
36
  class Row
31
37
  class << self
32
38
  def element name, &block
39
+ elements << name
33
40
  define_method(name) do
34
41
  instance_eval &block
35
42
  end
36
43
  end
44
+ def elements # :nodoc:
45
+ @elements ||= []
46
+ end
37
47
  def field name, &block
48
+ fields << name
38
49
  element_name = "#{name}_field"
39
50
  element element_name, &block
40
51
  define_method(name) do
@@ -44,6 +55,9 @@ module WatirCraft
44
55
  send(element_name).set value
45
56
  end
46
57
  end
58
+ def fields # :nodoc:
59
+ @fields ||= []
60
+ end
47
61
  end
48
62
  attr_reader :row
49
63
  def initialize watir_row
@@ -1,3 +1,3 @@
1
1
  # This file is autogenerated. Do not edit.
2
2
  # Use 'rake version.rb' to update.
3
- module WatirCraft; VERSION = '0.4.5'; end
3
+ module WatirCraft; VERSION = '0.5.0'; end
@@ -0,0 +1,40 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/spec_generator_helper'
3
+
4
+ describe "Spec Generation" do
5
+ include RubiGen::GeneratorTestHelper
6
+ include Helpers::Generator
7
+ include Helpers::Taza
8
+
9
+ before :each do
10
+ generate_project ["--site=frito"]
11
+ end
12
+
13
+ after :each do
14
+ bare_teardown
15
+ end
16
+
17
+ it "should be able to generate a method" do
18
+ run_generator('method', ['empty_shopping_cart'], generator_sources)
19
+ end
20
+
21
+ it "should work when when the provided name includes a space" do
22
+ MethodGenerator.any_instance.stubs(:configured_site).returns('frito')
23
+ generator = MethodGenerator.new(['check out'])
24
+ generator.name.should == 'check_out'
25
+ end
26
+
27
+ it "should add a method to the site" do
28
+ MethodGenerator.any_instance.stubs(:configured_site).returns('frito')
29
+ run_generator('method', ['extra'], generator_sources)
30
+
31
+ require File.join(PROJECT_FOLDER, 'lib/frito')
32
+ Frito::Frito.any_instance.stubs(:base_path).returns(PROJECT_FOLDER)
33
+
34
+ stub_settings
35
+ stub_browser
36
+
37
+ Frito::Frito.new.extra
38
+ end
39
+
40
+ end
@@ -341,6 +341,29 @@ describe Taza::Page do
341
341
  uses_table_page
342
342
  @table_page.results.row(:missing => 'nada').should be_nil
343
343
  end
344
+
345
+ it "should be able to be listed from the page" do
346
+ uses_table_page
347
+ @table_page.tables.should == ['results']
348
+ end
349
+
350
+ it "should list its fields" do
351
+ uses_table_page
352
+ @table_page.results.fields.should == %w(name phone missing)
353
+ end
354
+
355
+ it "should list its elements" do
356
+ @page_class.class_eval do
357
+ element(:results_table) do FakeTable.new []
358
+ end
359
+ table(:results) do
360
+ field(:name){row.element(:letter)}
361
+ element(:phone){row.element(:number)}
362
+ end
363
+ end
364
+ @table_page = @page_class.new
365
+ @table_page.results.elements.should == %w(name_field phone)
366
+ end
344
367
 
345
368
  end
346
369
 
@@ -0,0 +1,7 @@
1
+ module Foo
2
+ module Methods
3
+ def spiderman
4
+ 'i am spiderman'
5
+ end
6
+ end
7
+ end
@@ -1,4 +1,4 @@
1
- class BarPage < Taza::Page
1
+ class Foo::BarPage < Taza::Page
2
2
  element :foo do
3
3
  browser
4
4
  end
@@ -4,21 +4,31 @@ require 'taza'
4
4
 
5
5
  describe do
6
6
 
7
+ module ::Foo
8
+ class Foo < ::Taza::Site
9
+
10
+ end
11
+ end
12
+
7
13
  before :all do
8
14
  @pages_path = File.join("spec","sandbox","pages","foo","**","*.rb")
9
15
  @flows_path = File.join("spec","sandbox","flows","*.rb")
10
- @foo_class = Class.new(Taza::Site)
16
+ @methods_path = File.join("spec","sandbox","methods","*.rb")
17
+ @foo_class = ::Foo::Foo
11
18
  end
12
19
 
13
20
  before :each do
14
21
  ENV['BROWSER'] = nil
15
22
  ENV['DRIVER'] = nil
23
+
16
24
  @foo_class.any_instance.stubs(:pages_path).returns(@pages_path)
25
+ @foo_class.any_instance.stubs(:methods_path).returns(@methods_path)
17
26
  Taza::Settings.stubs(:config_file).returns({})
18
27
  Taza::Settings.stubs(:environment_settings).returns({})
19
28
  Taza::Site.before_browser_closes {}
20
29
  @browser = stub_browser
21
30
  Taza::Browser.stubs(:create).returns(@browser)
31
+
22
32
  @site = @foo_class.new
23
33
  end
24
34
 
@@ -35,23 +45,23 @@ describe do
35
45
  @context.bar_page do |bar|
36
46
  barzor = bar
37
47
  end
38
- barzor.should be_an_instance_of(BarPage)
48
+ barzor.should be_an_instance_of(Foo::BarPage)
39
49
  end
40
50
 
41
51
  it "should return a page by name" do
42
52
  # Bar is a page on the site
43
- @context.bar_page.should be_an_instance_of(BarPage)
53
+ @context.bar_page.should be_an_instance_of(Foo::BarPage)
44
54
  end
45
55
 
46
56
  it "should return a page by method" do
47
- @context.page('bar').should be_an_instance_of(BarPage)
48
- @context.page('Bar').should be_an_instance_of(BarPage)
57
+ @context.page('bar').should be_an_instance_of(Foo::BarPage)
58
+ @context.page('Bar').should be_an_instance_of(Foo::BarPage)
49
59
  end
50
60
 
51
61
  it "should yield to a page" do
52
62
  the_page = nil
53
63
  @context.page('Bar') {|page| the_page = page }
54
- the_page.should be_an_instance_of(BarPage)
64
+ the_page.should be_an_instance_of(Foo::BarPage)
55
65
  end
56
66
 
57
67
  it "should pass the site browser instance to its pages " do
@@ -66,8 +76,7 @@ describe do
66
76
  Taza::Settings.expects(:environment_settings).returns({:url => 'http://www.zoro.com'}).at_least_once
67
77
  @context.site.origin.should == 'http://www.zoro.com'
68
78
  end
69
-
70
-
79
+
71
80
  it "should go to a relative url" do
72
81
  @browser.expects(:goto).with('http://www.foo.com/page.html')
73
82
  Taza::Settings.stubs(:config).returns(:url => 'http://www.foo.com')
@@ -91,6 +100,15 @@ describe do
91
100
  it "should provide Spec::Matchers" do
92
101
  @context.instance_eval { [1,2,3].should include(2) }
93
102
  end
103
+
104
+ it "should load the methods files" do
105
+ defined?(Foo::Methods).should be_true
106
+ Foo::Methods.instance_methods.should include("spiderman")
107
+ end
108
+
109
+ it "should have user-site-methods defined as instance methods" do
110
+ @context.spiderman.should == 'i am spiderman'
111
+ end
94
112
  end
95
113
 
96
114
  describe Taza::Site do
@@ -1,6 +1,7 @@
1
1
  #### Rubigen helpers
2
2
  require 'rubigen'
3
3
  require 'rubigen/helpers/generator_test_helper'
4
+ require 'taza'
4
5
 
5
6
 
6
7
  def generator_sources
@@ -1,8 +1,5 @@
1
1
  require 'spec/spec_helper'
2
2
  require 'spec/spec_generator_helper'
3
- require 'rubygems'
4
- require 'fileutils'
5
- require 'taza'
6
3
 
7
4
  describe "Spec Generation" do
8
5
  include RubiGen::GeneratorTestHelper
@@ -1,6 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
3
  require 'mocha'
4
+ begin
5
+ # Needed for rspec 1.2.x. (Allows "ruby" to run specs.)
6
+ # But not available before that.
7
+ require 'spec/autorun'
8
+ rescue LoadError
9
+ nil
10
+ end
11
+
4
12
  require 'config/vendorized_gems'
5
13
  lib_path = File.expand_path("#{File.dirname(__FILE__)}/../lib")
6
14
  $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{watircraft}
5
- s.version = "0.4.5"
5
+ s.version = "0.5.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bret Pettichord", "Jim Matthews", "Charley Baker", "Adam Anderson"]
9
- s.date = %q{2009-04-07}
9
+ s.date = %q{2009-04-10}
10
10
  s.default_executable = %q{watircraft}
11
11
  s.description = %q{WatirCraft is a framework for testing web apps.}
12
12
  s.email = %q{bret@pettichord.com}
13
13
  s.executables = ["watircraft"]
14
14
  s.extra_rdoc_files = ["History.txt", "README.rdoc"]
15
- s.files = ["History.txt", "Manifest.txt", "README.rdoc", "VERSION.yml", "watircraft.gemspec", "bin/watircraft", "lib/extensions", "lib/extensions/array.rb", "lib/extensions/hash.rb", "lib/extensions/object.rb", "lib/extensions/string.rb", "lib/extensions/watir.rb", "lib/taza", "lib/taza/browser.rb", "lib/taza/entity.rb", "lib/taza/fixture.rb", "lib/taza/flow.rb", "lib/taza/page.rb", "lib/taza/settings.rb", "lib/taza/site.rb", "lib/taza/tasks.rb", "lib/taza.rb", "lib/watircraft", "lib/watircraft/generator_helper.rb", "lib/watircraft/table.rb", "lib/watircraft/version.rb", "lib/watircraft.rb", "spec/array_spec.rb", "spec/browser_spec.rb", "spec/entity_spec.rb", "spec/fake_table.rb", "spec/fixtures_spec.rb", "spec/fixture_spec.rb", "spec/hash_spec.rb", "spec/object_spec.rb", "spec/page_generator_spec.rb", "spec/page_spec.rb", "spec/project_generator_spec.rb", "spec/sandbox", "spec/sandbox/config", "spec/sandbox/config/config.yml", "spec/sandbox/config/environments.yml", "spec/sandbox/config/simpler.yml", "spec/sandbox/config/simpler_site.yml", "spec/sandbox/config.yml", "spec/sandbox/fixtures", "spec/sandbox/fixtures/examples.yml", "spec/sandbox/fixtures/users.yml", "spec/sandbox/flows", "spec/sandbox/flows/batman.rb", "spec/sandbox/flows/robin.rb", "spec/sandbox/pages", "spec/sandbox/pages/foo", "spec/sandbox/pages/foo/bar_page.rb", "spec/sandbox/pages/foo/partials", "spec/sandbox/pages/foo/partials/partial_the_reckoning.rb", "spec/settings_spec.rb", "spec/site_spec.rb", "spec/spec_generator_helper.rb", "spec/spec_generator_spec.rb", "spec/spec_helper.rb", "spec/steps_generator_spec.rb", "spec/string_spec.rb", "spec/table_spec.rb", "spec/taza_spec.rb", "spec/watircraft_bin_spec.rb", "spec/watir_spec.rb", "app_generators/watircraft", "app_generators/watircraft/templates", "app_generators/watircraft/templates/config.yml.erb", "app_generators/watircraft/templates/environments.yml.erb", "app_generators/watircraft/templates/feature_helper.rb", "app_generators/watircraft/templates/initialize.rb.erb", "app_generators/watircraft/templates/rakefile.rb", "app_generators/watircraft/templates/readme.txt", "app_generators/watircraft/templates/script", "app_generators/watircraft/templates/script/console", "app_generators/watircraft/templates/script/console.cmd", "app_generators/watircraft/templates/site.rb.erb", "app_generators/watircraft/templates/site_start.rb.erb", "app_generators/watircraft/templates/spec_helper.rb", "app_generators/watircraft/templates/spec_initialize.rb", "app_generators/watircraft/templates/world.rb", "app_generators/watircraft/USAGE", "app_generators/watircraft/watircraft_generator.rb", "watircraft_generators/page", "watircraft_generators/page/page_generator.rb", "watircraft_generators/page/templates", "watircraft_generators/page/templates/page.rb.erb", "watircraft_generators/page/USAGE", "watircraft_generators/spec", "watircraft_generators/spec/spec_generator.rb", "watircraft_generators/spec/templates", "watircraft_generators/spec/templates/spec.rb.erb", "watircraft_generators/spec/USAGE", "watircraft_generators/steps", "watircraft_generators/steps/steps_generator.rb", "watircraft_generators/steps/templates", "watircraft_generators/steps/templates/steps.rb.erb", "watircraft_generators/steps/USAGE"]
15
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "VERSION.yml", "watircraft.gemspec", "bin/watircraft", "lib/extensions", "lib/extensions/array.rb", "lib/extensions/hash.rb", "lib/extensions/object.rb", "lib/extensions/string.rb", "lib/extensions/watir.rb", "lib/taza", "lib/taza/browser.rb", "lib/taza/entity.rb", "lib/taza/fixture.rb", "lib/taza/flow.rb", "lib/taza/page.rb", "lib/taza/settings.rb", "lib/taza/site.rb", "lib/taza/tasks.rb", "lib/taza.rb", "lib/watircraft", "lib/watircraft/generator_helper.rb", "lib/watircraft/table.rb", "lib/watircraft/version.rb", "lib/watircraft.rb", "spec/array_spec.rb", "spec/browser_spec.rb", "spec/entity_spec.rb", "spec/fake_table.rb", "spec/fixtures_spec.rb", "spec/fixture_spec.rb", "spec/hash_spec.rb", "spec/method_generator_spec.rb", "spec/object_spec.rb", "spec/page_generator_spec.rb", "spec/page_spec.rb", "spec/project_generator_spec.rb", "spec/sandbox", "spec/sandbox/config", "spec/sandbox/config/config.yml", "spec/sandbox/config/environments.yml", "spec/sandbox/config/simpler.yml", "spec/sandbox/config/simpler_site.yml", "spec/sandbox/config.yml", "spec/sandbox/fixtures", "spec/sandbox/fixtures/examples.yml", "spec/sandbox/fixtures/users.yml", "spec/sandbox/flows", "spec/sandbox/flows/batman.rb", "spec/sandbox/flows/robin.rb", "spec/sandbox/methods", "spec/sandbox/methods/spiderman.rb", "spec/sandbox/pages", "spec/sandbox/pages/foo", "spec/sandbox/pages/foo/bar_page.rb", "spec/sandbox/pages/foo/partials", "spec/sandbox/pages/foo/partials/partial_the_reckoning.rb", "spec/settings_spec.rb", "spec/site_spec.rb", "spec/spec_generator_helper.rb", "spec/spec_generator_spec.rb", "spec/spec_helper.rb", "spec/steps_generator_spec.rb", "spec/string_spec.rb", "spec/table_spec.rb", "spec/taza_spec.rb", "spec/watircraft_bin_spec.rb", "spec/watir_spec.rb", "app_generators/watircraft", "app_generators/watircraft/templates", "app_generators/watircraft/templates/config.yml.erb", "app_generators/watircraft/templates/environments.yml.erb", "app_generators/watircraft/templates/feature_helper.rb", "app_generators/watircraft/templates/initialize.rb.erb", "app_generators/watircraft/templates/rakefile.rb", "app_generators/watircraft/templates/readme.txt", "app_generators/watircraft/templates/script", "app_generators/watircraft/templates/script/console", "app_generators/watircraft/templates/script/console.cmd", "app_generators/watircraft/templates/site.rb.erb", "app_generators/watircraft/templates/site_start.rb.erb", "app_generators/watircraft/templates/spec_helper.rb", "app_generators/watircraft/templates/spec_initialize.rb", "app_generators/watircraft/templates/world.rb", "app_generators/watircraft/USAGE", "app_generators/watircraft/watircraft_generator.rb", "watircraft_generators/method", "watircraft_generators/method/method_generator.rb", "watircraft_generators/method/templates", "watircraft_generators/method/templates/method.rb.erb", "watircraft_generators/method/USAGE", "watircraft_generators/page", "watircraft_generators/page/page_generator.rb", "watircraft_generators/page/templates", "watircraft_generators/page/templates/page.rb.erb", "watircraft_generators/page/USAGE", "watircraft_generators/spec", "watircraft_generators/spec/spec_generator.rb", "watircraft_generators/spec/templates", "watircraft_generators/spec/templates/spec.rb.erb", "watircraft_generators/spec/USAGE", "watircraft_generators/steps", "watircraft_generators/steps/steps_generator.rb", "watircraft_generators/steps/templates", "watircraft_generators/steps/templates/steps.rb.erb", "watircraft_generators/steps/USAGE"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://wiki.github.com/bret/watircraft}
18
18
  s.rdoc_options = ["--main", "README.rdoc"]
@@ -0,0 +1,15 @@
1
+ Description:
2
+
3
+ Creates a template for a WatirCraft method. The method can be called
4
+ from a spec (in an "it", "before" or "after" block) or from a
5
+ step (a Given or When or Then block).
6
+
7
+ It can also be called from within script\console or as a method on the
8
+ site object.
9
+
10
+ The @browser and @site instance variables are available to your method.
11
+
12
+ Examples:
13
+
14
+ script\generate method notice
15
+ script\generate method empty_shopping_cart
@@ -0,0 +1,54 @@
1
+ require 'rubygems'
2
+ require 'rubigen'
3
+ require 'activesupport'
4
+ require 'watircraft/generator_helper'
5
+ require 'extensions/string'
6
+
7
+ class MethodGenerator < RubiGen::Base
8
+ include WatirCraft::GeneratorHelper
9
+ default_options :author => nil
10
+ attr_reader :name, :site_name
11
+
12
+ def initialize(runtime_args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ @name = args.shift.computerize
16
+ @site_name = configured_validated_site
17
+ extract_options
18
+ end
19
+
20
+ def manifest
21
+ record do |m|
22
+ m.template "method.rb.erb", File.join('lib','methods',"#{name}.rb")
23
+ end
24
+ end
25
+
26
+ protected
27
+ def banner
28
+ <<-EOS
29
+ Creates a template for a WatirCraft method.
30
+
31
+ USAGE: #{$0} #{spec.name} name
32
+
33
+ EOS
34
+ end
35
+
36
+ def add_options!(opts)
37
+ # opts.separator ''
38
+ # opts.separator 'Options:'
39
+ # For each option below, place the default
40
+ # at the top of the file next to "default_options"
41
+ # opts.on("-a", "--author=\"Your Name\"", String,
42
+ # "Some comment about this option",
43
+ # "Default: none") { |options[:author]| }
44
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
45
+ end
46
+
47
+ def extract_options
48
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
49
+ # Templates can access these value via the attr_reader-generated methods, but not the
50
+ # raw instance variable value.
51
+ # @author = options[:author]
52
+ end
53
+
54
+ end
@@ -0,0 +1,8 @@
1
+ module <%= site_module %>
2
+ module Methods
3
+ def <%= name %>
4
+ # Place the code for your method here.
5
+
6
+ end
7
+ end
8
+ end
@@ -1,8 +1,8 @@
1
1
  Description:
2
2
 
3
- A page class collects elements that grouped together. They might all
4
- be on the same page. You can also use page classes for parts of a
5
- page, or for items which appear on many pages.
3
+ A page class collects elements that grouped together. Usually they all
4
+ appear on the same physical page. But you can also use page classes for
5
+ parts of a page, or for items which appear on many pages.
6
6
 
7
7
  Examples:
8
8
 
@@ -16,10 +16,6 @@ class PageGenerator < RubiGen::Base
16
16
  extract_options
17
17
  end
18
18
 
19
- def site_module
20
- @site_name.camelize
21
- end
22
-
23
19
  def page_class
24
20
  "#{name.computerize.camelize}Page"
25
21
  end
@@ -26,7 +26,7 @@ class SpecGenerator < RubiGen::Base
26
26
  protected
27
27
  def banner
28
28
  <<-EOS
29
- Creates a spec.
29
+ Creates a template for an Rspec test.
30
30
 
31
31
  USAGE: #{$0} #{spec.name} name
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bret-watircraft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bret Pettichord
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-04-07 00:00:00 -07:00
15
+ date: 2009-04-10 00:00:00 -07:00
16
16
  default_executable: watircraft
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - spec/fixtures_spec.rb
120
120
  - spec/fixture_spec.rb
121
121
  - spec/hash_spec.rb
122
+ - spec/method_generator_spec.rb
122
123
  - spec/object_spec.rb
123
124
  - spec/page_generator_spec.rb
124
125
  - spec/page_spec.rb
@@ -136,6 +137,8 @@ files:
136
137
  - spec/sandbox/flows
137
138
  - spec/sandbox/flows/batman.rb
138
139
  - spec/sandbox/flows/robin.rb
140
+ - spec/sandbox/methods
141
+ - spec/sandbox/methods/spiderman.rb
139
142
  - spec/sandbox/pages
140
143
  - spec/sandbox/pages/foo
141
144
  - spec/sandbox/pages/foo/bar_page.rb
@@ -170,6 +173,11 @@ files:
170
173
  - app_generators/watircraft/templates/world.rb
171
174
  - app_generators/watircraft/USAGE
172
175
  - app_generators/watircraft/watircraft_generator.rb
176
+ - watircraft_generators/method
177
+ - watircraft_generators/method/method_generator.rb
178
+ - watircraft_generators/method/templates
179
+ - watircraft_generators/method/templates/method.rb.erb
180
+ - watircraft_generators/method/USAGE
173
181
  - watircraft_generators/page
174
182
  - watircraft_generators/page/page_generator.rb
175
183
  - watircraft_generators/page/templates