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 CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  Dir[File.join(File.dirname(__FILE__), '*_steps.rb')].each do |f|
2
4
  name = File.basename(f, '.rb')
3
5
  unless name == 'all_steps'
@@ -1,4 +1,4 @@
1
- #
1
+ # coding: UTF-8
2
2
 
3
3
  # Marks scenario as pending
4
4
  Then /^it should work$/ do
@@ -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.body.to_s.scan(Patterns::URL)[index][2]
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.body.should include(text)
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 = 0xC2.chr + 0xA0.chr
34
+ nbsp = " "
33
35
  content.gsub(/[\r\n\t]+/, ' ').gsub(nbsp, ' ').gsub(/ {2,}/, ' ').strip
34
36
  end
35
37
 
@@ -1,3 +1,6 @@
1
+ # coding: UTF-8
2
+
3
+
1
4
  # Steps to travel through time using [Timecop](https://github.com/jtrupiano/timecop).
2
5
  #
3
6
  # See [this article](https://makandracards.com/makandra/1222-useful-cucumber-steps-to-travel-through-time-with-timecop) for details.
@@ -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 "([^"]*)"$/ do |value, field|
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 = 0xC2.chr + 0xA0.chr
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
- expectation = negate ? :should_not : :should
318
- field_labeled(field).find(:xpath, ".//option[text() = '#{value}']").send(expectation, be_present)
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,2 +1,4 @@
1
+ # coding: UTF-8
2
+
1
3
  require "spreewald_support/version"
2
4
  require "spreewald_support/github"
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  module Spreewald
2
4
  def self.github_url
3
5
  "https://github.com/makandra/spreewald"
@@ -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? || mail.body.include?(conditions[:body]),
14
- conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:original_filename).sort
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.body
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
@@ -1,6 +1,8 @@
1
+ # coding: UTF-8
2
+
1
3
  module PathSelectorFallbacks
2
4
  def _selector_for(locator)
3
- if respond_to?(:select_for)
5
+ if respond_to?(:selector_for)
4
6
  selector_for(locator)
5
7
  elsif locator =~ /^"(.+)"$/
6
8
  $1
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  module StepFallback
2
4
  def step(*args)
3
5
  if defined?(super)
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  module ToleranceForSeleniumSyncIssues
2
4
  # This is similiar but not entirely the same as Capybara::Node::Base#wait_until or Capybara::Session#wait_until
3
5
  def patiently(seconds=Capybara.default_wait_time, &block)
@@ -1,3 +1,5 @@
1
+ # coding: UTF-8
2
+
1
3
  module Spreewald
2
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
3
5
  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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
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-30 00:00:00 +01:00
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.3.9.5
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: