acceptance_tests_support 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -3,3 +3,7 @@
3
3
  == Version 1.0.0
4
4
 
5
5
  * Initial release.
6
+
7
+ == Version 1.0.1
8
+
9
+ * Refactoring code, adding support for selenium with firefox.
@@ -32,57 +32,35 @@ class AcceptanceTestsSupport
32
32
  set_defaults
33
33
 
34
34
  configure
35
-
36
- register_drivers
37
35
  end
38
36
 
39
37
  def before context
40
- driver = context.example.metadata[:driver]
38
+ driver = driver(context)
41
39
 
42
40
  if driver
43
- if [:js, :javascript].include? driver
44
- Capybara.current_driver = Capybara.javascript_driver
45
- elsif [:webkit, :selenium, :selenium_chrome, :poltergeist].include? driver
46
- Capybara.current_driver = driver
47
- Capybara.javascript_driver = driver
48
- elsif [:selenium_remote].include? driver
41
+ register_driver driver
42
+
43
+ select_driver driver
44
+
45
+ if driver.to_s =~ /selenium/
49
46
  puts "\nSelenium Configuration: #{@selenium_config[:name]}"
50
47
  puts "Environment: #{@selenium_config[:env]}"
51
48
  puts "Application: #{@selenium_config[:webapp_url]}"
52
49
  puts "Selenium: #{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}"
53
-
54
- selenium_app_host = app_host_from_url(@selenium_config[:webapp_url])
55
- setup_app_host selenium_app_host
56
-
57
- Rails.env = @selenium_config[:env]
58
-
59
- Capybara.current_driver = driver
60
- else
61
- Capybara.current_driver = Capybara.default_driver
62
- end
63
- else
64
- driver = ENV['DRIVER']
65
-
66
- if driver
67
- Capybara.current_driver = driver.to_sym
68
- else
69
- Capybara.current_driver = :webkit
70
50
  end
71
51
  end
72
52
 
73
- setup_app_host @app_host
53
+ setup_app_host app_host
74
54
  end
75
55
 
76
56
  def after context
77
57
  context.reset_session!
78
58
 
79
59
  if context.example.exception
80
- driver = context.example.metadata[:driver]
60
+ driver = driver(context)
81
61
 
82
- if driver
83
- if [:js, :javascript, :selenium, :selenium_remote].include? driver
84
- save_screenshot context.example, context.page
85
- end
62
+ if driver and not [:webkit].include? driver
63
+ save_screenshot context.example, context.page
86
64
  end
87
65
  end
88
66
 
@@ -105,19 +83,10 @@ class AcceptanceTestsSupport
105
83
  require 'rspec/rails'
106
84
  require 'rspec/autorun'
107
85
 
108
- require "capybara/rails"
109
-
110
- require 'capybara/rspec'
111
- require "capybara-webkit"
112
- require 'capybara/poltergeist'
113
-
114
86
  require "capybara"
115
87
  require "capybara/dsl"
116
- require 'capybara/firebug'
117
-
118
- #Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
119
-
120
- #Selenium::WebDriver::Firefox::Profile.enable_firebug
88
+ require 'capybara/rspec'
89
+ require "capybara/rails"
121
90
 
122
91
  RSpec.configure do |config|
123
92
  config.filter_run_excluding :exclude => true
@@ -125,7 +94,6 @@ class AcceptanceTestsSupport
125
94
 
126
95
  RSpec.configure do |config|
127
96
  config.include Capybara::DSL
128
- #config.include Rails.application.routes.url_helpers, :type => :acceptance
129
97
  end
130
98
 
131
99
  RSpec::Core::ExampleGroup.send :include, Capybara::DSL
@@ -151,24 +119,94 @@ class AcceptanceTestsSupport
151
119
  #
152
120
  end
153
121
 
154
- def register_drivers
155
- Capybara.register_driver :selenium_chrome do |app|
156
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
157
- end
122
+ def register_driver driver
123
+ case driver
124
+ when :webkit
125
+ require "capybara-webkit"
126
+
127
+ when :selenium
128
+ # nothing
129
+
130
+ when :selenium_with_firebug
131
+ require 'capybara/firebug'
132
+
133
+ #Capybara.register_driver :selenium_with_firebug do |app|
134
+ # profile = Selenium::WebDriver::Firefox::Profile.new
135
+ # profile.enable_firebug
136
+ # Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
137
+ #end
138
+
139
+ #Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
140
+ when :selenium_chrome
141
+ unless Capybara.drivers[:selenium_chrome]
142
+ Capybara.register_driver :selenium_chrome do |app|
143
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
144
+ end
145
+ end
146
+
147
+ when :poltergeist
148
+ require 'capybara/poltergeist'
158
149
 
159
- Capybara.register_driver :poltergeist do |app|
160
- Capybara::Poltergeist::Driver.new(app, { debug: false })
150
+ unless Capybara.drivers[:poltergeist]
151
+ Capybara.register_driver :poltergeist do |app|
152
+ Capybara::Poltergeist::Driver.new(app, { debug: false })
153
+ end
154
+ end
155
+
156
+ when :selenium_remote
157
+ unless Capybara.drivers[:selenium_remote]
158
+ selenium_url = "http://#{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}/wd/hub"
159
+
160
+ Capybara.register_driver :selenium_remote do |app|
161
+ Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => selenium_url})
162
+
163
+ #profile = Selenium::WebDriver::Firefox::Profile.new
164
+ #profile.enable_firebug
165
+ #
166
+ #Capybara::Driver::Selenium.new(app, {
167
+ # :browser => :remote,
168
+ # :url => selenium_url,
169
+ # :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
170
+ #})
171
+ end
172
+ end
173
+ when :selenium_safari
174
+ unless Capybara.drivers[:selenium_safari]
175
+ Capybara.register_driver :selenium_safari do |app|
176
+ Capybara::Selenium::Driver.new(app, :browser => :safari)
177
+ end
178
+ end
179
+ else
180
+ # nothing
161
181
  end
182
+ end
183
+
184
+ def select_driver driver
185
+ if [:js, :javascript].include? driver
186
+ Capybara.current_driver = Capybara.javascript_driver
187
+ elsif [:webkit, :selenium, :selenium_with_firebug, :selenium_chrome, :poltergeist].include? driver
188
+ Capybara.current_driver = driver
189
+ Capybara.javascript_driver = driver
190
+ elsif [:selenium_remote].include? driver
191
+ selenium_app_host = app_host_from_url(@selenium_config[:webapp_url])
192
+ setup_app_host selenium_app_host
162
193
 
163
- selenium_url = "http://#{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}/wd/hub"
194
+ Rails.env = @selenium_config[:env]
164
195
 
165
- Capybara.register_driver :selenium_remote do |app|
166
- Capybara::Selenium::Driver.new(app, {:url => selenium_url, :browser => :remote})
196
+ Capybara.current_driver = driver
197
+ else
198
+ Capybara.current_driver = Capybara.default_driver
167
199
  end
200
+ end
168
201
 
169
- #Capybara.register_driver :safari_selenium do |app|
170
- # Capybara::Selenium::Driver.new(app, :browser => :safari)
171
- #end
202
+ def driver context
203
+ driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
204
+
205
+ driver = context.example.metadata[:driver] if driver.nil?
206
+
207
+ driver = :webkit if driver.nil?
208
+
209
+ driver
172
210
  end
173
211
 
