spreewald 0.1.4 → 0.1.5
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.
- data/.gitignore +1 -0
- data/lib/spreewald/all_steps.rb +2 -0
- data/lib/spreewald/development_steps.rb +1 -1
- data/lib/spreewald/email_steps.rb +5 -3
- data/lib/spreewald/table_steps.rb +3 -1
- data/lib/spreewald/timecop_steps.rb +3 -0
- data/lib/spreewald/web_steps.rb +14 -5
- data/lib/spreewald.rb +2 -0
- data/lib/spreewald_support/github.rb +2 -0
- data/lib/spreewald_support/mail_finder.rb +18 -4
- data/lib/spreewald_support/path_selector_fallbacks.rb +3 -1
- data/lib/spreewald_support/step_fallback.rb +2 -0
- data/lib/spreewald_support/tolerance_for_selenium_sync_issues.rb +2 -0
- data/lib/spreewald_support/version.rb +3 -1
- metadata +6 -7
data/.gitignore
CHANGED
data/lib/spreewald/all_steps.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
1
3
|
require 'spreewald_support/mail_finder'
|
2
4
|
|
3
5
|
Before do
|
@@ -36,7 +38,7 @@ Then /^(an|no) e?mail should have been sent with:$/ do |mode, raw_data|
|
|
36
38
|
end
|
37
39
|
|
38
40
|
# nodoc
|
39
|
-
Then /^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
|
41
|
+
Then /^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|bcc "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
|
40
42
|
conditions = {}
|
41
43
|
conditions[:to] = $1 if query =~ /to "([^"]+)"/
|
42
44
|
conditions[:cc] = $1 if query =~ / cc "([^"]+)"/
|
@@ -54,7 +56,7 @@ end
|
|
54
56
|
When /^I follow the (first|second|third)? ?link in the e?mail$/ do |index_in_words|
|
55
57
|
mail = @mail || ActionMailer::Base.deliveries.last
|
56
58
|
index = { nil => 0, 'first' => 0, 'second' => 1, 'third' => 2 }[index_in_words]
|
57
|
-
visit mail.
|
59
|
+
visit MailFinder.email_text_body(mail).to_s.scan(Patterns::URL)[index][2]
|
58
60
|
end
|
59
61
|
|
60
62
|
Then /^no e?mail should have been sent$/ do
|
@@ -63,7 +65,7 @@ end
|
|
63
65
|
|
64
66
|
# Checks that the last sent email includes some text
|
65
67
|
Then /^I should see "([^\"]*)" in the e?mail$/ do |text|
|
66
|
-
ActionMailer::Base.deliveries.last.
|
68
|
+
MailFinder.email_text_body(ActionMailer::Base.deliveries.last).should include(text)
|
67
69
|
end
|
68
70
|
|
69
71
|
# Print all sent emails to STDOUT.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
1
3
|
# Check the content of tables in your HTML.
|
2
4
|
#
|
3
5
|
# See [this article](https://makandracards.com/makandra/763-cucumber-step-to-match-table-rows-with-capybara) for details.
|
@@ -29,7 +31,7 @@ module TableStepsHelper
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def normalize_content(content)
|
32
|
-
nbsp =
|
34
|
+
nbsp = " "
|
33
35
|
content.gsub(/[\r\n\t]+/, ' ').gsub(nbsp, ' ').gsub(/ {2,}/, ' ').strip
|
34
36
|
end
|
35
37
|
|
data/lib/spreewald/web_steps.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
1
3
|
# Most of cucumber-rails' original web steps plus a few of our own.
|
2
4
|
#
|
3
5
|
# Note that cucumber-rails deprecated all its steps quite a while ago with the following
|
@@ -62,14 +64,14 @@ When /^(?:|I )follow "([^"]*)"$/ do |link|
|
|
62
64
|
end
|
63
65
|
|
64
66
|
# Fill in text field
|
65
|
-
When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
67
|
+
When /^(?:|I )fill in "([^"]*)" (?:with|for) "([^"]*)"$/ do |field, value|
|
66
68
|
patiently do
|
67
69
|
fill_in(field, :with => value)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
# Fill in text field
|
72
|
-
When /^(?:|I )fill in "([^"]*)" for
|
74
|
+
When /^(?:|I )fill in "([^"]*)" (?:with|for) '(.*)'$/ do |field, value|
|
73
75
|
patiently do
|
74
76
|
fill_in(field, :with => value)
|
75
77
|
end
|
@@ -279,7 +281,7 @@ end
|
|
279
281
|
# See [here](https://makandracards.com/makandra/1225-test-that-a-number-or-money-amount-is-shown-with-cucumber) for details
|
280
282
|
Then /^I should( not)? see the (?:number|amount) ([\-\d,\.]+)(?: (.*?))?$/ do |negate, amount, unit|
|
281
283
|
no_minus = amount.starts_with?('-') ? '' : '[^\\-]'
|
282
|
-
nbsp =
|
284
|
+
nbsp = " "
|
283
285
|
regexp = Regexp.new(no_minus + "\\b" + Regexp.quote(amount) + (unit ? "( |#{nbsp}| )(#{unit}|#{Regexp.quote(HTMLEntities.new.encode(unit, :named))})" :"\\b"))
|
284
286
|
expectation = negate ? :should_not : :should
|
285
287
|
patiently do
|
@@ -314,8 +316,15 @@ end
|
|
314
316
|
# Checks for the presence of an option in a select
|
315
317
|
Then /^"([^"]*)" should( not)? be an option for "([^"]*)"$/ do |value, negate, field|
|
316
318
|
patiently do
|
317
|
-
|
318
|
-
|
319
|
+
xpath = ".//option[text() = '#{value}']"
|
320
|
+
if negate
|
321
|
+
begin
|
322
|
+
field_labeled(field).find(:xpath, xpath).should_not be_present
|
323
|
+
rescue Capybara::ElementNotFound
|
324
|
+
end
|
325
|
+
else
|
326
|
+
field_labeled(field).find(:xpath, xpath).should be_present
|
327
|
+
end
|
319
328
|
end
|
320
329
|
end
|
321
330
|
|
data/lib/spreewald.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
|
1
3
|
class MailFinder
|
2
4
|
class << self
|
3
5
|
|
4
6
|
attr_accessor :user_identity
|
5
7
|
|
6
8
|
def find(conditions)
|
9
|
+
filename_method = Rails::VERSION::MAJOR < 3 ? 'original_filename' : 'filename'
|
7
10
|
ActionMailer::Base.deliveries.detect do |mail|
|
11
|
+
mail_body = email_text_body(mail)
|
8
12
|
[ conditions[:to].nil? || mail.to.include?(resolve_email conditions[:to]),
|
9
13
|
conditions[:cc].nil? || mail.cc.andand.include?(resolve_email conditions[:cc]),
|
10
14
|
conditions[:bcc].nil? || mail.bcc.andand.include?(resolve_email conditions[:bcc]),
|
11
15
|
conditions[:from].nil? || mail.from.include?(resolve_email conditions[:from]),
|
12
16
|
conditions[:subject].nil? || mail.subject.include?(conditions[:subject]),
|
13
|
-
conditions[:body].nil? ||
|
14
|
-
conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:
|
17
|
+
conditions[:body].nil? || mail_body.include?(conditions[:body]),
|
18
|
+
conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:"#{filename_method}").sort
|
15
19
|
].all?
|
16
20
|
end.tap do |mail|
|
17
21
|
log(mail)
|
@@ -30,13 +34,23 @@ class MailFinder
|
|
30
34
|
if mail.present?
|
31
35
|
File.open("log/test_mails.log", "a") do |file|
|
32
36
|
file << "From: #{mail.from}\n"
|
33
|
-
file << "To: #{mail.to.join(', ')}\n"
|
37
|
+
file << "To: #{mail.to.join(', ')}\n" if mail.to
|
34
38
|
file << "Subject: #{mail.subject}\n\n"
|
35
|
-
file << mail
|
39
|
+
file << email_text_body(mail)
|
36
40
|
file << "\n-------------------------\n\n"
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
45
|
+
def email_text_body(mail)
|
46
|
+
if mail.parts.any?
|
47
|
+
mail.parts.select { |part| part.content_type.include?('text/') }.collect(&:decoded).join("\n")
|
48
|
+
elsif mail.body.respond_to? :raw_source
|
49
|
+
mail.body.raw_source
|
50
|
+
else
|
51
|
+
mail.body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
41
55
|
end
|
42
56
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreewald
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tobias Kraze
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-10-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-10-31 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: cucumber-rails
|
@@ -92,7 +91,6 @@ files:
|
|
92
91
|
- lib/spreewald_support/version.rb
|
93
92
|
- spreewald.gemspec
|
94
93
|
- support/documentation_generator.rb
|
95
|
-
has_rdoc: true
|
96
94
|
homepage: https://github.com/makandra/spreewald
|
97
95
|
licenses: []
|
98
96
|
|
@@ -122,9 +120,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
120
|
requirements: []
|
123
121
|
|
124
122
|
rubyforge_project:
|
125
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.8.23
|
126
124
|
signing_key:
|
127
125
|
specification_version: 3
|
128
126
|
summary: Collection of useful cucumber steps.
|
129
127
|
test_files: []
|
130
128
|
|
129
|
+
has_rdoc:
|