express_pigeon 1.0.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +1 -0
  3. data/.gitignore +19 -16
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +17 -0
  6. data/.rubocop_todo.yml +15 -0
  7. data/.ruby-gemset +1 -0
  8. data/.ruby-version +1 -0
  9. data/CONTRIBUTING.md +21 -0
  10. data/Gemfile +13 -8
  11. data/Guardfile +56 -0
  12. data/LICENSE +9 -2
  13. data/README.md +4 -124
  14. data/Rakefile +1 -2
  15. data/express_pigeon.gemspec +31 -16
  16. data/lib/express_pigeon/api/campaigns.rb +62 -0
  17. data/lib/express_pigeon/api/contacts.rb +42 -0
  18. data/lib/express_pigeon/api/lists.rb +49 -0
  19. data/lib/express_pigeon/api/messages.rb +56 -0
  20. data/lib/express_pigeon/api.rb +66 -0
  21. data/lib/express_pigeon/autoresponders.rb +0 -0
  22. data/lib/express_pigeon/contacts.rb +71 -0
  23. data/lib/express_pigeon/lists.rb +111 -0
  24. data/lib/express_pigeon/meta_hash.rb +20 -0
  25. data/lib/express_pigeon/templates.rb +4 -0
  26. data/lib/express_pigeon/transactional_emails.rb +4 -0
  27. data/lib/express_pigeon/version.rb +1 -1
  28. data/lib/express_pigeon.rb +16 -442
  29. data/spec/express_pigeon/api/campaigns_spec.rb +100 -0
  30. data/spec/express_pigeon/api/contacts_spec.rb +146 -0
  31. data/spec/express_pigeon/api/lists_spec.rb +23 -0
  32. data/spec/express_pigeon/api/messages_spec.rb +36 -0
  33. data/spec/express_pigeon/contacts_spec.rb +111 -0
  34. data/spec/express_pigeon/lists_spec.rb +131 -0
  35. data/spec/fixtures/contacts.csv +2 -0
  36. data/spec/fixtures/contacts.csv.zip +0 -0
  37. data/spec/spec_helper.rb +100 -12
  38. data/vendor/cache/ast-2.0.0.gem +0 -0
  39. data/vendor/cache/astrolabe-1.3.0.gem +0 -0
  40. data/vendor/cache/awesome_print-1.2.0.gem +0 -0
  41. data/vendor/cache/byebug-3.5.1.gem +0 -0
  42. data/vendor/cache/celluloid-0.16.0.gem +0 -0
  43. data/vendor/cache/coderay-1.1.0.gem +0 -0
  44. data/vendor/cache/colorize-0.7.5.gem +0 -0
  45. data/vendor/cache/columnize-0.9.0.gem +0 -0
  46. data/vendor/cache/debugger-linecache-1.2.0.gem +0 -0
  47. data/vendor/cache/diff-lcs-1.2.5.gem +0 -0
  48. data/vendor/cache/docile-1.1.5.gem +0 -0
  49. data/vendor/cache/dotenv-1.0.2.gem +0 -0
  50. data/vendor/cache/ffi-1.9.6.gem +0 -0
  51. data/vendor/cache/formatador-0.2.5.gem +0 -0
  52. data/vendor/cache/guard-2.10.5.gem +0 -0
  53. data/vendor/cache/guard-compat-1.2.0.gem +0 -0
  54. data/vendor/cache/guard-rspec-4.5.0.gem +0 -0
  55. data/vendor/cache/hitimes-1.2.2.gem +0 -0
  56. data/vendor/cache/httmultiparty-0.3.16.gem +0 -0
  57. data/vendor/cache/httparty-0.13.3.gem +0 -0
  58. data/vendor/cache/json-1.8.1.gem +0 -0
  59. data/vendor/cache/listen-2.8.4.gem +0 -0
  60. data/vendor/cache/lumberjack-1.0.9.gem +0 -0
  61. data/vendor/cache/method_source-0.8.2.gem +0 -0
  62. data/vendor/cache/mimemagic-0.2.1.gem +0 -0
  63. data/vendor/cache/multi_json-1.10.1.gem +0 -0
  64. data/vendor/cache/multi_xml-0.5.5.gem +0 -0
  65. data/vendor/cache/multipart-post-2.0.0.gem +0 -0
  66. data/vendor/cache/nenv-0.1.1.gem +0 -0
  67. data/vendor/cache/parser-2.2.0.pre.8.gem +0 -0
  68. data/vendor/cache/powerpack-0.0.9.gem +0 -0
  69. data/vendor/cache/pry-0.10.1.gem +0 -0
  70. data/vendor/cache/pry-byebug-2.0.0.gem +0 -0
  71. data/vendor/cache/rainbow-2.0.0.gem +0 -0
  72. data/vendor/cache/rake-10.4.2.gem +0 -0
  73. data/vendor/cache/rb-fsevent-0.9.4.gem +0 -0
  74. data/vendor/cache/rb-inotify-0.9.5.gem +0 -0
  75. data/vendor/cache/rspec-3.1.0.gem +0 -0
  76. data/vendor/cache/rspec-core-3.1.7.gem +0 -0
  77. data/vendor/cache/rspec-expectations-3.1.2.gem +0 -0
  78. data/vendor/cache/rspec-mocks-3.1.3.gem +0 -0
  79. data/vendor/cache/rspec-support-3.1.2.gem +0 -0
  80. data/vendor/cache/rubocop-0.28.0.gem +0 -0
  81. data/vendor/cache/ruby-progressbar-1.7.1.gem +0 -0
  82. data/vendor/cache/simplecov-0.9.1.gem +0 -0
  83. data/vendor/cache/simplecov-html-0.8.0.gem +0 -0
  84. data/vendor/cache/slop-3.6.0.gem +0 -0
  85. data/vendor/cache/thor-0.19.1.gem +0 -0
  86. data/vendor/cache/timers-4.0.1.gem +0 -0
  87. metadata +183 -53
  88. data/.rvmrc +0 -52
  89. data/.travis.yml +0 -8
  90. data/CHANGELOG +0 -6
  91. data/bin/console +0 -12
  92. data/express_pigeon-rb.yml +0 -10
  93. data/lib/active_model/validations/date_format_validator.rb +0 -20
  94. data/script/lint +0 -6
  95. data/script/multispec +0 -23
  96. data/spec/web_forms_spec.rb +0 -164
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,115 +1,245 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: express_pigeon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
- - Michael D. Hall
7
+ - Mike
8
+ - Hall
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
12
+ date: 2014-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activemodel
15
+ name: httparty
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>='
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
- version: '0'
20
+ version: 0.13.3
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - "~>"
28
26
  - !ruby/object:Gem::Version
29
- version: '0'
27
+ version: 0.13.3
30
28
  - !ruby/object:Gem::Dependency
31
- name: curb-fu
29
+ name: httmultiparty
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - "~>"
36
33
  - !ruby/object:Gem::Version
37
- version: '0'
34
+ version: '0.3'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 0.3.16
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
41
  requirements:
43
- - - ! '>='
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '0.3'
45
+ - - ">="
44
46
  - !ruby/object:Gem::Version
45
- version: '0'
47
+ version: 0.3.16
46
48
  - !ruby/object:Gem::Dependency
47
- name: chronic
49
+ name: bundler
48
50
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
51
  requirements:
51
- - - ! '>='
52
+ - - "~>"
52
53
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
54
+ version: '1.7'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: rspec
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.1'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 3.1.0
86
+ type: :development
55
87
  prerelease: false
56
88
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
89
  requirements:
59
- - - ! '>='
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '3.1'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 3.1.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: awesome_print
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.2'
103
+ - - ">="
60
104
  - !ruby/object:Gem::Version
61
- version: '0'
62
- description: Light-weight wrapper around ExpressPigeon.
105
+ version: 1.2.0
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.2'
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 1.2.0
116
+ description: |2
117
+ (Another) ExpressPigeon Ruby API for sending transactional messages,
118
+ manipulating lists, contacts and more.
63
119
  email:
64
- - mdh@just3ws.com
65
- executables:
66
- - console
120
+ - mike@just3ws.com
121
+ executables: []
67
122
  extensions: []
68
- extra_rdoc_files: []
123
+ extra_rdoc_files:
124
+ - LICENSE
125
+ - README.md
69
126
  files:
70
- - .gitignore
71
- - .rspec
72
- - .rvmrc
73
- - .travis.yml
74
- - CHANGELOG
127
+ - ".env.example"
128
+ - ".gitignore"
129
+ - ".rspec"
130
+ - ".rubocop.yml"
131
+ - ".rubocop_todo.yml"
132
+ - ".ruby-gemset"
133
+ - ".ruby-version"
134
+ - CONTRIBUTING.md
75
135
  - Gemfile
136
+ - Guardfile
76
137
  - LICENSE
77
138
  - README.md
78
139
  - Rakefile
79
- - bin/console
80
- - express_pigeon-rb.yml
81
140
  - express_pigeon.gemspec
82
- - lib/active_model/validations/date_format_validator.rb
83
141
  - lib/express_pigeon.rb
142
+ - lib/express_pigeon/api.rb
143
+ - lib/express_pigeon/api/campaigns.rb
144
+ - lib/express_pigeon/api/contacts.rb
145
+ - lib/express_pigeon/api/lists.rb
146
+ - lib/express_pigeon/api/messages.rb
147
+ - lib/express_pigeon/autoresponders.rb
148
+ - lib/express_pigeon/contacts.rb
149
+ - lib/express_pigeon/lists.rb
150
+ - lib/express_pigeon/meta_hash.rb
151
+ - lib/express_pigeon/templates.rb
152
+ - lib/express_pigeon/transactional_emails.rb
84
153
  - lib/express_pigeon/version.rb
85
- - script/lint
86
- - script/multispec
154
+ - spec/express_pigeon/api/campaigns_spec.rb
155
+ - spec/express_pigeon/api/contacts_spec.rb
156
+ - spec/express_pigeon/api/lists_spec.rb
157
+ - spec/express_pigeon/api/messages_spec.rb
158
+ - spec/express_pigeon/contacts_spec.rb
159
+ - spec/express_pigeon/lists_spec.rb
160
+ - spec/fixtures/contacts.csv
161
+ - spec/fixtures/contacts.csv.zip
87
162
  - spec/spec_helper.rb
88
- - spec/web_forms_spec.rb
89
- homepage: http://github.com/just3ws/express_pigeon-rb
90
- licenses: []
163
+ - vendor/cache/ast-2.0.0.gem
164
+ - vendor/cache/astrolabe-1.3.0.gem
165
+ - vendor/cache/awesome_print-1.2.0.gem
166
+ - vendor/cache/byebug-3.5.1.gem
167
+ - vendor/cache/celluloid-0.16.0.gem
168
+ - vendor/cache/coderay-1.1.0.gem
169
+ - vendor/cache/colorize-0.7.5.gem
170
+ - vendor/cache/columnize-0.9.0.gem
171
+ - vendor/cache/debugger-linecache-1.2.0.gem
172
+ - vendor/cache/diff-lcs-1.2.5.gem
173
+ - vendor/cache/docile-1.1.5.gem
174
+ - vendor/cache/dotenv-1.0.2.gem
175
+ - vendor/cache/ffi-1.9.6.gem
176
+ - vendor/cache/formatador-0.2.5.gem
177
+ - vendor/cache/guard-2.10.5.gem
178
+ - vendor/cache/guard-compat-1.2.0.gem
179
+ - vendor/cache/guard-rspec-4.5.0.gem
180
+ - vendor/cache/hitimes-1.2.2.gem
181
+ - vendor/cache/httmultiparty-0.3.16.gem
182
+ - vendor/cache/httparty-0.13.3.gem
183
+ - vendor/cache/json-1.8.1.gem
184
+ - vendor/cache/listen-2.8.4.gem
185
+ - vendor/cache/lumberjack-1.0.9.gem
186
+ - vendor/cache/method_source-0.8.2.gem
187
+ - vendor/cache/mimemagic-0.2.1.gem
188
+ - vendor/cache/multi_json-1.10.1.gem
189
+ - vendor/cache/multi_xml-0.5.5.gem
190
+ - vendor/cache/multipart-post-2.0.0.gem
191
+ - vendor/cache/nenv-0.1.1.gem
192
+ - vendor/cache/parser-2.2.0.pre.8.gem
193
+ - vendor/cache/powerpack-0.0.9.gem
194
+ - vendor/cache/pry-0.10.1.gem
195
+ - vendor/cache/pry-byebug-2.0.0.gem
196
+ - vendor/cache/rainbow-2.0.0.gem
197
+ - vendor/cache/rake-10.4.2.gem
198
+ - vendor/cache/rb-fsevent-0.9.4.gem
199
+ - vendor/cache/rb-inotify-0.9.5.gem
200
+ - vendor/cache/rspec-3.1.0.gem
201
+ - vendor/cache/rspec-core-3.1.7.gem
202
+ - vendor/cache/rspec-expectations-3.1.2.gem
203
+ - vendor/cache/rspec-mocks-3.1.3.gem
204
+ - vendor/cache/rspec-support-3.1.2.gem
205
+ - vendor/cache/rubocop-0.28.0.gem
206
+ - vendor/cache/ruby-progressbar-1.7.1.gem
207
+ - vendor/cache/simplecov-0.9.1.gem
208
+ - vendor/cache/simplecov-html-0.8.0.gem
209
+ - vendor/cache/slop-3.6.0.gem
210
+ - vendor/cache/thor-0.19.1.gem
211
+ - vendor/cache/timers-4.0.1.gem
212
+ homepage: https://github.com/just3ws/express_pigeon
213
+ licenses:
214
+ - MIT
215
+ metadata: {}
91
216
  post_install_message:
92
217
  rdoc_options: []
93
218
  require_paths:
94
219
  - lib
95
220
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
221
  requirements:
98
- - - ! '>='
222
+ - - ">="
99
223
  - !ruby/object:Gem::Version
100
- version: '0'
224
+ version: 2.1.0
101
225
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
226
  requirements:
104
- - - ! '>='
227
+ - - ">="
105
228
  - !ruby/object:Gem::Version
106
229
  version: '0'
107
230
  requirements: []
108
231
  rubyforge_project:
109
- rubygems_version: 1.8.24
232
+ rubygems_version: 2.4.5
110
233
  signing_key:
111
- specification_version: 3
112
- summary: API for interacting with ExpressPigeon service.
234
+ specification_version: 4
235
+ summary: ExpressPigeon API Ruby Wrapper
113
236
  test_files:
237
+ - spec/express_pigeon/api/campaigns_spec.rb
238
+ - spec/express_pigeon/api/contacts_spec.rb
239
+ - spec/express_pigeon/api/lists_spec.rb
240
+ - spec/express_pigeon/api/messages_spec.rb
241
+ - spec/express_pigeon/contacts_spec.rb
242
+ - spec/express_pigeon/lists_spec.rb
243
+ - spec/fixtures/contacts.csv
244
+ - spec/fixtures/contacts.csv.zip
114
245
  - spec/spec_helper.rb