174
212
  def setup_app_host app_host
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTestsSupport
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
8
+ <orderEntry type="library" scope="PROVIDED" name="capybara (v2.1.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
9
+ <orderEntry type="library" scope="PROVIDED" name="capybara-firebug (v1.3.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="capybara-webkit (v1.0.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="cucumber (v1.3.2, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.4, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.6, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.23, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="mocha (v0.14.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.7.6, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.5.10, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.13.1, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.13.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="xpath (v2.0.0, RVM: ruby-1.9.3-p429 [rails_app_tmpl]) [gem]" level="application" />
24
+ </component>
25
+ </module>
26
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acceptance_tests_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gemspec_deps_gen
@@ -50,14 +50,6 @@ extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
52
  - .gitignore
53
- - .idea/.name
54
- - .idea/.rakeTasks
55
- - .idea/acceptance_tests_support.iml
56
- - .idea/encodings.xml
57
- - .idea/misc.xml
58
- - .idea/modules.xml
59
- - .idea/scopes/scope_settings.xml
60
- - .idea/vcs.xml
61
53
  - .ruby-gemset
62
54
  - .ruby-version
63
55
  - CHANGES
@@ -73,6 +65,7 @@ files:
73
65
  - lib/acceptance_tests_support/acceptance_shared_context.rb
74
66
  - lib/acceptance_tests_support/acceptance_tests_support.rb
75
67
  - lib/acceptance_tests_support/version.rb
68
+ - projectFilesBackup/.idea/acceptance_tests_support.iml
76
69
  homepage: http://github.com/shvets/acceptance_tests_support
77
70
  licenses: []
78
71
  post_install_message:
data/.idea/.name DELETED
@@ -1 +0,0 @@
1
- acceptance_tests_support
data/.idea/.rakeTasks DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -1,34 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="FacetManager">
4
- <facet type="gem" name="Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
- <option name="GEM_APP_TEST_PATH" value="" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
- </configuration>
10
- </facet>
11
- </component>
12
- <component name="NewModuleRootManager">
13
- <content url="file://$MODULE_DIR$" />
14
- <orderEntry type="inheritedJdk" />
15
- <orderEntry type="sourceFolder" forTests="false" />
16
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="capybara (v2.1.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="capybara-firebug (v1.3.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="capybara-webkit (v1.0.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="cucumber (v1.3.2, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.4, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.6, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="gherkin (v2.12.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="mime-types (v1.23, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="mocha (v0.14.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.7.6, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.2, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.13.1, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.13.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="xpath (v2.0.0, RVM: ruby-1.9.3-p429 [r23]) [gem]" level="application" />
32
- </component>
33
- </module>
34
-
data/.idea/encodings.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
- </project>
5
-
data/.idea/misc.xml DELETED
@@ -1,23 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p429 [r23]" project-jdk-type="RUBY_SDK" />
4
- <component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false">
5
- <option name="USER" value="" />
6
- <option name="PASSWORD" value="" />
7
- <option name="mySSHConnectionTimeout" value="30000" />
8
- <option name="mySSHReadTimeout" value="30000" />
9
- <option name="LAST_MERGED_REVISION" />
10
- <option name="MERGE_DRY_RUN" value="false" />
11
- <option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
12
- <option name="UPDATE_LOCK_ON_DEMAND" value="false" />
13
- <option name="IGNORE_SPACES_IN_MERGE" value="false" />
14
- <option name="DETECT_NESTED_COPIES" value="true" />
15
- <option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
16
- <option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
17
- <option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
18
- <option name="FORCE_UPDATE" value="false" />
19
- <option name="IGNORE_EXTERNALS" value="false" />
20
- <myIsUseDefaultProxy>false</myIsUseDefaultProxy>
21
- </component>
22
- </project>
23
-
data/.idea/modules.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/acceptance_tests_support.iml" filepath="$PROJECT_DIR$/.idea/acceptance_tests_support.iml" />
6
- </modules>
7
- </component>
8
- </project>
9
-
@@ -1,5 +0,0 @@
1
- <component name="DependencyValidationManager">
2
- <state>
3
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
- </state>
5
- </component>
data/.idea/vcs.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
7
-