visible-cukes 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/visible_cukes.rb +95 -0
- metadata +55 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'webrat'
|
2
|
+
|
3
|
+
module Webrat
|
4
|
+
class ButtonField
|
5
|
+
end
|
6
|
+
|
7
|
+
class SelectOption
|
8
|
+
alias :standard_choose :choose
|
9
|
+
|
10
|
+
def choose
|
11
|
+
standard_choose
|
12
|
+
current_selections = XML.xpath_search(select_element, ".//option[@selected = 'selected']")
|
13
|
+
remove_selection_from current_selections unless current_selections.empty?
|
14
|
+
@element['selected'] = ''
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def remove_selection_from options
|
20
|
+
options.each {|option| option.remove_attribute 'selected' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class TextField
|
25
|
+
def set(value)
|
26
|
+
@value = value
|
27
|
+
@element['value'] = value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class TextAreaField
|
32
|
+
end
|
33
|
+
|
34
|
+
class CheckboxField
|
35
|
+
end
|
36
|
+
|
37
|
+
class RadioField
|
38
|
+
end
|
39
|
+
|
40
|
+
class PasswordField
|
41
|
+
end
|
42
|
+
|
43
|
+
class FileField
|
44
|
+
end
|
45
|
+
|
46
|
+
class ResetField
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class VisibleCukes < Cucumber::Formatter::Html
|
51
|
+
def initialize(step_mother, io, options)
|
52
|
+
super(step_mother, io, options)
|
53
|
+
|
54
|
+
@rb = step_mother.load_programming_language('rb')
|
55
|
+
end
|
56
|
+
|
57
|
+
def visit_feature_name(name)
|
58
|
+
super(name)
|
59
|
+
@current_page_name_prefix = name.split(/\r?\n/)[0].downcase.gsub(/\s+/, '_').gsub(/[^a-z_]/, '')
|
60
|
+
@current_page_name_count = 1
|
61
|
+
end
|
62
|
+
|
63
|
+
def visit_step(step)
|
64
|
+
@step_id = step.dom_id
|
65
|
+
html_filename = "feature_pages/#{@current_page_name_prefix}_#{@current_page_name_count}.html"
|
66
|
+
@current_page_name_count += 1
|
67
|
+
@builder.a(:href => html_filename) do
|
68
|
+
super
|
69
|
+
end
|
70
|
+
save_file html_filename
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def save_file html_filename
|
76
|
+
full_path = File.expand_path("./doc/#{html_filename}")
|
77
|
+
unless has_response?
|
78
|
+
File.open(full_path, 'w') do |f|
|
79
|
+
f.write(current_page)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def has_response?
|
85
|
+
current_world.response.nil?
|
86
|
+
end
|
87
|
+
|
88
|
+
def current_page
|
89
|
+
current_world.webrat.dom
|
90
|
+
end
|
91
|
+
|
92
|
+
def current_world
|
93
|
+
@rb.current_world
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visible-cukes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Moss Collum
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-22 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: VisibleCukes is a Cucumber formatter that saves screenshots after each Webrat step.
|
17
|
+
email: moss.collum@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/visible_cukes.rb
|
26
|
+
has_rdoc: true
|
27
|
+
homepage: http://github.com/moss/visible-cukes
|
28
|
+
licenses: []
|
29
|
+
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
version:
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
requirements: []
|
48
|
+
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 1.3.5
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: Capture screenshots to illustrate Cucumber steps.
|
54
|
+
test_files: []
|
55
|
+
|