115
- - spec/web_forms_spec.rb
data/.rvmrc DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p194-perf@express_pigeon"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.13.6 (master)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- if [[ $- == *i* ]] # check for interactive shells
29
- then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
30
- else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
31
- fi
32
- else
33
- # If the environment file has not yet been created, use the RVM CLI to select.
34
- rvm --create use "$environment_id" || {
35
- echo "Failed to create RVM environment '${environment_id}'."
36
- return 1
37
- }
38
- fi
39
-
40
- # If you use bundler, this might be useful to you:
41
- # if [[ -s Gemfile ]] && {
42
- # ! builtin command -v bundle >/dev/null ||
43
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
44
- # }
45
- # then
46
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
47
- # gem install bundler
48
- # fi
49
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
50
- # then
51
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
52
- # fi
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - ree
5
- script: bundle exec rspec spec
6
- before_install:
7
- - gem update --system
8
- - gem --version
data/CHANGELOG DELETED
@@ -1,6 +0,0 @@
1
- 1.0.2
2
-
3
- * Added support for date types and valid date strings to date of birth on
4
- web form.
5
- * Format the date as MM/DD/YYYY to the web form.
6
-
data/bin/console DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
- # encoding: utf-8
3
-
4
- $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
5
-
6
- require 'express_pigeon'
7
- require 'irb'
8
- require 'irb/completion'
9
-
10
- include ExpressPigeon
11
-
12
- IRB.start
@@ -1,10 +0,0 @@
1
- project_name: ep
2
- project_root: ~/projects/express_pigeon-rb
3
- socket_name: express_pigeon-rb
4
- rvm: ruby-1.9.3-perf@express_pigeon
5
- tabs:
6
- - editor:
7
- layout: main-vertical
8
- panes:
9
- - vim
10
- - clear; bundle exec rspec spec/
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'chronic'
4
-
5
- module ActiveModel
6
- module Validations
7
- class DateFormatValidator < ActiveModel::Validator
8
- def validate(record)
9
-
10
- return if [DateTime, Date, Time].include? record.date_of_birth.class
11
-
12
- return if record.date_of_birth.blank?
13
-
14
- unless Chronic.parse(record.date_of_birth)
15
- record.errors[:base] << (options[:message] || "is not a valid date format")
16
- end
17
- end
18
- end
19
- end
20
- end
data/script/lint DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- clear
4
-
5
- export RBXOPT="-X19 -Xrbc.db"
6
- rvm rbx@express_pigeon exec pelusa lib/*.rb
data/script/multispec DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- clear
4
-
5
- export RBXOPT="-X19 -Xrbc.db"
6
-
7
- echo; echo "---------"
8
- echo " ree"
9
- echo "---------"; echo
10
- rvm ree@express_pigeon exec bundle &> /dev/null
11
- rvm ree@express_pigeon exec bundle exec rspec spec/
12
-
13
- echo; echo "---------"
14
- echo " rbx"
15
- echo "---------"; echo
16
- rvm rbx@express_pigeon exec bundle &> /dev/null
17
- rvm rbx@express_pigeon exec bundle exec rspec spec/
18
-
19
- echo; echo "---------"
20
- echo " 1.9.3"
21
- echo "---------"; echo
22
- rvm 1.9.3@express_pigeon exec bundle &> /dev/null
23
- rvm 1.9.3@express_pigeon exec bundle exec rspec spec/
@@ -1,164 +0,0 @@
1
- require 'spec_helper'
2
- require 'express_pigeon'
3
-
4
- describe ExpressPigeon::WebForm do
5
-
6
- describe "Validations" do
7
- it { should_not be_valid }
8
- it { should validate_presence_of :email }
9
- it { should validate_presence_of :guid }
10
-
11
-
12
- describe "specific validations" do
13
- # TODO add the matchers to activemodel-rspec
14
- # that will make this section easier
15
- let(:form) do
16
- wf = ExpressPigeon::WebForm.new
17
-
18
- wf.guid = "51697971-48b4-45d3-ab80-3b23152999ed"
19
- wf.email = "valid@just3ws.com"
20
-
21
- wf.should be_valid
22
-
23
- wf
24
- end
25
-
26
- it "checks email field" do
27
- # minimum - valid
28
- form.email = "x@y"
29
- form.should be_valid
30
-
31
- # maximum - valid
32
- form.email = "#{'x'*48}@y"
33
- form.should be_valid
34
-
35
- # too long - invalid
36
- form.email = "is.too.long.#{'x'*50}@just3ws.com"
37
- form.should_not be_valid
38
- end
39
-
40
- it "only rejects non-date date of births" do
41
- form.date_of_birth = "this is invalid"
42
-
43
- form.should_not be_valid
44
- end
45
-
46
- it "accepts date of birth as MM/DD/YYYY" do
47
- form.date_of_birth = "05/30/2008"
48
- form.should be_valid
49
- form.date_of_birth.should == "05/30/2008"
50
- end
51
-
52
- it "accepts a date object as date of birth" do
53
- form.date_of_birth = Chronic.parse("2011-2-22")
54
- form.should be_valid
55
- form
56
- end
57
-
58
- it "accepts DateTime for date of birth" do
59
- form.date_of_birth = DateTime.now
60
- form.should be_valid
61
- end
62
-
63
- it "accepts Time for date of birth" do
64
- form.date_of_birth = Time.now
65
- form.should be_valid
66
- end
67
-
68
- it "accepts Date for date of birth" do
69
- form.date_of_birth = Date.today
70
- form.should be_valid
71
- end
72
-
73
-
74
- {"address1" => 255,
75
- "address2" => 255,
76
- "city" => 128,
77
- "company" => 128,
78
- "country" => 128,
79
- "first_name" => 50,
80
- "last_name" => 50,
81
- "phone" => 30,
82
- "state" => 48,
83
- "title" => 30,
84
- "zip" => 24}.each_pair do |name, length|
85
- it "checks #{name} max length" do
86
- # maximum - valid
87
- form.send("#{name}=".to_sym, "x"*length)
88
- form.should be_valid
89
-
90
- # too long invalid
91
- form.send("#{name}=".to_sym, "x"*(length+1))
92
- form.should_not be_valid
93
- end
94
- end
95
- end
96
- end
97
-
98
- describe "Pushing data to ExpressPigeon.com" do
99
- it { subject.save.should be_false }
100
- end
101
-
102
- describe "Dirty Tracking" do
103
- it { should_not be_changed }
104
-
105
- context "changed email" do
106
- before { subject.email = "foo@bar.com" }
107
-
108
- it { should be_changed }
109
- it { should be_email_changed }
110
- end
111
-
112
- it "resets changed after successfully saving" do
113
- wf = ExpressPigeon::WebForm.new
114
-
115
- wf.email = "doesnt@matter.com"
116
- wf.guid = "doesn't matter"
117
-
118
- wf.stub(:push_to_express_pigeon!).and_return(true)
119
-
120
- wf.save
121
-
122
- wf.should_not be_changed
123
- end
124
-
125
- it "remains changed when save fails" do
126
- wf = ExpressPigeon::WebForm.new
127
-
128
- wf.email = "doesnt@matter.com"
129
- wf.guid = "doesn't matter"
130
- wf.stub(:push_to_express_pigeon!).and_return(false)
131
-
132
- wf.save
133
-
134
- wf.should be_changed
135
- end
136
- end
137
-
138
- it "pushes to expresspigeon.com", :live => true do
139
- wf = ExpressPigeon::WebForm.new
140
-
141
- wf.guid = "51697971-48b4-45d3-ab80-3b23152999ed"
142
- wf.first_name = "Michael"
143
- wf.last_name = "Hall"
144
- wf.email = "mdh+rspec@just3ws.com"
145
- wf.address1 = "1 Way Street"
146
- wf.address1 = "Suite #0"
147
- wf.city = "Springfield"
148
- wf.state = "Illinois"
149
- wf.zip = "60606"
150
- wf.country = "United States"
151
- wf.date_of_birth = "1/1/1900"
152
- wf.phone = "888-555-1212"
153
- wf.title = "Emperor of Mankind"
154
- wf.company = "Imperium of Man"
155
-
156
- wf.save
157
-
158
- pending "Need to get the actual push to EP working first"
159
-
160
- wf.should be_changed
161
- end
162
-
163
-
164
- end