spreewald 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +7 -7
  5. data/lib/spreewald/email_steps.rb +10 -8
  6. data/lib/spreewald/web_steps.rb +12 -7
  7. data/lib/spreewald_support/version.rb +1 -1
  8. data/tests/rails-3_capybara-1/Gemfile.lock +1 -1
  9. data/tests/rails-3_capybara-1/config/cucumber.yml +2 -0
  10. data/tests/rails-3_capybara-1/config/database.yml +7 -0
  11. data/tests/rails-3_capybara-1/features/support/paths.rb +16 -0
  12. data/tests/rails-3_capybara-1/features/support/selectors.rb +52 -0
  13. data/tests/rails-3_capybara-2/Gemfile.lock +1 -1
  14. data/tests/rails-3_capybara-2/Rakefile +18 -0
  15. data/tests/rails-3_capybara-2/config.ru +4 -0
  16. data/tests/rails-4_capybara-3/Gemfile.lock +1 -1
  17. data/tests/rails-4_capybara-3/features/development_steps.feature +8 -0
  18. data/tests/rails-4_capybara-3/features/email_steps.feature +216 -0
  19. data/tests/rails-4_capybara-3/features/overriding.feature +5 -0
  20. data/tests/rails-4_capybara-3/features/step_definitions/overriding_steps.rb +3 -0
  21. data/tests/rails-4_capybara-3/features/step_definitions/test_steps.rb +56 -0
  22. data/tests/rails-4_capybara-3/features/support/paths.rb +16 -0
  23. data/tests/rails-4_capybara-3/features/support/selectors.rb +52 -0
  24. data/tests/rails-4_capybara-3/features/table_steps.feature +293 -0
  25. data/tests/rails-4_capybara-3/features/web_steps.feature +295 -0
  26. data/tests/shared/app/views/forms/disabled_elements.html.haml +53 -0
  27. data/tests/shared/features/shared/email_steps.feature +3 -11
  28. data/tests/shared/features/shared/web_steps.feature +25 -0
  29. metadata +5 -31
  30. data/tests/rails-3_capybara-1/app +0 -1
  31. data/tests/rails-3_capybara-1/config/cucumber.yml +0 -1
  32. data/tests/rails-3_capybara-1/config/database.yml +0 -1
  33. data/tests/rails-3_capybara-1/db +0 -1
  34. data/tests/rails-3_capybara-1/features/shared +0 -1
  35. data/tests/rails-3_capybara-1/features/support/paths.rb +0 -1
  36. data/tests/rails-3_capybara-1/features/support/selectors.rb +0 -1
  37. data/tests/rails-3_capybara-1/public +0 -1
  38. data/tests/rails-3_capybara-2/Rakefile +0 -1
  39. data/tests/rails-3_capybara-2/app +0 -1
  40. data/tests/rails-3_capybara-2/config +0 -1
  41. data/tests/rails-3_capybara-2/config.ru +0 -1
  42. data/tests/rails-3_capybara-2/db +0 -1
  43. data/tests/rails-3_capybara-2/features +0 -1
  44. data/tests/rails-3_capybara-2/public +0 -1
  45. data/tests/rails-3_capybara-2/script +0 -1
  46. data/tests/rails-4_capybara-3/app +0 -1
  47. data/tests/rails-4_capybara-3/db +0 -1
  48. data/tests/rails-4_capybara-3/features/development_steps.feature +0 -1
  49. data/tests/rails-4_capybara-3/features/email_steps.feature +0 -1
  50. data/tests/rails-4_capybara-3/features/overriding.feature +0 -1
  51. data/tests/rails-4_capybara-3/features/step_definitions/overriding_steps.rb +0 -1
  52. data/tests/rails-4_capybara-3/features/step_definitions/test_steps.rb +0 -1
  53. data/tests/rails-4_capybara-3/features/support/paths.rb +0 -1
  54. data/tests/rails-4_capybara-3/features/support/selectors.rb +0 -1
  55. data/tests/rails-4_capybara-3/features/table_steps.feature +0 -1
  56. data/tests/rails-4_capybara-3/features/web_steps.feature +0 -1
  57. data/tests/rails-4_capybara-3/public/fixture_files +0 -1
  58. data/tests/shared/db/test.sqlite3 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 356289403f9035cb4de73481fbe3fe874dfaa64e
4
- data.tar.gz: eb92d6018a939b0ac4046323e69b14a05435a556
3
+ metadata.gz: dbbb1aa373a4a39fef3fa0919d4d93e1b8e2410a
4
+ data.tar.gz: 324f16cba03ab1e80147a95da42a39a24421dd14
5
5
  SHA512:
6
- metadata.gz: 045cf38593b6bc640a02474401d5416a06310045e53b26dfe0a9b834cfb3d4114fd0b93ee522a886fd346fd0bf502ef356f0fe3f481eb024717f96bedafc0ecf
7
- data.tar.gz: b0891a0aa08f0e811cad30834965edfd939b58d2b3b5255af7c8b3a6875a4045092c838ceaa2cbf78499944ac8e8d628a3b572bfed3fde69117c68ff5a16b191
6
+ metadata.gz: 755e1efa4859d6e3e749f005e69917719a95a9e45cdbc3358c90b0f12997b2e0501d944a243bc03467701f2fa5ea1a1bf80127af6791271e36f343a231ac1839
7
+ data.tar.gz: 1ac713920860234a6b39b2c3fc14de320ff09d4b5634fa757233f63107038a19d042b2004a1bf8e00e9ad06e7539b128bbd82cf50cb04f47569b302cc590dea9
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ InstalledFiles
11
11
  tmp
12
12
  _yardoc
13
13
  *.log
14
+ tests/shared/db/test.sqlite3
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## 2.2.2
7
+ - Fix `Then the "something" button should be disabled` (see issue [#18](https://github.com/makandra/spreewald/issues/18))
8
+ - Improve documentation of emails steps
9
+ - Clarify step definition of `that e?mail should have the following (?:|content in the )body:`
10
+
6
11
  ## 2.2.1
7
12
  - Refactor the `I should see the (number|amount)` step. (see issues [#43](https://github.com/makandra/spreewald/issues/43) and [#44](https://github.com/makandra/spreewald/issues/44))
8
13
  * It can now be composed with the 'within' step
data/README.md CHANGED
@@ -171,8 +171,9 @@ the step definitions.
171
171
  Message body goes here.
172
172
  """
173
173
 
174
- You can skip lines, of course. Note that the mail body is only checked for
175
- _inclusion_.
174
+ You can skip lines in the header, of course. Note that the mail body is only checked for
175
+ _inclusion_. That means you can only test a prefix of the body. The subject can also be
176
+ a prefix.
176
177
 
177
178
 
178
179
  * **When I follow the (first|second|third)? link in the e?mail**
@@ -195,8 +196,6 @@ the step definitions.
195
196
 
196
197
  * **Then that e?mail should( not)? have the following lines in the body:**
197
198
 
198
- Only works after you've retrieved the email using "Then an email should have been sent with:"
199
-
200
199
  Example:
201
200
 
202
201
  And that mail should have the following lines in the body:
@@ -204,11 +203,12 @@ the step definitions.
204
203
  All of these lines
205
204
  need to be present
206
205
  """
206
+
207
+ You can skip lines, of course. Note that the lines are only checked for _inclusion_.
207
208
 
208
209
 
209
- * **Then that e?mail should have the following body:**
210
+ * **Then that e?mail should have the following (|content in the )body:**
210
211
 
211
- Only works after you've retrieved the email using "Then an email should have been sent with:"
212
212
  Checks that the text should be included in the retrieved email
213
213
 
214
214
 
@@ -656,7 +656,7 @@ deprecation notice. Decide for yourself whether you want to use them:
656
656
 
657
657
  * **Then the "..." (field|button|checkbox) should( not)? be disabled**
658
658
 
659
- Tests that an input or button with the given label is disabled.
659
+ Tests that an input, button or checkbox with the given label is disabled.
660
660
 
661
661
 
662
662
  * **Then the "..." field should( not)? be visible**
@@ -23,8 +23,9 @@ end.overridable
23
23
  # Message body goes here.
24
24
  # """
25
25
  #
26
- # You can skip lines, of course. Note that the mail body is only checked for
27
- # _inclusion_.
26
+ # You can skip lines in the header, of course. Note that the mail body is only checked for
27
+ # _inclusion_. That means you can only test a prefix of the body. The subject can also be
28
+ # a prefix.
28
29
  Then /^(an|no) e?mail should have been sent with:$/ do |mode, raw_data|
29
30
  patiently do
30
31
  raw_data.strip!
@@ -93,8 +94,6 @@ Then /^show me the e?mails$/ do
93
94
  end
94
95
  end.overridable
95
96
 
96
- # Only works after you've retrieved the email using "Then an email should have been sent with:"
97
- #
98
97
  # Example:
99
98
  #
100
99
  # And that mail should have the following lines in the body:
@@ -102,17 +101,20 @@ end.overridable
102
101
  # All of these lines
103
102
  # need to be present
104
103
  # """
104
+ #
105
+ # You can skip lines, of course. Note that the lines are only checked for _inclusion_.
105
106
  Then /^that e?mail should( not)? have the following lines in the body:$/ do |negate, body|
106
107
  expectation = negate ? 'not_to' : 'to'
107
- email_text_body = MailFinder.email_text_body(@mail)
108
+ mail = @mail || ActionMailer::Base.deliveries.last
109
+ email_text_body = MailFinder.email_text_body(mail)
108
110
 
109
111
  body.to_s.strip.split(/\n/).each do |line|
110
112
  expect(email_text_body).send(expectation, include(line.strip))
111
113
  end
112
114
  end.overridable
113
115
 
114
- # Only works after you've retrieved the email using "Then an email should have been sent with:"
115
116
  # Checks that the text should be included in the retrieved email
116
- Then /^that e?mail should have the following body:$/ do |body|
117
- expect(MailFinder.email_text_body(@mail)).to include(body.strip)
117
+ Then /^that e?mail should have the following (?:|content in the )body:$/ do |body|
118
+ mail = @mail || ActionMailer::Base.deliveries.last
119
+ expect(MailFinder.email_text_body(mail)).to include(body.strip)
118
120
  end.overridable
@@ -662,18 +662,23 @@ When /^I switch to the new tab$/ do
662
662
  end
663
663
  end.overridable
664
664
 
665
- # Tests that an input or button with the given label is disabled.
665
+ # Tests that an input, button or checkbox with the given label is disabled.
666
666
  Then /^the "([^\"]*)" (field|button|checkbox) should( not)? be disabled$/ do |label, kind, negate|
667
- if kind == 'field' || kind == 'checkbox'
668
- if Capybara::VERSION < "2.1"
669
- element = find_field(label, :disabled => !negate)
667
+ if Gem::Version.new(Capybara::VERSION) < Gem::Version.new("2.1")
668
+ if kind == 'field' || kind == 'checkbox'
669
+ element = find_field(label)
670
670
  else
671
- element = find_field(label, :disabled => !negate)
671
+ element = find_button(label)
672
672
  end
673
+ expect(element[:disabled]).send(negate ? :to : :not_to, eq(nil))
673
674
  else
674
- element = find_button(label)
675
+ if kind == 'field' || kind == 'checkbox'
676
+ element = find_field(label, disabled: !negate)
677
+ else
678
+ element = find_button(label, disabled: !negate)
679
+ end
680
+ expect(element).to be_present
675
681
  end
676
- expect(["false", "", nil]).send(negate ? :not_to : :to, include(element[:disabled]))
677
682
  end.overridable
678
683
 
679
684
  # Tests that a field with the given label is visible.
@@ -1,3 +1,3 @@
1
1
  module Spreewald
2
- VERSION = '2.2.1'
2
+ VERSION = '2.2.2'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (2.2.1)
4
+ spreewald (2.2.2)
5
5
  cucumber
6
6
  cucumber_priority (>= 0.3.0)
7
7
  rspec (>= 2.13.0)
@@ -0,0 +1,2 @@
1
+ default: --require features --require features/shared features/shared
2
+
@@ -0,0 +1,7 @@
1
+ development:
2
+ adapter: sqlite3
3
+ database: ":memory:"
4
+
5
+ test:
6
+ adapter: sqlite3
7
+ database: ":memory:"
@@ -0,0 +1,16 @@
1
+ module NavigationHelpers
2
+
3
+ def path_to(page_name)
4
+ case page_name
5
+ when /^"(.*)"$/
6
+ $1
7
+
8
+ else
9
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
10
+ "Now, go and add a mapping in #{__FILE__}"
11
+ end
12
+ end
13
+
14
+ end
15
+
16
+ World(NavigationHelpers)
@@ -0,0 +1,52 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when /^a panel?$/
12
+ '.panel'
13
+
14
+ when /^a panels nested contents?$/
15
+ '.panel--nested-contents'
16
+
17
+ when /^the timeline?$/
18
+ '.timeline'
19
+
20
+ when /^the table row containing "(.+?)"$/
21
+ all('tr').detect { |tr| tr.text.include? $1 } || raise("Could not find tr containing #{$1.inspect}")
22
+
23
+ when /^a table$/
24
+ '.table'
25
+
26
+ # Add more mappings here.
27
+ # Here is an example that pulls values out of the Regexp:
28
+ #
29
+ # when /^the (notice|error|info) flash$/
30
+ # ".flash.#{$1}"
31
+
32
+ # You can also return an array to use a different selector
33
+ # type, like:
34
+ #
35
+ # when /the header/
36
+ # [:xpath, "//header"]
37
+
38
+ # This allows you to provide a quoted selector as the scope
39
+ # for "within" steps as was previously the default for the
40
+ # web steps:
41
+ when /^"(.+)"$/
42
+ $1
43
+
44
+ else
45
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
46
+ "Now, go and add a mapping in #{__FILE__}"
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ World(HtmlSelectorsHelpers)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (2.2.1)
4
+ spreewald (2.2.2)
5
5
  cucumber
6
6
  cucumber_priority (>= 0.3.0)
7
7
  rspec (>= 2.13.0)
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+ require 'cucumber/rake/task'
3
+
4
+ desc 'Default: Run all specs for a specific rails version.'
5
+ task :default => :features
6
+
7
+ desc 'Run all specs for rails 3.2'
8
+ Cucumber::Rake::Task.new(:features) do |t|
9
+ feature = if ENV['SINGLE_FEATURE']
10
+ "../../shared/features/shared/#{ ENV['SINGLE_FEATURE'] }"
11
+ else
12
+ 'features/shared'
13
+ end
14
+
15
+ # tell cucumber where it finds it files (subdirectories and symlinks are confusing it)
16
+ t.cucumber_opts = "--require features --require features/shared #{feature}"
17
+ end
18
+
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run SpreewaldTest::Application
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- spreewald (2.2.1)
4
+ spreewald (2.2.2)
5
5
  cucumber
6
6
  cucumber_priority (>= 0.3.0)
7
7
  rspec (>= 2.13.0)
@@ -0,0 +1,8 @@
1
+ Feature: Development steps
2
+
3
+ Scenario: /^it should work(.+?)?$/ (without a reason)
4
+ Then it should work
5
+
6
+ Scenario: /^it should work(.+?)?$/ (with a given reason)
7
+ Then it should work once the blocker described here was fulfilled. (Feature should be pending)
8
+
@@ -0,0 +1,216 @@
1
+ Feature: Test Spreewald's email steps
2
+
3
+ Scenario: /^no e?mail should have been sent$/
4
+ When I go to "/emails/do_nothing"
5
+ Then the following step should succeed:
6
+ | no email should have been sent |
7
+
8
+ When I go to "/emails/send_email"
9
+ Then the following step should fail:
10
+ | no email should have been sent |
11
+
12
+
13
+ Scenario: /^I should see "([^\"]*)" in the e?mail$/
14
+ When I go to "/emails/send_email"
15
+ Then the following step should succeed:
16
+ | I should see "Body" in the email |
17
+ But the following step should fail:
18
+ | I should see "XYZ" in the email |
19
+
20
+
21
+ Scenario: /^(an|no) e?mail should have been sent with:$/
22
+ When I go to "/emails/send_email"
23
+
24
+ # Test without body
25
+ Then the following multiline step should succeed:
26
+ """
27
+ Then an email should have been sent with:
28
+ '''
29
+ From: from@example.com
30
+ Reply-To: reply-to@example.com
31
+ To: to@example.com
32
+ Subject: SUBJECT
33
+ '''
34
+ """
35
+
36
+ # Test with body
37
+ Then the following multiline step should succeed:
38
+ """
39
+ Then an email should have been sent with:
40
+ '''
41
+ From: from@example.com
42
+ Reply-To: reply-to@example.com
43
+ To: to@example.com
44
+ Subject: SUBJECT
45
+
46
+ Body
47
+ with
48
+ line
49
+ breaks
50
+ '''
51
+ """
52
+
53
+ # Test with incorrect From header
54
+ Then the following multiline step should fail:
55
+ """
56
+ Then an email should have been sent with:
57
+ '''
58
+ From: other-from@example.com
59
+ Reply-To: reply-to@example.com
60
+ To: to@example.com
61
+ Subject: SUBJECT
62
+
63
+ Body
64
+ with
65
+ line
66
+ breaks
67
+ '''
68
+ """
69
+
70
+ # Test with incorrect Reply-To header
71
+ Then the following multiline step should fail:
72
+ """
73
+ Then an email should have been sent with:
74
+ '''
75
+ From: from@example.com
76
+ Reply-To: other-reply-to@example.com
77
+ To: to@example.com
78
+ Subject: SUBJECT
79
+
80
+ Body
81
+ with
82
+ line
83
+ breaks
84
+ '''
85
+ """
86
+ # Test with incorrect To header
87
+ Then the following multiline step should fail:
88
+ """
89
+ Then an email should have been sent with:
90
+ '''
91
+ From: from@example.com
92
+ Reply-To: reply-to@example.com
93
+ To: other-to@example.com
94
+ Subject: SUBJECT
95
+
96
+ Body
97
+ with
98
+ line
99
+ breaks
100
+ '''
101
+ """
102
+
103
+ # Test with incorrect Subject header
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: OTHER-SUBJECT
112
+
113
+ Body
114
+ with
115
+ line
116
+ breaks
117
+ '''
118
+ """
119
+
120
+ # Test with incorrect body
121
+ Then the following multiline step should fail:
122
+ """
123
+ Then an email should have been sent with:
124
+ '''
125
+ From: from@example.com
126
+ Reply-To: reply-to@example.com
127
+ To: to@example.com
128
+ Subject: SUBJECT
129
+
130
+ Other body
131
+ with
132
+ line
133
+ breaks
134
+ '''
135
+ """
136
+
137
+ # Test body with multiple paragraphs
138
+ Then the following multiline step should fail:
139
+ """
140
+ Then an email should have been sent with:
141
+ '''
142
+ From: from@example.com
143
+ Reply-To: reply-to@example.com
144
+ To: to@example.com
145
+ Subject: SUBJECT
146
+
147
+ Body
148
+ with
149
+ line
150
+ breaks
151
+
152
+ MORE-BODY
153
+ '''
154
+ """
155
+
156
+ Scenario: /^(an|no) e?mail should have been sent((?: |and|with|from "[^"]+"|bcc "[^"]+"|cc "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/
157
+ When I go to "/emails/send_email"
158
+
159
+ # Test with correct conditions
160
+ Then the following multiline step should succeed:
161
+ """
162
+ Then an email should have been sent from "from@example.com" to "to@example.com" cc "cc@example.com" bcc "bcc@example.com" and the subject "SUBJECT" and the attachments "attached_file.pdf"
163
+ """
164
+
165
+ # Test with wrong conditions
166
+ Then the following multiline step should fail:
167
+ """
168
+ Then an email should have been sent from "from@example.com" to "to@example.com" cc "cc@example.com" bcc "wrong_bcc@example.com" and the subject "SUBJECT" and the attachments "attached_file.pdf"
169
+ """
170
+
171
+ Scenario: /^that e?mail should have the following lines in the body:$/
172
+ When I go to "/emails/send_email"
173
+
174
+ # Test with correct body lines
175
+ Then the following multiline step should succeed:
176
+ """
177
+ Then that email should have the following lines in the body:
178
+ '''
179
+ with
180
+ line
181
+ '''
182
+ """
183
+
184
+ # Test with wrong body lines
185
+ Then the following multiline step should fail:
186
+ """
187
+ Then that email should have the following lines in the body:
188
+ '''
189
+ wrong
190
+ line
191
+ '''
192
+ """
193
+
194
+
195
+ Scenario: /^that e?mail should have the following( content in the)? body$/
196
+ When I go to "/emails/send_email"
197
+
198
+ # Test with correct body lines
199
+ Then the following multiline step should succeed:
200
+ """
201
+ Then that email should have the following content in the body:
202
+ '''
203
+ with
204
+ line
205
+ '''
206
+ """
207
+
208
+ # Test with wrong body lines
209
+ Then the following multiline step should fail:
210
+ """
211
+ Then that email should have the following body:
212
+ '''
213
+ wrong
214
+ line
215
+ '''
216
+ """