acceptance_test 1.1.3 → 1.1.4

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
- NGRhY2FhMTNlMDhhY2MyNTY1YmM5ZmQxOGQzYmYxZTQwMTJiZmE5Yw==
4
+ NmE1MDc5ZWE4ZTg1OGE1M2E5ODM5NzRlNWRlZGZlMmY5YTAzZjQ2ZQ==
5
5
  data.tar.gz: !binary |-
6
- OTc1NWEyMDdkM2YwOGRjNzhiOGNkNzVkMDFhNmIxMzY3ZjA2ZmE5ZQ==
6
+ MWY5NWVmNzAwYWViNjExZmVjNWYxNmY5ODU4OWI1Nzc2MTk2Y2NkNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTU5NjkyOTM1ZTFiOWI2NmZjM2JlYjg4Njg4NjIyZjYwYmEwMTdhNDJjNGFh
10
- MTBjYTZkNTczMWFjOTFiMWI1MWExZjg3ZDJkMTg4Yzg3OWQ3MTUzOGFiMGQ0
11
- NmU2OGViOTc1NTczYjNhNmViOTRhYjM0NDFmOGYyM2FkNDEzZjY=
9
+ YjUxNWYwYzNhNmI5MTJkMTc2MGZlZWE1MjdmYTQzNGMxODZlY2JhZTMyZjYy
10
+ ZDJkOWQ0YmM2NzQwMDVkYjA0YWRhY2Q1ZmYzNzQxMTI4ZjFiMjBmODdkNjFi
11
+ YWNjMjMyMzRkMTY0OWVmNjMyMzY3ZjVhYzI0ZDBiMGJhNTlkNDY=
12
12
  data.tar.gz: !binary |-
13
- MmFiMTgyYWViNWIzNTAyMjc4ZGE4MGNlNTkwYmFjNzNjODc5YjRlNDAwZjQ1
14
- ZTc0YTc0ODdiMjg5MmQzMDVjY2UyMDFlYzY2ZDcxOWVjMDg0ZmU3YjczNmU1
15
- YzdjZmI1N2Q2MmNhZDE2M2U2M2FmNTg0ZDFkNGEzYjBlMWIxYWQ=
13
+ MGQ4ZDNiZWZhMWIwN2NiMjBkNWJmMmZmMmNmNDUyZmRiYTVhNDk5N2JjMjk1
14
+ OWExYTIyYjZlMDZjYzQzMDVlNDRiMDViNzA3MDZkYmI1MTJlOTJjYjQxODE4
15
+ NGVkMDI5NTFiOTQ5NzUyNjlhMzgwMWFjYTIxMWJkYTNjZTUxZTY=
data/CHANGES CHANGED
@@ -46,4 +46,8 @@
46
46
 
47
47
  == Version 1.1.3
48
48
 
49
- * Bug fix
49
+ * Bug fix
50
+
51
+ == Version 1.1.4
52
+
53
+ * Adding ScreenshotMaker
@@ -7,10 +7,11 @@ require 'active_support/hash_with_indifferent_access'
7
7
  require 'acceptance_test/acceptance_test_helper'
8
8
 
9
9
  class AcceptanceTest
10
- attr_accessor :app_host
10
+ attr_accessor :app_host, :project_root, :screenshot_dir
11
11
 
12
- def initialize project_root="."
12
+ def initialize project_root, screenshot_dir
13
13
  @project_root = File.expand_path(project_root.to_s)
14
+ @screenshot_dir = File.expand_path(screenshot_dir.to_s)
14
15
 
15
16
  @app_host = default_app_host
16
17
 
@@ -39,12 +40,17 @@ class AcceptanceTest
39
40
  setup_app_host app_host
40
41
  end
41
42
 
42
- def after page, example_exception=nil, metadata={}
43
- if example_exception
43
+ def after page, exception=nil, metadata={}
44
+ if exception
44
45
  driver = driver(metadata)
45
46
 
46
47
  if driver and not [:webkit].include? driver
47
- save_screenshot example, page
48
+ screenshot_maker = ScreenshotMaker.new screenshot_dir
49
+
50
+ screenshot_maker.make page, metadata
51
+
52
+ puts metadata[:full_description]
53
+ puts "Screenshot: #{screenshot_maker.screenshot_url(metadata)}"
48
54
  end
49
55
  end
50
56
 
@@ -79,7 +85,7 @@ class AcceptanceTest
79
85
  require "capybara"
80
86
  require "capybara/dsl"
81
87
 
82
- # try to load capybara related rspec library
88
+ # try to load capybara-related rspec library
83
89
  begin
84
90
  require 'capybara/rspec'
85
91
  rescue
@@ -209,25 +215,6 @@ class AcceptanceTest
209
215
  "#{uri.scheme}://#{uri.host}:#{uri.port}"
210
216
  end
211
217
 
212
- def save_screenshot example, page
213
- file_path = example.metadata[:file_path]
214
- line_number = example.metadata[:line_number]
215
- full_description = example.metadata[:full_description]
216
-
217
- filename = File.basename(file_path)
218
-
219
- screenshot_name = "screenshot-#{filename}-#{line_number}.png"
220
- screenshot_path = "#{@project_root}/tmp/#{screenshot_name}"
221
-
222
- page.save_screenshot(screenshot_path)
223
-
224
- project_url = ENV['BUILD_URL'].nil? ? "file:///#{@project_root}" : "#{ENV['BUILD_URL']}../ws"
225
-
226
- screenshot_url = "#{project_url}/tmp/#{screenshot_name}"
227
-
228
- puts full_description + "\n Screenshot: #{screenshot_url}"
229
- end
230
-
231
218
  def acceptance_config_exist?
232
219
  not @acceptance_config.nil? and @acceptance_config.size > 0
233
220
  end
@@ -0,0 +1,30 @@
1
+ class ScreenshotMaker
2
+ attr_reader :basedir
3
+
4
+ def initialize basedir
5
+ @basedir = basedir
6
+ end
7
+
8
+ def make page, options
9
+ page.save_screenshot(screenshot_path(options))
10
+ end
11
+
12
+ def screenshot_path options
13
+ "#{basedir}/#{screenshot_name(options)}"
14
+ end
15
+
16
+ def screenshot_name options
17
+ filename = File.basename(options[:file_path])
18
+ line_number = options[:line_number]
19
+
20
+ name = "screenshot-#{filename}"
21
+ name += "-#{line_number}" if line_number
22
+
23
+ "#{name}.png"
24
+ end
25
+
26
+ def screenshot_url options
27
+ "file:///#{screenshot_path(options)}"
28
+ end
29
+
30
+ end
@@ -1,3 +1,3 @@
1
1
  class AcceptanceTest
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
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.3
4
+ version: 1.1.4
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-13 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gemspec_deps_gen
@@ -67,6 +67,7 @@ files:
67
67
  - lib/acceptance_test/acceptance_shared_context.rb
68
68
  - lib/acceptance_test/acceptance_test.rb
69
69
  - lib/acceptance_test/acceptance_test_helper.rb
70
+ - lib/acceptance_test/screenshot_maker.rb
70
71
  - lib/acceptance_test/version.rb
71
72
  - spec/features/features_spec_helper.rb
72
73
  - spec/features/google_search_spec.rb