bret-watircraft 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. data/BUGS.txt +11 -0
  2. data/History.txt +209 -0
  3. data/Manifest.txt +103 -0
  4. data/README.rdoc +75 -0
  5. data/VERSION.yml +4 -0
  6. data/app_generators/watircraft/USAGE +11 -0
  7. data/app_generators/watircraft/templates/config.yml.erb +3 -0
  8. data/app_generators/watircraft/templates/feature_helper.rb +12 -0
  9. data/app_generators/watircraft/templates/initialize.rb.erb +10 -0
  10. data/app_generators/watircraft/templates/rakefile.rb +3 -0
  11. data/app_generators/watircraft/templates/script/console +5 -0
  12. data/app_generators/watircraft/templates/script/console.cmd +1 -0
  13. data/app_generators/watircraft/templates/site_start.rb.erb +12 -0
  14. data/app_generators/watircraft/templates/spec_helper.rb +9 -0
  15. data/app_generators/watircraft/templates/spec_initialize.rb +16 -0
  16. data/app_generators/watircraft/templates/world.rb +12 -0
  17. data/app_generators/watircraft/watircraft_generator.rb +108 -0
  18. data/bin/watircraft +17 -0
  19. data/lib/extensions/array.rb +10 -0
  20. data/lib/extensions/hash.rb +5 -0
  21. data/lib/extensions/object.rb +24 -0
  22. data/lib/extensions/string.rb +17 -0
  23. data/lib/extensions/watir.rb +41 -0
  24. data/lib/taza/browser.rb +45 -0
  25. data/lib/taza/entity.rb +34 -0
  26. data/lib/taza/fixture.rb +66 -0
  27. data/lib/taza/flow.rb +40 -0
  28. data/lib/taza/page.rb +259 -0
  29. data/lib/taza/settings.rb +80 -0
  30. data/lib/taza/site.rb +227 -0
  31. data/lib/taza/tasks.rb +30 -0
  32. data/lib/taza.rb +35 -0
  33. data/lib/watircraft/generator_helper.rb +27 -0
  34. data/lib/watircraft/table.rb +56 -0
  35. data/lib/watircraft/version.rb +3 -0
  36. data/lib/watircraft.rb +1 -0
  37. data/spec/array_spec.rb +16 -0
  38. data/spec/browser_spec.rb +68 -0
  39. data/spec/entity_spec.rb +9 -0
  40. data/spec/fake_table.rb +34 -0
  41. data/spec/fixture_spec.rb +34 -0
  42. data/spec/fixtures_spec.rb +21 -0
  43. data/spec/hash_spec.rb +12 -0
  44. data/spec/object_spec.rb +29 -0
  45. data/spec/page_generator_spec.rb +111 -0
  46. data/spec/page_spec.rb +342 -0
  47. data/spec/project_generator_spec.rb +103 -0
  48. data/spec/sandbox/config/config.yml +1 -0
  49. data/spec/sandbox/config/environments.yml +4 -0
  50. data/spec/sandbox/config/simpler.yml +1 -0
  51. data/spec/sandbox/config/simpler_site.yml +2 -0
  52. data/spec/sandbox/config.yml +2 -0
  53. data/spec/sandbox/fixtures/examples.yml +8 -0
  54. data/spec/sandbox/fixtures/users.yml +2 -0
  55. data/spec/sandbox/flows/batman.rb +5 -0
  56. data/spec/sandbox/flows/robin.rb +4 -0
  57. data/spec/sandbox/pages/foo/bar_page.rb +9 -0
  58. data/spec/sandbox/pages/foo/partials/partial_the_reckoning.rb +2 -0
  59. data/spec/settings_spec.rb +103 -0
  60. data/spec/site_generator_spec.rb +62 -0
  61. data/spec/site_spec.rb +249 -0
  62. data/spec/spec_generator_helper.rb +40 -0
  63. data/spec/spec_generator_spec.rb +24 -0
  64. data/spec/spec_helper.rb +21 -0
  65. data/spec/steps_generator_spec.rb +29 -0
  66. data/spec/string_spec.rb +17 -0
  67. data/spec/table_spec.rb +32 -0
  68. data/spec/taza_spec.rb +12 -0
  69. data/spec/watircraft_bin_spec.rb +14 -0
  70. data/watircraft.gemspec +53 -0
  71. data/watircraft_generators/page/USAGE +11 -0
  72. data/watircraft_generators/page/page_generator.rb +65 -0
  73. data/watircraft_generators/page/templates/page.rb.erb +8 -0
  74. data/watircraft_generators/site/site_generator.rb +51 -0
  75. data/watircraft_generators/site/templates/environments.yml.erb +4 -0
  76. data/watircraft_generators/site/templates/site.rb.erb +10 -0
  77. data/watircraft_generators/spec/USAGE +8 -0
  78. data/watircraft_generators/spec/spec_generator.rb +54 -0
  79. data/watircraft_generators/spec/templates/spec.rb.erb +17 -0
  80. data/watircraft_generators/steps/USAGE +13 -0
  81. data/watircraft_generators/steps/steps_generator.rb +62 -0
  82. data/watircraft_generators/steps/templates/steps.rb.erb +12 -0
  83. metadata +229 -0
@@ -0,0 +1,103 @@
1
+ require 'spec/spec_helper'
2
+ require 'rubygems'
3
+ require 'taza'
4
+
5
+ describe Taza::Settings do
6
+
7
+ before :each do
8
+ ENV['ENVIRONMENT'] = 'test'
9
+ ENV['BROWSER'] = nil
10
+ ENV['DRIVER'] = nil
11
+ end
12
+
13
+ it "should use environment variable for browser settings" do
14
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
15
+ ENV['BROWSER'] = 'foo'
16
+ Taza::Settings.config('SiteName')[:browser].should eql(:foo)
17
+ end
18
+
19
+ it "should use environment variable for driver settings" do
20
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
21
+ ENV['DRIVER'] = 'bar'
22
+ Taza::Settings.config('SiteName')[:driver].should eql(:bar)
23
+ end
24
+
25
+ it "should provide default values if no config file or environment settings provided" do
26
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
27
+ Taza::Settings.config('SiteName')[:driver].should eql(:watir)
28
+ Taza::Settings.config('SiteName')[:browser].should eql(:firefox)
29
+ end
30
+
31
+ it "should be able to load the site yml" do
32
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
33
+ Taza::Settings.config("SiteName")[:url].should eql('http://google.com')
34
+ end
35
+
36
+ it "should be able to load a alternate site url" do
37
+ ENV['ENVIRONMENT'] = 'clown_shoes'
38
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
39
+ Taza::Settings.config("SiteName")[:url].should eql('http://clownshoes.com')
40
+ end
41
+
42
+ it "should use the config file's variable for browser settings if no environment variable is set" do
43
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
44
+ Taza::Settings.expects(:config_file).returns({:browser => :fu})
45
+ Taza::Settings.config('SiteName')[:browser].should eql(:fu)
46
+ end
47
+
48
+ it "should use the config file's variable for driver settings if no environment variable is set" do
49
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
50
+ Taza::Settings.stubs(:config_file).returns({:driver => :fun})
51
+ Taza::Settings.config('SiteName')[:driver].should eql(:fun)
52
+ end
53
+
54
+ it "should use the ENV variables if specified instead of config files" do
55
+ ENV['BROWSER'] = 'opera'
56
+ Taza::Settings.expects(:config_file).returns({:browser => :fu})
57
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
58
+ Taza::Settings.config('SiteName')[:browser].should eql(:opera)
59
+ end
60
+
61
+ it "should use the correct config file" do
62
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
63
+ Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config.yml')
64
+ end
65
+
66
+ it "should raise error when the config file does not exist" do
67
+ Taza::Settings.stubs(:path).returns('spec/no_such_directory')
68
+ lambda {Taza::Settings.config}.should raise_error
69
+ end
70
+
71
+ class SiteName < Taza::Site
72
+ end
73
+
74
+ it "a site should be able to load its settings" do
75
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
76
+ browser = stub()
77
+ browser.stubs(:goto)
78
+ SiteName.new(:browser => browser).config[:url].should eql('http://google.com')
79
+ end
80
+
81
+ it "setting keys can be specified as strings (i.e. without a colon) in the config file" do
82
+ Taza::Settings.stubs(:config_file_path).returns("spec/sandbox/config/simpler.yml")
83
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
84
+ Taza::Settings.config('SiteName')[:browser].should eql(:opera)
85
+ end
86
+
87
+ it "setting keys can be specified as strings (i.e. without a colon) in the config file" do
88
+ Taza::Settings.stubs(:path).returns("spec/sandbox")
89
+ Taza::Settings.stubs(:environment_file).returns('config/simpler_site.yml')
90
+ Taza::Settings.config('SimplerSite')[:url].should eql('http://makezine.com')
91
+ end
92
+
93
+ it "should be able to convert string keys to symbol keys" do
94
+ result = Taza::Settings.convert_string_keys_to_symbols 'browser' => :foo
95
+ result.should == {:browser => :foo}
96
+ end
97
+
98
+ it "should provide an empty hash when the config file doesn't exist" do
99
+ Taza::Settings.stubs(:config_file_path).returns('spec/sandbox/config/no_such_file.yml')
100
+ Taza::Settings.config_file.should == {}
101
+ end
102
+
103
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/spec_generator_helper'
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+ require 'taza'
6
+
7
+ describe "Site Generation" do
8
+ include RubiGen::GeneratorTestHelper
9
+ include Helpers::Generator
10
+ include Helpers::Taza
11
+
12
+ before :all do
13
+ @spec_helper = File.join(TMP_ROOT,PROJECT_NAME,'spec','spec_helper.rb')
14
+ @site_name = "WikipediaFoo"
15
+ @site_file = File.join(PROJECT_FOLDER,'lib', "wikipedia_foo.rb")
16
+ @site_folder = File.join(PROJECT_FOLDER,'lib')
17
+ @page_folder = File.join(@site_folder, 'pages')
18
+ end
19
+
20
+ before :each do
21
+ bare_setup
22
+ run_generator('watircraft', [APP_ROOT], generator_sources)
23
+ end
24
+
25
+ after :each do
26
+ bare_teardown
27
+ end
28
+
29
+ it "should generate configuration file for a site" do
30
+ run_generator('site', [@site_name], generator_sources)
31
+ File.exists?(File.join(PROJECT_FOLDER,'config','environments.yml')).should be_true
32
+ end
33
+
34
+ it "should generate a site path for pages" do
35
+ run_generator('site', [@site_name], generator_sources)
36
+ File.directory?(@site_folder).should be_true
37
+ File.directory?(@page_folder).should be_true
38
+ end
39
+
40
+ it "should generate a site path even if the site name is given with spaces" do
41
+ run_generator('site', ["Wikipedia Foo"], generator_sources)
42
+ File.directory?(@site_folder).should be_true
43
+ File.directory?(@page_folder).should be_true
44
+ end
45
+
46
+ it "should generate a site path even if the site name is given with underscores" do
47
+ run_generator('site', ["wikipedia_foo"], generator_sources)
48
+ File.directory?(@site_folder).should be_true
49
+ File.directory?(@page_folder).should be_true
50
+ end
51
+
52
+ it "generated site that uses the block given in new" do
53
+ @site_class = generate_site(@site_name)
54
+ stub_settings
55
+ stub_browser
56
+ foo = nil
57
+ @site_class.new {|site| foo = site}
58
+ foo.should_not be_nil
59
+ foo.should be_a_kind_of(Taza::Site)
60
+ end
61
+
62
+ end
data/spec/site_spec.rb ADDED
@@ -0,0 +1,249 @@
1
+ require 'spec/spec_helper'
2
+ require 'rubygems'
3
+ require 'taza'
4
+
5
+ describe do
6
+
7
+ before :all do
8
+ @pages_path = File.join("spec","sandbox","pages","foo","**","*.rb")
9
+ @flows_path = File.join("spec","sandbox","flows","*.rb")
10
+ @foo_class = Class.new(Taza::Site)
11
+ end
12
+
13
+ before :each do
14
+ ENV['BROWSER'] = nil
15
+ ENV['DRIVER'] = nil
16
+ @foo_class.any_instance.stubs(:pages_path).returns(@pages_path)
17
+ Taza::Settings.stubs(:config_file).returns({})
18
+ Taza::Settings.stubs(:environment_settings).returns({})
19
+ Taza::Site.before_browser_closes {}
20
+ @browser = stub_browser
21
+ Taza::Browser.stubs(:create).returns(@browser)
22
+ @site = @foo_class.new
23
+ end
24
+
25
+ def stub_browser
26
+ browser = stub()
27
+ browser.stubs(:close)
28
+ browser.stubs(:goto)
29
+ browser
30
+ end
31
+
32
+ shared_examples_for "an execution context" do
33
+ it "should yield an instance of a page class" do
34
+ barzor = nil
35
+ @context.bar_page do |bar|
36
+ barzor = bar
37
+ end
38
+ barzor.should be_an_instance_of(BarPage)
39
+ end
40
+
41
+ it "should return a page by name" do
42
+ # Bar is a page on the site
43
+ @context.bar_page.should be_an_instance_of(BarPage)
44
+ end
45
+
46
+ 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)
49
+ end
50
+
51
+ it "should yield to a page" do
52
+ the_page = nil
53
+ @context.page('Bar') {|page| the_page = page }
54
+ the_page.should be_an_instance_of(BarPage)
55
+ end
56
+
57
+ it "should pass the site browser instance to its pages " do
58
+ @context.bar_page.browser.should eql(@browser)
59
+ end
60
+
61
+ it "should provide direct access to the site" do
62
+ @context.site.should == @site
63
+ end
64
+
65
+ it "should all access to the site origin" do
66
+ Taza::Settings.expects(:environment_settings).returns({:url => 'http://www.zoro.com'}).at_least_once
67
+ @context.site.origin.should == 'http://www.zoro.com'
68
+ end
69
+
70
+
71
+ it "should go to a relative url" do
72
+ @browser.expects(:goto).with('http://www.foo.com/page.html')
73
+ Taza::Settings.stubs(:config).returns(:url => 'http://www.foo.com')
74
+ @context.goto 'page.html'
75
+ end
76
+
77
+ it "should go to the site origin" do
78
+ @browser.expects(:goto).with('http://www.foo.com/')
79
+ Taza::Settings.stubs(:config).returns(:url => 'http://www.foo.com')
80
+ @context.goto ''
81
+ end
82
+
83
+ it "should allow pages to access the site" do
84
+ @context.bar_page.site.should == @site
85
+ end
86
+
87
+ it "should list the site's pages" do
88
+ @context.pages.should == ["bar_page", "partial_the_reckoning"]
89
+ end
90
+ end
91
+
92
+ describe Taza::Site do
93
+ it_should_behave_like "an execution context"
94
+
95
+ before :each do
96
+ @context = @site
97
+ end
98
+
99
+ it "pages_path should not contain the site class name" do
100
+ Bax = Class.new(Taza::Site)
101
+ Bax.new.send(:pages_path).should eql(APP_ROOT + "/lib/pages/**/*.rb")
102
+ end
103
+
104
+ it "should have flows defined as instance methods" do
105
+ Barz = Class.new(Taza::Site)
106
+ Barz.any_instance.stubs(:path).returns('spec/sandbox')
107
+ Barz.any_instance.stubs(:flows_path).returns(@flows_path)
108
+ Barz.new.batman_flow.should == "i am batman"
109
+ end
110
+
111
+ it "should open watir browsers at the configuration URL" do
112
+ @browser.expects(:goto).with('a_url')
113
+ Taza::Settings.stubs(:config).returns(:url => 'a_url')
114
+ @foo_class.new
115
+ end
116
+
117
+ it "should accept a browser instance" do
118
+ provided_browser = stub_browser
119
+ site = @foo_class.new(:browser => provided_browser)
120
+ site.browser.should eql(provided_browser)
121
+ end
122
+
123
+ it "should create a browser instance if one is not provided" do
124
+ site = @foo_class.new
125
+ site.browser.should eql(@browser)
126
+ end
127
+
128
+ it "should still close browser if an error is raised" do
129
+ @browser.expects(:close)
130
+ lambda { @foo_class.new { |site| raise StandardError}}.should raise_error
131
+ end
132
+
133
+ it "should not close browser if block not given" do
134
+ @browser.expects(:close).never
135
+ @foo_class.new
136
+ end
137
+
138
+ it "should not close browser if an error is raised on browser goto" do
139
+ @browser.stubs(:goto).raises(StandardError,"ErrorOnBrowserGoto")
140
+ @browser.expects(:close).never
141
+ lambda { @foo_class.new }.should raise_error(StandardError,"ErrorOnBrowserGoto")
142
+ end
143
+
144
+ it "should raise browser close error if no other errors" do
145
+ @browser.expects(:close).raises(StandardError,"BrowserCloseError")
146
+ lambda { @foo_class.new {}}.should raise_error(StandardError,"BrowserCloseError")
147
+ end
148
+
149
+ it "should raise error inside block if both it and browser.close throws an error" do
150
+ @browser.expects(:close).raises(StandardError,"BrowserCloseError")
151
+ lambda { @foo_class.new { |site| raise StandardError, "innererror" }}.should raise_error(StandardError,"innererror")
152
+ end
153
+
154
+ it "should close a browser if block given (and it did not make it)" do
155
+ @browser.expects(:close)
156
+ @foo_class.new {}
157
+ end
158
+
159
+ it "should yield itself upon initialization" do
160
+ foo = nil
161
+ f = @foo_class.new { |site| foo = site }
162
+ foo.should eql(f)
163
+ end
164
+
165
+ it "should yield after page methods have been setup" do
166
+ klass = Class::new(Taza::Site)
167
+ klass.any_instance.stubs(:pages_path).returns(@pages_path)
168
+ klass.new do |site|
169
+ site.should respond_to(:bar_page)
170
+ end
171
+ end
172
+
173
+ it "should yield after browser has been setup" do
174
+ klass = Class::new(Taza::Site)
175
+ klass.any_instance.stubs(:pages_path).returns(@pages_path)
176
+ klass.new do |site|
177
+ site.browser.should_not be_nil
178
+ end
179
+ end
180
+
181
+ it "should add partials defined under the pages directory" do
182
+ klass = Class::new(Taza::Site)
183
+ klass.any_instance.stubs(:pages_path).returns(@pages_path)
184
+ klass.new do |site|
185
+ site.partial_the_reckoning
186
+ end
187
+ end
188
+
189
+ it "should have a way to evaluate a block of code before site closes the browser" do
190
+ browser_state = states('browser_open_state').starts_as('on')
191
+ @browser.expects(:close).then(browser_state.is('off'))
192
+ @browser.expects(:doit).when(browser_state.is('on'))
193
+ Taza::Site.before_browser_closes { |browser| browser.doit }
194
+ @foo_class.new {}
195
+ end
196
+
197
+ it "should have a way to evaluate a block of code before site closes the browser if an error occurs" do
198
+ browser_state = states('browser_open_state').starts_as('on')
199
+ @browser.expects(:close).then(browser_state.is('off'))
200
+ @browser.expects(:doit).when(browser_state.is('on'))
201
+ Taza::Site.before_browser_closes { |browser| browser.doit }
202
+ lambda { @foo_class.new { |site| raise StandardError, "innererror" }}.should raise_error(StandardError,"innererror")
203
+ end
204
+
205
+ it "should still close its browser if #before_browser_closes raises an exception" do
206
+ @browser.expects(:close)
207
+ Taza::Site.before_browser_closes { |browser| raise StandardError, 'foo error' }
208
+ lambda { @foo_class.new {} }.should raise_error(StandardError,'foo error')
209
+ end
210
+
211
+ it "should not close a browser it did not make" do
212
+ @browser.expects(:close).never
213
+ @foo_class.new(:browser => @browser) {}
214
+ end
215
+
216
+ module Zoro
217
+ class Zoro < ::Taza::Site
218
+ end
219
+ end
220
+
221
+ it "should pass in the class name to settings config" do
222
+ Taza::Settings.expects(:config).with('Zoro').returns({}).at_least_once
223
+ Zoro::Zoro.new
224
+ end
225
+
226
+ it "should return the configured site url" do
227
+ Taza::Settings.expects(:environment_settings).returns({:url => 'http://www.zoro.com'}).at_least_once
228
+ @site.origin.should == 'http://www.zoro.com'
229
+ end
230
+
231
+ end
232
+
233
+ describe "Rspec Context" do
234
+ it_should_behave_like "an execution context"
235
+ before do
236
+ # this code replicates what is in spec_initialize.rb
237
+ @context = Spec::Example::ExampleGroup.new "sample"
238
+ @site.initialize_context!(@context)
239
+ end
240
+
241
+ end
242
+
243
+ describe "Site#execution_context (aka irb START)" do
244
+ it_should_behave_like "an execution context"
245
+ before do
246
+ @context = @site.execution_context
247
+ end
248
+ end
249
+ end
@@ -0,0 +1,40 @@
1
+ #### Rubigen helpers
2
+ require 'rubigen'
3
+ require 'rubigen/helpers/generator_test_helper'
4
+
5
+
6
+ def generator_sources
7
+ [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__), "..", "app_generators")),
8
+ RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__), "..", "watircraft_generators"))]
9
+ end
10
+
11
+ module Helpers
12
+ module Generator
13
+ def generate_site(site_name)
14
+ site_name = "#{site_name}#{Time.now.to_i}"
15
+ run_generator('site', [site_name], generator_sources)
16
+ site_file_path = File.join(PROJECT_FOLDER,'lib',"#{site_name.underscore}.rb")
17
+ require site_file_path
18
+ "::#{site_name.camelize}::#{site_name.camelize}".constantize.any_instance.stubs(:base_path).returns(PROJECT_FOLDER)
19
+ site_name.camelize.constantize
20
+ end
21
+ def generate_project
22
+ run_generator('watircraft', [APP_ROOT], generator_sources)
23
+ ::Taza::Settings.stubs(:path).returns(APP_ROOT)
24
+ end
25
+ end
26
+
27
+ module Taza
28
+ def stub_settings
29
+ ::Taza::Settings.stubs(:config).returns({})
30
+ end
31
+
32
+ def stub_browser
33
+ stub_browser = stub()
34
+ stub_browser.stubs(:goto)
35
+ stub_browser.stubs(:close)
36
+ ::Taza::Browser.stubs(:create).returns(stub_browser)
37
+ end
38
+ end
39
+ end
40
+ #### Rubigen helpers end
@@ -0,0 +1,24 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/spec_generator_helper'
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+ require 'taza'
6
+
7
+ describe "Spec Generation" do
8
+ include RubiGen::GeneratorTestHelper
9
+ include Helpers::Generator
10
+ include Helpers::Taza
11
+
12
+ before :each do
13
+ generate_project
14
+ end
15
+
16
+ after :each do
17
+ bare_teardown
18
+ end
19
+
20
+ it "should be able to generate a spec" do
21
+ run_generator('spec', ['add penguin'], generator_sources)
22
+ end
23
+
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require 'mocha'
4
+ require 'config/vendorized_gems'
5
+ lib_path = File.expand_path("#{File.dirname(__FILE__)}/../lib")
6
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
7
+
8
+ # Must set before requiring generator libs.
9
+ TMP_ROOT = File.join(File.dirname(__FILE__),"sandbox","generated")
10
+ PROJECT_NAME = 'example'
11
+ PROJECT_FOLDER = File.join(TMP_ROOT,PROJECT_NAME)
12
+ APP_ROOT = File.join(TMP_ROOT, PROJECT_NAME)
13
+
14
+ Spec::Runner.configure do |config|
15
+ config.mock_with :mocha
16
+ end
17
+
18
+ def null_device
19
+ File.exists?('/dev/null') ? '/dev/null' : 'NUL'
20
+ end
21
+
@@ -0,0 +1,29 @@
1
+ require 'spec/spec_helper'
2
+ require 'spec/spec_generator_helper'
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+ require 'taza'
6
+
7
+ describe "Step Generation" do
8
+ include RubiGen::GeneratorTestHelper
9
+ include Helpers::Generator
10
+ include Helpers::Taza
11
+
12
+ before :each do
13
+ generate_project
14
+ end
15
+
16
+ after :each do
17
+ bare_teardown
18
+ end
19
+
20
+ it "should give you usage if you provide no arguments" do
21
+ lambda { run_generator('steps', [], generator_sources) }.
22
+ should raise_error(RubiGen::UsageError)
23
+ end
24
+
25
+ it "should be able to generate a steps file" do
26
+ lambda{run_generator('steps', ['simple'], generator_sources)}.
27
+ should_not raise_error
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec/spec_helper'
2
+ require 'extensions/string'
3
+
4
+ describe "string extensions" do
5
+ it "should pluralize and to sym a string" do
6
+ "apple".pluralize_to_sym.should eql(:apples)
7
+ end
8
+ it "should computerize a string with a space" do
9
+ "count down".computerize.should == "count_down"
10
+ end
11
+ it "should computerize a string that is capitalized" do
12
+ "Count Down".computerize.should == "count_down"
13
+ end
14
+ it "should computerize a string that is in CamelCase" do
15
+ "CountDown".computerize.should == "count_down"
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec/spec_helper'
2
+ require 'taza/page'
3
+ require 'taza/site'
4
+ require 'spec/fake_table'
5
+
6
+ describe FakeTable do
7
+
8
+ it "has rows" do
9
+ @fake_table = FakeTable.new [{},{}]
10
+ @fake_table.rows.length.should == 2
11
+ end
12
+
13
+ it "has fake rows" do
14
+ @fake_table = FakeTable.new [{:name => 'apple'}]
15
+ @fake_table.rows[0].should be_a(FakeRow)
16
+ end
17
+
18
+ # Note: the way it fakes out elements is the least
19
+ # authentic aspect of this scheme
20
+ it "has rows with elements and display values" do
21
+ @fake_table = FakeTable.new [{:name => 'apple'}]
22
+ @fake_table.rows[0].element(:name).display_value.should == 'apple'
23
+ end
24
+
25
+ it "has rows with elements that can be set" do
26
+ @fake_table = FakeTable.new [{:name => 'apple', :color => 'blue'}]
27
+ @fake_table.rows[0].element(:color).set 'red'
28
+ @fake_table.rows[0].element(:color).display_value.should == 'red'
29
+ end
30
+
31
+ end
32
+
data/spec/taza_spec.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'spec/spec_helper'
2
+ require 'rubygems'
3
+
4
+ describe "Taza GIVE ME 100% COVERAGE LOL" do
5
+ it "should cover the windows method" do
6
+ Taza.windows?
7
+ end
8
+
9
+ it "should cover the osx method" do
10
+ Taza.osx?
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec/spec_helper'
2
+ require 'rubygems'
3
+ require 'fileutils'
4
+ require 'taza'
5
+
6
+ describe "WatirCraft project generator script" do
7
+
8
+ it "should have an executable script" do
9
+ path = 'spec/sandbox/generators'
10
+ taza_bin = "#{File.expand_path(File.dirname(__FILE__)+'/../bin/watircraft')} #{path}"
11
+ system("ruby -c #{taza_bin} > #{null_device}").should be_true
12
+ end
13
+
14
+ end
@@ -0,0 +1,53 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{watircraft}
5
+ s.version = "0.4.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Bret Pettichord", "Jim Matthews", "Charley Baker", "Adam Anderson"]
9
+ s.date = %q{2009-02-24}
10
+ s.default_executable = %q{watircraft}
11
+ s.description = %q{WatirCraft is a framework for web testing.}
12
+ s.email = %q{bret@pettichord.com}
13
+ s.executables = ["watircraft"]
14
+ s.extra_rdoc_files = ["History.txt", "README.rdoc"]
15
+ s.files = ["BUGS.txt", "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_generator_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", "app_generators/watircraft", "app_generators/watircraft/templates", "app_generators/watircraft/templates/config.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/script", "app_generators/watircraft/templates/script/console", "app_generators/watircraft/templates/script/console.cmd", "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/site", "watircraft_generators/site/site_generator.rb", "watircraft_generators/site/templates", "watircraft_generators/site/templates/environments.yml.erb", "watircraft_generators/site/templates/site.rb.erb", "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
+ s.has_rdoc = true
17
+ s.rdoc_options = ["--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubyforge_project = %q{watir}
20
+ s.rubygems_version = %q{1.3.1}
21
+ s.summary = %q{WatirCraft is a framework for web testing.}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 2
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<watir>, [">= 1.6.2"])
29
+ s.add_runtime_dependency(%q<taglob>, [">= 1.1.1"])
30
+ s.add_runtime_dependency(%q<rake>, [">= 0.8.3"])
31
+ s.add_runtime_dependency(%q<mocha>, [">= 0.9.3"])
32
+ s.add_runtime_dependency(%q<rubigen>, [">= 1.4.0"])
33
+ s.add_runtime_dependency(%q<rspec>, ["= 1.1.12"])
34
+ s.add_runtime_dependency(%q<cucumber>, ["= 0.1.16"])
35
+ else
36
+ s.add_dependency(%q<watir>, [">= 1.6.2"])
37
+ s.add_dependency(%q<taglob>, [">= 1.1.1"])
38
+ s.add_dependency(%q<rake>, [">= 0.8.3"])
39
+ s.add_dependency(%q<mocha>, [">= 0.9.3"])
40
+ s.add_dependency(%q<rubigen>, [">= 1.4.0"])
41
+ s.add_dependency(%q<rspec>, ["= 1.1.12"])
42
+ s.add_dependency(%q<cucumber>, ["= 0.1.16"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<watir>, [">= 1.6.2"])
46
+ s.add_dependency(%q<taglob>, [">= 1.1.1"])
47
+ s.add_dependency(%q<rake>, [">= 0.8.3"])
48
+ s.add_dependency(%q<mocha>, [">= 0.9.3"])
49
+ s.add_dependency(%q<rubigen>, [">= 1.4.0"])
50
+ s.add_dependency(%q<rspec>, ["= 1.1.12"])
51
+ s.add_dependency(%q<cucumber>, ["= 0.1.16"])
52
+ end
53
+ end