acceptance_test 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWZkZTc4ZmEwMTk0Nzc2ZTFjYjRhY2JhMDU1NzJkZDliMmM2ZDk0MA==
4
+ NTRhYWVlMWRiOGQ1YjBmODMwZWVjZjliNDk2OWZmZDcxNTBmMDdkNQ==
5
5
  data.tar.gz: !binary |-
6
- ZjI4NGU3YTcyMjY2MTlhMTIxMmJhMmFjZTdiNDE2NjczZmZlYTZmMw==
6
+ NzYxZjQxNjQ5ZjUxZjA5NGI5ZjE0NWU1OTE4MDY3OTQzY2NjYmEzMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmZjOWQ4MmYzN2YyYjA5NmRlNjNhN2RhZDY3ZjY3NWJlMzIyNTU3NTBiMGI4
10
- YzI2MGU4NWJkYTFkYWRkOTc1NTc1NTFhMjMyYjU1NTY3Y2I3MTdjNzQ4OTkz
11
- ODFiZjllODRiMTYyMDgwOTQxZTQxYWY0OGIzNGFjYmZlMjAzYzU=
9
+ NjY1MTU4N2Y2YTExODI1YzEwZDI0YWQyM2VhMGQ2YTU0Y2JmOThhYTlkZGVk
10
+ NzY5MmEwYmVlNGZjMzY5Nzc1YWE2MjM0ZDgxMjA5MGM5N2Y2OWE3MGVlMmQ3
11
+ NDZkM2ZlYjhlMDQ2YzdiOGVhNjFlMTM0YzcyMDZiNjQ2OTQyNTY=
12
12
  data.tar.gz: !binary |-
13
- NDJkNmRiMDc2ZWQ3N2U3M2IwMzQ1MTIyNzcwYTkzOTdlYjk3M2I5Y2IyNzFm
14
- NmEwMWEwODcxZmIxNTk0NDJkYTY0YTJkNjA0YmNmOTAxNGY1MWY4MGJkMGMy
15
- MTM1ZDA0N2IwZjdkNGJiZWJmM2YxZjIwNzIzZmQ5MjcwNTE1MTY=
13
+ MTc0ZjZiOWYzNTRkNjBhNWU3Y2NiNDFlMDY3MThiMjA4MDQ5ZDBiMDk0NzEw
14
+ OWZlNjdhN2Y3MDI0MmNiNjg5YjFjYzA2NzQzMThkNTExYWJjYmE2MWYyZGQy
15
+ YjYwOGY1YzdkNmM5N2QyZTkxMjljZjU3ZTgwMTM3YmY5MWIxN2E=
data/CHANGES CHANGED
@@ -36,7 +36,10 @@
36
36
 
37
37
  * Switch to rspec3
38
38
 
39
-
40
39
  == Version 1.1.1
41
40
 
42
41
  * Bug fix
42
+
43
+ == Version 1.1.2
44
+
45
+ * Relaxing method calls
@@ -1,4 +1,2 @@
1
1
  require 'acceptance_test/version'
2
- require 'acceptance_test/acceptance_test_helper'
3
- require 'acceptance_test/acceptance_test'
4
- require 'acceptance_test/acceptance_shared_context'
2
+ require 'acceptance_test/acceptance_test'
@@ -1,23 +1,25 @@
1
- acceptance_test_lambda = lambda do
2
- attr_reader :acceptance_test
1
+ if defined? RSpec
2
+ acceptance_test_lambda = lambda do
3
+ attr_reader :acceptance_test
3
4
 
4
- before :all do
5
- @acceptance_test = AcceptanceTest.new
6
- end
5
+ before :all do
6
+ @acceptance_test = AcceptanceTest.new
7
+ end
7
8
 
8
- before do
9
- acceptance_test.before self
10
- end
9
+ before do
10
+ acceptance_test.before self
11
+ end
11
12
 
12
- after do
13
- acceptance_test.after self
13
+ after do
14
+ acceptance_test.after self
15
+ end
14
16
  end
15
- end
16
17
 
17
- RSpec.shared_context "AcceptanceTest" do
18
- self.define_singleton_method(:include_context, acceptance_test_lambda)
18
+ RSpec.shared_context "AcceptanceTest" do
19
+ self.define_singleton_method(:include_context, acceptance_test_lambda)
19
20
 
20
- include_context
21
+ include_context
22
+ end
21
23
  end
22
24
 
23
25
 
@@ -4,6 +4,8 @@ require 'capybara'
4
4
  require 'yaml'
5
5
  require 'active_support/hash_with_indifferent_access'
6
6
 
7
+ require 'acceptance_test/acceptance_test_helper'
8
+
7
9
  class AcceptanceTest
8
10
  attr_accessor :app_host
9
11
 
@@ -17,45 +19,43 @@ class AcceptanceTest
17
19
  configure
18
20
  end
19
21
 
20
- def before context
21
- driver = driver(context)
22
+ def before metadata={}
23
+ driver = driver(metadata)
22
24
 
23
25
  if driver
24
26
  register_driver driver
25
27
 
26
28
  select_driver driver
27
29
 
28
- if selenium_driver?(driver) and selenium_config_exist?
29
- puts "\nSelenium Configuration: #{@selenium_config[:name]}"
30
- puts "Environment: #{@selenium_config[:env]}"
31
- puts "Application: #{@selenium_config[:webapp_url]}"
32
- puts "Selenium: #{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}"
30
+ if acceptance_config_exist?
31
+ put "\n"
32
+ puts "Acceptance Configuration: #{@acceptance_config[:name]}"
33
+ puts "Environment: #{@acceptance_config[:env]}"
34
+ puts "Application: #{@acceptance_config[:webapp_url]}"
35
+ puts "Selenium: #{@acceptance_config[:selenium_host]}:#{@acceptance_config[:selenium_port]}" if
36
+ selenium_driver?(driver)
33
37
  end
34
38
  end
35
39
 
36
40
  setup_app_host app_host
37
41
  end
38
42
 
39
- def after context
40
- example = RSpec.current_example
41
-
42
- if example.exception
43
- driver = driver(context)
43
+ def after page, example_exception=nil, metadata={}
44
+ if example_exception
45
+ driver = driver(metadata)
44
46
 
45
47
  if driver and not [:webkit].include? driver
46
- save_screenshot example, context.page
48
+ save_screenshot example, page
47
49
  end
48
50
  end
49
51
 
50
52
  Capybara.current_driver = Capybara.default_driver
51
-
52
- context.reset_session!
53
53
  end
54
54
 
55
- def load_selenium_config file_name, config_name
56
- @selenium_config = HashWithIndifferentAccess.new YAML.load_file(file_name)[config_name]
55
+ def load_acceptance_config file_name, config_name
56
+ @acceptance_config = HashWithIndifferentAccess.new YAML.load_file(file_name)[config_name]
57
57
 
58
- @selenium_config[:name] = config_name
58
+ @acceptance_config[:name] = config_name
59
59
  end
60
60
 
61
61
  private
@@ -79,17 +79,25 @@ class AcceptanceTest
79
79
 
80
80
  require "capybara"
81
81
  require "capybara/dsl"
82
- require 'capybara/rspec'
83
82
 
84
- RSpec.configure do |config|
85
- config.filter_run_excluding :exclude => true
83
+ # try to load capybara related rspec library
84
+ begin
85
+ require 'capybara/rspec'
86
+ rescue
87
+ ;
86
88
  end
87
89
 
88
- RSpec.configure do |config|
89
- config.include Capybara::DSL
90
- end
90
+ if defined? RSpec
91
+ RSpec.configure do |config|
92
+ config.filter_run_excluding :exclude => true
93
+ end
94
+
95
+ RSpec.configure do |config|
96
+ config.include Capybara::DSL
97
+ end
91
98
 
92
- RSpec::Core::ExampleGroup.send :include, Capybara::DSL
99
+ RSpec::Core::ExampleGroup.send :include, Capybara::DSL
100
+ end
93
101
 
94
102
  Capybara.configure do |config|
95
103
  config.default_wait_time = ENV['WAIT_TIME'].to_i
@@ -108,13 +116,13 @@ class AcceptanceTest
108
116
  when :selenium_with_firebug
109
117
  require 'capybara/firebug'
110
118
 
111
- #Capybara.register_driver :selenium_with_firebug do |app|
112
- # profile = Selenium::WebDriver::Firefox::Profile.new
113
- # profile.enable_firebug
114
- # Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
115
- #end
119
+ #Capybara.register_driver :selenium_with_firebug do |app|
120
+ # profile = Selenium::WebDriver::Firefox::Profile.new
121
+ # profile.enable_firebug
122
+ # Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
123
+ #end
116
124
 
117
- #Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
125
+ #Selenium::WebDriver::Firefox::Profile.firebug_version = '1.11.2'
118
126
  when :selenium_chrome
119
127
  unless Capybara.drivers[:selenium_chrome]
120
128
  Capybara.register_driver :selenium_chrome do |app|
@@ -133,10 +141,10 @@ class AcceptanceTest
133
141
 
134
142
  when :selenium_remote
135
143
  unless Capybara.drivers[:selenium_remote]
136
- selenium_url = "http://#{@selenium_config[:selenium_host]}:#{@selenium_config[:selenium_port]}/wd/hub"
144
+ url = "http://#{@acceptance_config[:selenium_host]}:#{@acceptance_config[:selenium_port]}/wd/hub"
137
145
 
138
146
  Capybara.register_driver :selenium_remote do |app|
139
- Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => selenium_url})
147
+ Capybara::Selenium::Driver.new(app, {:browser => :remote, :url => url})
140
148
 
141
149
  #profile = Selenium::WebDriver::Firefox::Profile.new
142
150
  #profile.enable_firebug
@@ -164,7 +172,7 @@ class AcceptanceTest
164
172
  if driver == :selenium_remote
165
173
  setup_driver_from_config driver
166
174
  else
167
- if selenium_config_exist?
175
+ if acceptance_config_exist?
168
176
  setup_driver_from_config driver
169
177
  else
170
178
  if Capybara.drivers[driver]
@@ -181,10 +189,10 @@ class AcceptanceTest
181
189
  end
182
190
  end
183
191
 
184
- def driver context
192
+ def driver metadata
185
193
  driver = ENV['DRIVER'].nil? ? nil : ENV['DRIVER'].to_sym
186
194
 
187
- driver = context.example.metadata[:driver] if driver.nil?
195
+ driver = metadata[:driver] if driver.nil?
188
196
 
189
197
  driver = :webkit if driver.nil?
190
198
 
@@ -221,15 +229,14 @@ class AcceptanceTest
221
229
  puts full_description + "\n Screenshot: #{screenshot_url}"
222
230
  end
223
231
 
224
- def selenium_config_exist?
225
- not @selenium_config.nil? and @selenium_config.size > 0
232
+ def acceptance_config_exist?
233
+ not @acceptance_config.nil? and @acceptance_config.size > 0
226
234
  end
227
235
 
228
236
  def setup_driver_from_config driver
229
- selenium_app_host = app_host_from_url(@selenium_config[:webapp_url])
230
- @app_host = selenium_app_host
237
+ @app_host = app_host_from_url(@acceptance_config[:webapp_url])
231
238
 
232
- Rails.env = @selenium_config[:env] if defined? Rails.env
239
+ Rails.env = @acceptance_config[:env] if defined? Rails.env
233
240
 
234
241
  Capybara.current_driver = driver
235
242
  Capybara.javascript_driver = driver
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTest
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acceptance_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen