express_pigeon 1.0.1
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 +18 -0
- data/.rspec +2 -0
- data/.rvmrc +52 -0
- data/.travis.yml +8 -0
- data/Gemfile +18 -0
- data/LICENSE +22 -0
- data/README.md +124 -0
- data/Rakefile +2 -0
- data/bin/console +12 -0
- data/express_pigeon.gemspec +20 -0
- data/lib/express_pigeon/version.rb +3 -0
- data/lib/express_pigeon.rb +137 -0
- data/script/lint +6 -0
- data/script/multispec +23 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/web_forms_spec.rb +126 -0
- metadata +96 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,52 @@
|
|
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
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in expresspigeon.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development, :test do
|
7
|
+
gem 'awesome_print'
|
8
|
+
gem 'pry'
|
9
|
+
gem 'pry-nav'
|
10
|
+
|
11
|
+
gem 'wirble'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'rspec'
|
16
|
+
gem 'rspec-given'
|
17
|
+
gem 'activemodel-rspec', :git => "git://github.com/matthooks/activemodel-rspec.git"
|
18
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Michael D. Hall
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# ExpressPigeon
|
2
|
+
|
3
|
+
# ExpressPigeon [](http://travis-ci.org/just3ws/express_pigeon-rb) [](https://gemnasium.com/just3ws/express_pigeon-rb)
|
4
|
+
|
5
|
+
Library to interact with ExpressPigeon email service.
|
6
|
+
|
7
|
+
## Pre-requisites
|
8
|
+
|
9
|
+
1. Go to [Express Pigeon](http://expresspigeon.com)
|
10
|
+
2. Sign up for a free account
|
11
|
+
3. Create a Contact List
|
12
|
+
4. Create a Web Form for the contact list
|
13
|
+
5. Enable all the fields
|
14
|
+
6. Take note of the guid generated for the web form.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'express_pigeon'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install express_pigeon
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
TODO: Write usage instructions here
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
41
|
+
|
42
|
+
|
43
|
+
# Email Fields
|
44
|
+
|
45
|
+
+---------------+--------------+
|
46
|
+
| Field | Type |
|
47
|
+
+---------------+--------------+
|
48
|
+
| address1 | varchar(255) |
|
49
|
+
| address2 | varchar(255) |
|
50
|
+
| city | varchar(128) |
|
51
|
+
| company | varchar(128) |
|
52
|
+
| country | varchar(128) |
|
53
|
+
| date_of_birth | varchar(255) |
|
54
|
+
| email | varchar(50) | # likely upgraded to 100
|
55
|
+
| email_format | varchar(20) |
|
56
|
+
| first_name | varchar(50) |
|
57
|
+
| last_name | varchar(50) |
|
58
|
+
| phone | varchar(30) |
|
59
|
+
| state | varchar(48) |
|
60
|
+
| title | varchar(30) |
|
61
|
+
| zip | varchar(24) |
|
62
|
+
+---------------+--------------+
|
63
|
+
|
64
|
+
|
65
|
+
## Form Data
|
66
|
+
|
67
|
+
view-source:https://expresspigeon.com/subscription/form/51697971-48b4-45d3-ab80-3b23152999ed
|
68
|
+
|
69
|
+
- submits to
|
70
|
+
|
71
|
+
<form action="/subscription/add_contact" method="post" id="subscribe_form" class="form-add clearer"
|
72
|
+
|
73
|
+
- company name?
|
74
|
+
|
75
|
+
<title just3ws, llc - subscription</title
|
76
|
+
|
77
|
+
- Web form name
|
78
|
+
|
79
|
+
<h2 express_pigeon.rb</h2
|
80
|
+
|
81
|
+
- Web form title
|
82
|
+
|
83
|
+
<h2 Sign-up for our newsletters.</h2
|
84
|
+
|
85
|
+
- Subtitle
|
86
|
+
|
87
|
+
<h4 This is optional text for the form. You may use it to further entice your audience to subscribe</h4
|
88
|
+
|
89
|
+
- Form Fields
|
90
|
+
|
91
|
+
input type="hidden" name="guid" value="51697971-48b4-45d3-ab80-3b23152999ed"
|
92
|
+
|
93
|
+
input id="address1" name="address1"
|
94
|
+
input id="address2" name="address2"
|
95
|
+
input id="city" name="city"
|
96
|
+
input id="company" name="company"
|
97
|
+
input id="country" name="country"
|
98
|
+
input id="date_of_birth" name="date_of_birth"
|
99
|
+
input id="email" name="email"
|
100
|
+
input id="first_name" name="first_name"
|
101
|
+
input id="last_name" name="last_name"
|
102
|
+
input id="phone" name="phone"
|
103
|
+
input id="state" name="state"
|
104
|
+
input id="title" name="title"
|
105
|
+
input id="zip" name="zip"
|
106
|
+
|
107
|
+
label for="address1" Group Address 1
|
108
|
+
label for="address2" Group Address 2
|
109
|
+
label for="city" Group City
|
110
|
+
label for="company" Group Name
|
111
|
+
label for="country" Group Website
|
112
|
+
label for="date_of_birth" Group Twitter Name
|
113
|
+
label for="email" Your Email
|
114
|
+
label for="first_name" Your First Name
|
115
|
+
label for="last_name" Your Last Name
|
116
|
+
label for="phone" Group Management Site
|
117
|
+
label for="state" Group State
|
118
|
+
label for="title" Your Role In Group
|
119
|
+
label for="zip" Group Zip
|
120
|
+
|
121
|
+
|
122
|
+
- Submit simple form via cURL
|
123
|
+
|
124
|
+
curl -v -d "guid=51697971-48b4-45d3-ab80-3b23152999ed&email=mdh@just3ws.com"
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/express_pigeon/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Michael D. Hall"]
|
6
|
+
gem.email = ["mdh@just3ws.com"]
|
7
|
+
gem.description = %q{Light-weight wrapper around ExpressPigeon.}
|
8
|
+
gem.summary = %q{API for interacting with ExpressPigeon service.}
|
9
|
+
gem.homepage = "http://github.com/just3ws/express_pigeon-rb"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "express_pigeon"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = ExpressPigeon::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency("activemodel")
|
19
|
+
gem.add_runtime_dependency("curb-fu")
|
20
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require "express_pigeon/version"
|
2
|
+
require 'active_support'
|
3
|
+
require 'time'
|
4
|
+
require 'active_model'
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
module ExpressPigeon
|
8
|
+
class WebForm
|
9
|
+
include ActiveModel::Validations
|
10
|
+
include ActiveModel::Dirty
|
11
|
+
|
12
|
+
define_attribute_methods [
|
13
|
+
:address1,
|
14
|
+
:address2,
|
15
|
+
:city,
|
16
|
+
:company,
|
17
|
+
:country,
|
18
|
+
:date_of_birth,
|
19
|
+
:email,
|
20
|
+
:first_name,
|
21
|
+
:guid,
|
22
|
+
:last_name,
|
23
|
+
:phone,
|
24
|
+
:state,
|
25
|
+
:title,
|
26
|
+
:zip,
|
27
|
+
]
|
28
|
+
|
29
|
+
# TODO after submitting the form try to capture the response for errors?
|
30
|
+
|
31
|
+
validates :guid, :presence => true
|
32
|
+
validates :email, :presence => true, :length => 3..50, :allow_blank => false
|
33
|
+
|
34
|
+
# TODO check the actual form to see whether a field is required.
|
35
|
+
#
|
36
|
+
# The functionality to check whether a field is actually required
|
37
|
+
# hasn't been implemented yet. Go ahead and just assume they're not
|
38
|
+
# required and just check bounds.
|
39
|
+
validates :address1, :length => 0..255, :allow_blank => true
|
40
|
+
validates :address2, :length => 0..255, :allow_blank => true
|
41
|
+
validates :city, :length => 0..128, :allow_blank => true
|
42
|
+
validates :company, :length => 0..128, :allow_blank => true
|
43
|
+
validates :country, :length => 0..128, :allow_blank => true
|
44
|
+
|
45
|
+
# now sure why we can put 255 chars into date of birth but that's what it is.
|
46
|
+
# TODO validate and require date format, submit as MM/DD/YYYY
|
47
|
+
validates :date_of_birth, :length => 0..255, :allow_blank => true
|
48
|
+
|
49
|
+
# will email_form be a submittable field?
|
50
|
+
|
51
|
+
validates :first_name, :length => 0..50, :allow_blank => true
|
52
|
+
validates :last_name, :length => 0..50, :allow_blank => true
|
53
|
+
|
54
|
+
validates :phone, :length => 0..30, :allow_blank => true
|
55
|
+
|
56
|
+
# state is 48?
|
57
|
+
validates :state, :length => 0..48, :allow_blank => true
|
58
|
+
|
59
|
+
validates :title, :length => 0..30, :allow_blank => true
|
60
|
+
|
61
|
+
# zip is 24?
|
62
|
+
validates :zip, :length => 0..24, :allow_blank => true
|
63
|
+
|
64
|
+
|
65
|
+
# TODO validate date format MM/DD/YYYY
|
66
|
+
# TODO validate state
|
67
|
+
# TODO validate field sizes
|
68
|
+
|
69
|
+
def address1 ; @address1 ; end
|
70
|
+
def address2 ; @address2 ; end
|
71
|
+
def city ; @city ; end
|
72
|
+
def company ; @company ; end
|
73
|
+
def country ; @country ; end
|
74
|
+
def date_of_birth ; @date_of_birth ; end
|
75
|
+
def email ; @email ; end
|
76
|
+
def first_name ; @first_name ; end
|
77
|
+
def guid ; @guid ; end
|
78
|
+
def last_name ; @last_name ; end
|
79
|
+
def phone ; @phone ; end
|
80
|
+
def state ; @state ; end
|
81
|
+
def title ; @title ; end
|
82
|
+
def zip ; @zip ; end
|
83
|
+
|
84
|
+
def address1=(val) ; address1_will_change! unless val == @address1 ; @address1 = val ; end
|
85
|
+
def address2=(val) ; address2_will_change! unless val == @address2 ; @address2 = val ; end
|
86
|
+
def city=(val) ; city_will_change! unless val == @city ; @city = val ; end
|
87
|
+
def company=(val) ; company_will_change! unless val == @company ; @company = val ; end
|
88
|
+
def country=(val) ; country_will_change! unless val == @country ; @country = val ; end
|
89
|
+
def date_of_birth=(val) ; date_of_birth_will_change! unless val == @date_of_birth ; @date_of_birth = val ; end
|
90
|
+
def email=(val) ; email_will_change! unless val == @email ; @email = val ; end
|
91
|
+
def first_name=(val) ; first_name_will_change! unless val == @first_name ; @first_name = val ; end
|
92
|
+
def guid=(val) ; guid_will_change! unless val == @guid ; @guid = val ; end
|
93
|
+
def last_name=(val) ; last_name_will_change! unless val == @last_name ; @last_name = val ; end
|
94
|
+
def phone=(val) ; phone_will_change! unless val == @phone ; @phone = val ; end
|
95
|
+
def state=(val) ; state_will_change! unless val == @state ; @state = val ; end
|
96
|
+
def title=(val) ; title_will_change! unless val == @title ; @title = val ; end
|
97
|
+
def zip=(val) ; zip_will_change! unless val == @zip ; @zip = val ; end
|
98
|
+
|
99
|
+
def save
|
100
|
+
return false unless self.valid?
|
101
|
+
response = push_to_express_pigeon!
|
102
|
+
if response
|
103
|
+
@previously_changed = changes
|
104
|
+
@changed_attributes.clear
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def push_to_express_pigeon!
|
111
|
+
url = "https://expresspigeon.com/subscription/add_contact"
|
112
|
+
|
113
|
+
params = {
|
114
|
+
:address1 => self.address1,
|
115
|
+
:address2 => self.address2,
|
116
|
+
:city => self.city,
|
117
|
+
:company => self.company,
|
118
|
+
:country => self.country,
|
119
|
+
:date_of_birth => self.date_of_birth,
|
120
|
+
:email => self.email,
|
121
|
+
:first_name => self.first_name,
|
122
|
+
:guid => self.guid,
|
123
|
+
:last_name => self.last_name,
|
124
|
+
:phone => self.phone,
|
125
|
+
:state => self.state,
|
126
|
+
:title => self.title,
|
127
|
+
:zip => self.zip,
|
128
|
+
}
|
129
|
+
|
130
|
+
require 'curb-fu'
|
131
|
+
|
132
|
+
response = CurbFu.post({:url => url}, params)
|
133
|
+
|
134
|
+
response
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
data/script/lint
ADDED
data/script/multispec
ADDED
@@ -0,0 +1,23 @@
|
|
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/
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift '.'
|
10
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
|
11
|
+
require 'activemodel-rspec'
|
12
|
+
require 'rspec/given'
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.include ActiveModelMatchers
|
16
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
17
|
+
config.run_all_when_everything_filtered = true
|
18
|
+
config.filter_run :focus
|
19
|
+
config.filter_run_excluding :live => true
|
20
|
+
end
|
@@ -0,0 +1,126 @@
|
|
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
|
+
describe "specific validations" do
|
12
|
+
# TODO add the matchers to activemodel-rspec
|
13
|
+
# that will make this section easier
|
14
|
+
let(:form) do
|
15
|
+
f = ExpressPigeon::WebForm.new
|
16
|
+
f.guid = "51697971-48b4-45d3-ab80-3b23152999ed"
|
17
|
+
f.email = "valid@just3ws.com"
|
18
|
+
f.should be_valid
|
19
|
+
f
|
20
|
+
end
|
21
|
+
|
22
|
+
it "checks email field" do
|
23
|
+
# minimum - valid
|
24
|
+
form.email = "x@y"
|
25
|
+
form.should be_valid
|
26
|
+
|
27
|
+
# maximum - valid
|
28
|
+
form.email = "#{'x'*48}@y"
|
29
|
+
form.should be_valid
|
30
|
+
|
31
|
+
# too long - invalid
|
32
|
+
form.email = "is.too.long.#{'x'*50}@just3ws.com"
|
33
|
+
form.should_not be_valid
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
{"address1" => 255,
|
38
|
+
"address2" => 255,
|
39
|
+
"city" => 128,
|
40
|
+
"company" => 128,
|
41
|
+
"country" => 128,
|
42
|
+
"date_of_birth" => 255,
|
43
|
+
"first_name" => 50,
|
44
|
+
"last_name" => 50,
|
45
|
+
"phone" => 30,
|
46
|
+
"state" => 48,
|
47
|
+
"title" => 30,
|
48
|
+
"zip" => 24}.each_pair do |name, length|
|
49
|
+
it "checks #{name} max length" do
|
50
|
+
# maximum - valid
|
51
|
+
form.send("#{name}=".to_sym, "x"*length)
|
52
|
+
form.should be_valid
|
53
|
+
|
54
|
+
# too long invalid
|
55
|
+
form.send("#{name}=".to_sym, "x"*(length+1))
|
56
|
+
form.should_not be_valid
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "Pushing data to ExpressPigeon.com" do
|
63
|
+
it { subject.save.should be_false }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Dirty Tracking" do
|
67
|
+
it { should_not be_changed }
|
68
|
+
|
69
|
+
context "changed email" do
|
70
|
+
before { subject.email = "foo@bar.com" }
|
71
|
+
|
72
|
+
it { should be_changed }
|
73
|
+
it { should be_email_changed }
|
74
|
+
end
|
75
|
+
|
76
|
+
it "resets changed after successfully saving" do
|
77
|
+
wf = ExpressPigeon::WebForm.new
|
78
|
+
wf.email = "doesnt@matter.com"
|
79
|
+
wf.guid = "doesn't matter"
|
80
|
+
wf.stub(:push_to_express_pigeon!).and_return(true)
|
81
|
+
wf.save
|
82
|
+
wf.should_not be_changed
|
83
|
+
end
|
84
|
+
|
85
|
+
it "remains changed when save fails" do
|
86
|
+
wf = ExpressPigeon::WebForm.new
|
87
|
+
wf.email = "doesnt@matter.com"
|
88
|
+
wf.guid = "doesn't matter"
|
89
|
+
wf.stub(:push_to_express_pigeon!).and_return(false)
|
90
|
+
wf.save
|
91
|
+
wf.should be_changed
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "pushes to expresspigeon.com", :live => true do
|
96
|
+
wf = ExpressPigeon::WebForm.new
|
97
|
+
wf.guid = "51697971-48b4-45d3-ab80-3b23152999ed"
|
98
|
+
|
99
|
+
wf.first_name = "Michael"
|
100
|
+
wf.last_name = "Hall"
|
101
|
+
|
102
|
+
wf.email = "mdh+rspec@just3ws.com"
|
103
|
+
|
104
|
+
wf.address1 = "1 Way Street"
|
105
|
+
wf.address1 = "Suite #0"
|
106
|
+
|
107
|
+
wf.city = "Springfield"
|
108
|
+
wf.state = "Illinois"
|
109
|
+
wf.zip = "60606"
|
110
|
+
wf.country = "United States"
|
111
|
+
|
112
|
+
wf.date_of_birth = "1/1/1900"
|
113
|
+
|
114
|
+
wf.phone = "888-555-1212"
|
115
|
+
|
116
|
+
wf.title = "Emperor of Mankind"
|
117
|
+
wf.company = "Imperium of Man"
|
118
|
+
|
119
|
+
|
120
|
+
#wf.should_receive(:push_to_express_pigeon!)
|
121
|
+
|
122
|
+
wf.save
|
123
|
+
pending "need to get the actual push to EP working first"
|
124
|
+
wf.should be_changed
|
125
|
+
end
|
126
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: express_pigeon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael D. Hall
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: curb-fu
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Light-weight wrapper around ExpressPigeon.
|
47
|
+
email:
|
48
|
+
- mdh@just3ws.com
|
49
|
+
executables:
|
50
|
+
- console
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .rspec
|
56
|
+
- .rvmrc
|
57
|
+
- .travis.yml
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- bin/console
|
63
|
+
- express_pigeon.gemspec
|
64
|
+
- lib/express_pigeon.rb
|
65
|
+
- lib/express_pigeon/version.rb
|
66
|
+
- script/lint
|
67
|
+
- script/multispec
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spec/web_forms_spec.rb
|
70
|
+
homepage: http://github.com/just3ws/express_pigeon-rb
|
71
|
+
licenses: []
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.24
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: API for interacting with ExpressPigeon service.
|
94
|
+
test_files:
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
- spec/web_forms_spec.rb
|