spreewald 0.6.7 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,8 +22,8 @@ namespace :tests do
22
22
  success = true
23
23
  for_each_directory_of('tests/**/Rakefile') do |directory|
24
24
  Bundler.with_clean_env do
25
- env = "SPEC=../../#{ENV['SPEC']} " if ENV['SPEC']
26
- success &= system("cd #{directory} && #{env} bundle exec rake features")
25
+ env = "FEATURE=../../#{ENV['FEATURE']}" if ENV['FEATURE']
26
+ success &= system("cd #{directory} && bundle exec rake features #{env}")
27
27
  end
28
28
  end
29
29
  fail "Tests failed" unless success
@@ -15,24 +15,27 @@ end
15
15
  # Then an email should have been sent with:
16
16
  # """
17
17
  # From: max.mustermann@example.com
18
+ # Reply-To: mmuster@gmail.com
18
19
  # To: john.doe@example.com
19
20
  # Subject: Unter anderem der Betreff kann auch "Anführungszeichen" enthalten
20
- # Body: ...
21
21
  # Attachments: ...
22
+ #
23
+ # Message body goes here.
22
24
  # """
23
25
  #
24
26
  # You can skip lines, of course.
25
27
  Then /^(an|no) e?mail should have been sent with:$/ do |mode, raw_data|
26
28
  patiently do
27
29
  raw_data.strip!
28
- conditions = {}.tap do |hash|
29
- raw_data.split("\n").each do |row|
30
- if row.match(/^[a-z]+: /i)
31
- key, value = row.split(": ", 2)
32
- hash[key.downcase.to_sym] = value
33
- end
30
+ header, body = raw_data.split(/\n\n/)
31
+ conditions = {}
32
+ header.split("\n").each do |row|
33
+ if row.match(/^[a-z\-]+: /i)
34
+ key, value = row.split(": ", 2)
35
+ conditions[key.underscore.to_sym] = value
34
36
  end
35
37
  end
38
+ conditions[:body] = body if body
36
39
  @mail = MailFinder.find(conditions)
37
40
  expectation = mode == 'no' ? 'should_not' : 'should'
38
41
  @mail.send(expectation, be_present)
@@ -13,6 +13,7 @@ class MailFinder
13
13
  conditions[:cc].nil? || mail.cc.andand.include?(resolve_email conditions[:cc]),
14
14
  conditions[:bcc].nil? || mail.bcc.andand.include?(resolve_email conditions[:bcc]),
15
15
  conditions[:from].nil? || mail.from.include?(resolve_email conditions[:from]),
16
+ conditions[:reply_to].nil? || mail.reply_to.include?(resolve_email conditions[:reply_to]),
16
17
  conditions[:subject].nil? || mail.subject.include?(conditions[:subject]),
17
18
  conditions[:body].nil? || mail_body.include?(conditions[:body]),
18
19
  conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:"#{filename_method}").sort
@@ -1,5 +1,5 @@
1
1
  # coding: UTF-8
2
2
 
3
3
  module Spreewald
4
- VERSION = "0.6.7"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (0.6.0)
4
+ spreewald (0.6.7)
5
5
  capybara
6
6
  cucumber
7
7
  cucumber-rails
@@ -7,5 +7,6 @@ task :default => :features
7
7
  desc 'Run all specs for rails 2.3'
8
8
  Cucumber::Rake::Task.new(:features) do |t|
9
9
  # tell cucumber where it finds it files (subdirectories and symlinks are confusing it)
10
- t.cucumber_opts = "--require features --require features/shared features/shared/"
10
+ feature = ENV['FEATURE'] || "features/shared"
11
+ t.cucumber_opts = "--require features --require features/shared #{feature}"
11
12
  end
@@ -4,3 +4,4 @@ cucumber:
4
4
  host: localhost
5
5
  username: root
6
6
  password: junior
7
+
@@ -1,6 +1,3 @@
1
- EMAIL_RECIPIENT = "to@example.com"
2
- EMAIL_SENDER = "from@example.com"
3
-
4
1
  RSPEC_EXPECTATION_NOT_MET_ERROR = Spec::Expectations::ExpectationNotMetError
5
2
 
6
3
  config.action_mailer.delivery_method = :test
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (0.6.0)
4
+ spreewald (0.6.7)
5
5
  capybara
6
6
  cucumber
7
7
  cucumber-rails
@@ -7,6 +7,7 @@ task :default => :features
7
7
  desc 'Run all specs for rails 3.2'
8
8
  Cucumber::Rake::Task.new(:features) do |t|
9
9
  # tell cucumber where it finds it files (subdirectories and symlinks are confusing it)
10
- t.cucumber_opts = "--require features --require features/shared features/shared/"
10
+ feature = ENV['FEATURE'] || "features/shared"
11
+ t.cucumber_opts = "--require features --require features/shared #{feature}"
11
12
  end
12
13
 
@@ -4,3 +4,4 @@ cucumber:
4
4
  host: localhost
5
5
  username: root
6
6
  password: junior
7
+
@@ -5,12 +5,10 @@ class EmailsController < ApplicationController
5
5
  end
6
6
 
7
7
  def send_email
8
- text = params[:id].to_s
9
-
10
8
  if Rails.version >= "3"
11
- Mailer.email(text).deliver
9
+ Mailer.email.deliver
12
10
  else
13
- Mailer.deliver_email(text)
11
+ Mailer.deliver_email
14
12
  end
15
13
 
16
14
  render :nothing => true
@@ -1,23 +1,32 @@
1
1
  class Mailer < ActionMailer::Base
2
2
 
3
- if Rails.version >= "3"
3
+ REPLY_TO = "reply-to@example.com"
4
+ TO = "to@example.com"
5
+ FROM = "from@example.com"
6
+ SUBJECT = "SUBJECT"
7
+ BODY = "BODY"
4
8
 
5
- default :from => "from@example.com",
6
- :to => "to@example.com"
9
+ if Rails.version >= "3"
7
10
 
8
- def email(body = "body")
9
- mail(:subject => "email") do |format|
10
- format.text { render :text => body }
11
+ def email
12
+ mail(
13
+ :from => FROM,
14
+ :reply_to => REPLY_TO,
15
+ :to => TO,
16
+ :subject => SUBJECT
17
+ ) do |format|
18
+ format.text { render :text => BODY }
11
19
  end
12
20
  end
13
21
 
14
22
  else
15
23
 
16
- def email(body_text = "body")
17
- recipients EMAIL_RECIPIENT
18
- from EMAIL_SENDER
19
- subject "email"
20
- body body_text
24
+ def email
25
+ recipients TO
26
+ reply_to REPLY_TO
27
+ from FROM
28
+ subject SUBJECT
29
+ body BODY
21
30
  end
22
31
 
23
32
  end
@@ -9,8 +9,107 @@ Feature: Test Spreewald's email steps
9
9
  Then the following step should fail:
10
10
  | no email should have been sent |
11
11
 
12
-
13
12
  Scenario: /^I should see "([^\"]*)" in the e?mail$/
14
- When I go to "/emails/send_email/message_body"
13
+ When I go to "/emails/send_email"
15
14
  Then the following step should succeed:
16
- | I should see "message_body" in the email |
15
+ | I should see "BODY" in the email |
16
+ But the following step should fail:
17
+ | I should see "XYZ" in the email |
18
+
19
+ Scenario: /^(an|no) e?mail should have been sent with:$/
20
+ When I go to "/emails/send_email"
21
+
22
+ # Test without body
23
+ Then the following multiline step should succeed:
24
+ """
25
+ Then an email should have been sent with:
26
+ '''
27
+ From: from@example.com
28
+ Reply-To: reply-to@example.com
29
+ To: to@example.com
30
+ Subject: SUBJECT
31
+ '''
32
+ """
33
+
34
+ # Test with body
35
+ Then the following multiline step should succeed:
36
+ """
37
+ Then an email should have been sent with:
38
+ '''
39
+ From: from@example.com
40
+ Reply-To: reply-to@example.com
41
+ To: to@example.com
42
+ Subject: SUBJECT
43
+
44
+ BODY
45
+ '''
46
+ """
47
+
48
+ # Test with incorrect From header
49
+ Then the following multiline step should fail:
50
+ """
51
+ Then an email should have been sent with:
52
+ '''
53
+ From: other-from@example.com
54
+ Reply-To: reply-to@example.com
55
+ To: to@example.com
56
+ Subject: SUBJECT
57
+
58
+ BODY
59
+ '''
60
+ """
61
+
62
+ # Test with incorrect Reply-To header
63
+ Then the following multiline step should fail:
64
+ """
65
+ Then an email should have been sent with:
66
+ '''
67
+ From: from@example.com
68
+ Reply-To: other-reply-to@example.com
69
+ To: to@example.com
70
+ Subject: SUBJECT
71
+
72
+ BODY
73
+ '''
74
+ """
75
+ # Test with incorrect To header
76
+ Then the following multiline step should fail:
77
+ """
78
+ Then an email should have been sent with:
79
+ '''
80
+ From: from@example.com
81
+ Reply-To: reply-to@example.com
82
+ To: other-to@example.com
83
+ Subject: SUBJECT
84
+
85
+ BODY
86
+ '''
87
+ """
88
+
89
+ # Test with incorrect Subject header
90
+ Then the following multiline step should fail:
91
+ """
92
+ Then an email should have been sent with:
93
+ '''
94
+ From: from@example.com
95
+ Reply-To: reply-to@example.com
96
+ To: to@example.com
97
+ Subject: OTHER-SUBJECT
98
+
99
+ BODY
100
+ '''
101
+ """
102
+
103
+ # Test with incorrect body
104
+ Then the following multiline step should fail:
105
+ """
106
+ Then an email should have been sent with:
107
+ '''
108
+ From: from@example.com
109
+ Reply-To: reply-to@example.com
110
+ To: to@example.com
111
+ Subject: SUBJECT
112
+
113
+ OTHER-BODY
114
+ '''
115
+ """
@@ -21,7 +21,7 @@ When /^I run the following steps?:$/ do |steps_table|
21
21
  end
22
22
 
23
23
  Then /^the following multiline step should (fail|succeed):$/ do |expectation, multiline_step|
24
-
24
+ multiline_step = multiline_step.gsub(%{'''}, %{"""})
25
25
  if expectation == 'fail'
26
26
  expect { steps(multiline_step) }.to raise_error(RSPEC_EXPECTATION_NOT_MET_ERROR)
27
27
  else # succeed
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: 9
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
8
  - 7
10
- version: 0.6.7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Kraze
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-10-16 00:00:00 +02:00
18
+ date: 2013-10-30 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency