mailinator 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8690ff90f8395b86a6d402890f6ceb30599162b
4
+ data.tar.gz: 89925d6ba70a94e5552ceb1ef91baaf8c5d7bd46
5
+ SHA512:
6
+ metadata.gz: c16c2c51dcb449ff93ae34744b0051673d4603137191f8a68faa8f00d6ab54c010c36bf35f735de656f7551b412cf523cbd5171d21a693f58bfa10895f2079e4
7
+ data.tar.gz: f2443a3b4861f8d147aeb9cd0be5acc2743c969e6023de6d9215467975aeba60ca95a5cdea5b53e883dd0646aede490c8799042eed9b2583a9a68fb4b3aaf206
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .ruby-version
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.1.1
7
+ - 2.1.2
8
+ - 2.1.3
9
+ - 2.1.4
10
+ - 2.1.5
11
+ - 2.2.0
12
+ bundler_args: --without debug
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mailinator.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rubocop', '~> 0.28'
8
+ gem 'rspec', '~> 3.1'
9
+ gem 'guard', '~> 2.10'
10
+ gem 'guard-rspec', '~> 4.5'
11
+ gem 'fakeweb', '~> 1.3'
12
+ end
13
+
14
+ group :debug do
15
+ gem 'pry', '~> 0.10'
16
+ gem 'pry-byebug', '~> 2.0'
17
+ end
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, cmd: 'bundle exec rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { 'spec' }
9
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alejandro Dev.
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.
@@ -0,0 +1,102 @@
1
+ [![Build Status](https://travis-ci.org/ainformatico/mailinator.svg)](https://travis-ci.org/ainformatico/mailinator)
2
+ [![Code Climate](https://codeclimate.com/github/ainformatico/mailinator/badges/gpa.svg)](https://codeclimate.com/github/ainformatico/mailinator)
3
+
4
+ # Mailinator
5
+
6
+ Mailinator REST API wrapper, http://mailinator.com/apidocs.jsp
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'mailinator'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install mailinator
23
+
24
+ ## Usage
25
+
26
+ ### Configuration
27
+
28
+ ```ruby
29
+ Mailinator.configure do |config|
30
+ config.token = 'YOURTOKEN'
31
+ end
32
+ ```
33
+
34
+ ### Email
35
+
36
+ Access to an email
37
+
38
+ ```ruby
39
+ email = Mailinator::Email.get('email-abcd1234')
40
+ ```
41
+
42
+ Now you have access to some methods:
43
+
44
+ * `email.id`
45
+ * `email.body`
46
+ * `email.body_html`
47
+ * `email.read?`
48
+ * `email.inbox_fetches_left`
49
+ * `email.email_fetches_left`
50
+ * `email.sender`
51
+ * `email.reply_to`
52
+ * `email.from`
53
+ * `email.ip`
54
+ * `email.received`
55
+ * `email.date`
56
+ * `email.time`
57
+ * `email.forwards_left`
58
+ * `email.original`, original request
59
+
60
+ ### Inbox
61
+
62
+ Access to an inbox
63
+
64
+ ```ruby
65
+ inbox = Mailinator::Inbox.get('inbox-abcd1234')
66
+ ```
67
+
68
+ This returns a list of the emails for the given _inbox_, but not the emails themselves.
69
+ To download an `Email` you need:
70
+
71
+ ```ruby
72
+ email = inbox.messages.first.download
73
+ ```
74
+
75
+ or
76
+
77
+ ```ruby
78
+ inbox.messages.first.download do |email|
79
+ [...]
80
+ end
81
+ ```
82
+
83
+ ## Contributing
84
+
85
+ 1. Fork it ( https://github.com/ainformatico/mailinator/fork )
86
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
87
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
88
+ 4. Push to the branch (`git push origin my-new-feature`)
89
+ 5. Create a new Pull Request
90
+
91
+
92
+ ## License
93
+
94
+ Copyright (c) 2014 Alejandro Dev.
95
+
96
+ MIT License
97
+
98
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
99
+
100
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
101
+
102
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.rspec_opts = ['--color', '--format', 'documentation']
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ require 'mailinator/model'
2
+ require 'mailinator/models/email'
3
+ require 'mailinator/models/entry'
4
+ require 'mailinator/models/inbox'
5
+ require 'mailinator/api'
6
+ require 'mailinator/email'
7
+ require 'mailinator/inbox'
8
+ require 'mailinator/config'
9
+ require 'mailinator/version'
10
+
11
+ module Mailinator
12
+ class << self
13
+ attr_writer :config
14
+
15
+ def configure
16
+ yield(config)
17
+ end
18
+
19
+ def config
20
+ @config ||= Config.new
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module Mailinator
5
+
6
+ class Api
7
+ class NotFound < StandardError; end
8
+ class RequestError < StandardError; end
9
+
10
+ def get(url, params = {})
11
+ response = request(url, params)
12
+ handle_response(response)
13
+ end
14
+
15
+ def token
16
+ Mailinator.config.token
17
+ end
18
+
19
+ private
20
+
21
+ def request(url, params)
22
+ uri = generate_url(url)
23
+ uri.query = generate_params(params)
24
+ perform_request(uri)
25
+ end
26
+
27
+ def perform_request(uri)
28
+ Net::HTTP.get_response(uri)
29
+ end
30
+
31
+ def generate_url(url)
32
+ URI("#{base_url}/#{url}")
33
+ end
34
+
35
+ def generate_params(params)
36
+ URI.encode_www_form(params.merge({token: token}))
37
+ end
38
+
39
+ def base_url
40
+ 'https://api.mailinator.com/api'
41
+ end
42
+
43
+ def handle_response(response)
44
+ case response.code.to_i
45
+ when 200
46
+ JSON.parse(response.body)
47
+ when 404
48
+ fail NotFound
49
+ else
50
+ fail RequestError, {status: response.message, code: response.code}
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,12 @@
1
+ module Mailinator
2
+ class TokenError < StandardError; end
3
+
4
+ class Config
5
+ attr_accessor :token
6
+
7
+ def token
8
+ fail TokenError, 'Please provide a token' if @token.nil?
9
+ @token
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module Mailinator
2
+ class Email
3
+ class << self
4
+ def get(id)
5
+ api = Api.new
6
+ data = api.get('email', msgid: id)
7
+ populate(data)
8
+ end
9
+
10
+ private
11
+
12
+ def populate(data)
13
+ Mailinator::Models::Email.new(data)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Mailinator
2
+ class Inbox
3
+ class << self
4
+ def get(to)
5
+ api = Api.new
6
+ data = api.get('inbox', to: to)
7
+ populate(data)
8
+ end
9
+
10
+ private
11
+
12
+ def populate(data)
13
+ Mailinator::Models::Inbox.new(data)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require 'hashie'
2
+
3
+ module Mailinator
4
+ module Models
5
+ class Base < Hashie::Mash
6
+ def initialize(data)
7
+ @data = data
8
+ super(transform_data)
9
+ end
10
+
11
+ def original
12
+ @data
13
+ end
14
+
15
+ def transform_data
16
+ @data
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'date'
2
+
3
+ module Mailinator
4
+ module Models
5
+ class Email < Base
6
+ def transform_data
7
+ {
8
+ id: @data['data']['id'],
9
+ body: @data['data']['parts'].first['body'],
10
+ body_html: @data['data']['parts'][1]['body'],
11
+ inbox_fetches_left: @data['apiInboxFetchesLeft'],
12
+ email_fetches_left: @data['apiEmailFetchesLeft'],
13
+ forwards_left: @data['forwardsLeft'],
14
+ sender: @data['data']['headers']['sender'],
15
+ from: @data['data']['from'],
16
+ date: DateTime.parse(@data['data']['headers']['date']),
17
+ time: @data['data']['time'],
18
+ ip: @data['data']['ip'],
19
+ to: @data['data']['headers']['to'],
20
+ reply_to: @data['data']['headers']['reply-to'],
21
+ received: @data['data']['headers']['received'],
22
+ read?: @data['data']['been_read']
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ module Mailinator
2
+ module Models
3
+ class Entry < Base
4
+ def download
5
+ email = Mailinator::Email.get(id)
6
+ if block_given?
7
+ yield email
8
+ else
9
+ email
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Mailinator
2
+ module Models
3
+ class Inbox < Base
4
+ def transform_data
5
+ {
6
+ messages: @data['messages'].map { |entry| Entry.new(entry) }
7
+ }
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Mailinator
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mailinator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'mailinator'
8
+ spec.version = Mailinator::VERSION
9
+ spec.authors = ['Alejandro Dev.']
10
+ spec.email = ['aeinformatico@gmail.com']
11
+ spec.summary = %q{Mailinator REST API wrapper}
12
+ spec.homepage = 'https://github.com/ainformatico/mailinator'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'hashie', '~> 3.3'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.6'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
@@ -0,0 +1,5 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache-Coyote/1.1
3
+ Date: Sun, 28 Dec 2014 13:39:51 GMT
4
+
5
+ {"apiInboxFetchesLeft":696,"apiEmailFetchesLeft":10,"data":{"headers":{"sender":"example@example.net","content-type":"multipart\/alternative;\r\n\tboundary=\"MIMEBoundaryec1dc8828d9bbedf095f9e9d2ebdbdeb\"","to":"recipient@mailinator.com","x-connecting-ip":"127.0.0.1","subject":"This is a subject","mime-version":"1.0","x-received-time":"1419696967076","reply-to":"example@example.net","received":"from 127-0-0-1.dynamic-ip.example.net ()\r\n by mail.mailinator.com with SMTP (Postfix)\r\n for recipient@mailinator.com;\r\n Sat, 27 Dec 2014 16:16:07 +0000 (UTC)","from":"\"Sender\" <example@example.net>","date":"Sun, 28 Dec 2014 00:16:00 +0800"},"seconds_ago":77024,"id":"1419696967-44152505-recipient","to":"recipient@mailinator.com","time":1419696967076,"subject":"This is a subject","fromfull":"example@example.net","parts":[{"headers":{"content-type":"text\/plain;\r\n\tcharset=\"iso-8859-1\"","content-transfer-encoding":"quoted-printable"},"body":"This is a body"},{"headers":{"content-type":"text\/html;\r\n\tcharset=\"iso-8859-1\"","content-transfer-encoding":"quoted-printable"},"body":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\r\n\r\n<head>\r\n<meta content=\"en-us\" http-equiv=\"Content-Language\" \/>\r\n<meta content=\"text\/html; charset=utf-8\" http-equiv=\"Content-Type\" \/>\r\n<title>Alert<\/title>\r\n<\/head>\r\n\r\n<body><p>This is a body<\/p><\/body>\r\n\r\n<\/html>"}],"been_read":false,"from":"Sender","ip":"127.0.0.1"},"forwardsLeft":10}
@@ -0,0 +1,6 @@
1
+ HTTP/1.1 500 server error
2
+ Server: Apache-Coyote/1.1
3
+ Content-Type: text/html;charset=utf-8
4
+ Content-Language: en
5
+ Content-Length: 975
6
+ Date: Sun, 28 Dec 2014 15:59:50 GMT
@@ -0,0 +1,5 @@
1
+ HTTP/1.1 200 OK
2
+ Server: Apache-Coyote/1.1
3
+ Date: Sun, 28 Dec 2014 16:26:18 GMT
4
+
5
+ {"messages":[{"seconds_ago":87011,"id":"1419696967-44152505-recipient","to":"recipient@mailinator.com","time":1419696967076,"subject":"First subject","fromfull":"sender@example.org","been_read":false,"from":"Sender name","ip":"127.0.0.1"},{"seconds_ago":73130,"id":"1419710848-46252175-recipient","to":"recipient@mailinator.com","time":1419710848789,"subject":"Second subject","fromfull":"sender@example.org","been_read":false,"from":"Another sender name","ip":"127.0.0.2"}]}
@@ -0,0 +1,6 @@
1
+ HTTP/1.1 404 msg not found
2
+ Server: Apache-Coyote/1.1
3
+ Content-Type: text/html;charset=utf-8
4
+ Content-Language: en
5
+ Content-Length: 975
6
+ Date: Sun, 28 Dec 2014 15:59:50 GMT
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator::Api do
4
+ let(:token) { 'ABCD' }
5
+
6
+ before do
7
+ Mailinator.configure do |config|
8
+ config.token = token
9
+ end
10
+ end
11
+
12
+ it 'should raise when document not found' do
13
+ api = Mailinator::Api.new
14
+ expect { api.get('not-found') }.to raise_error(Mailinator::Api::NotFound)
15
+ end
16
+
17
+ it 'should raise when an error occurred' do
18
+ api = Mailinator::Api.new
19
+ expect { api.get('error') }.to raise_error(Mailinator::Api::RequestError)
20
+ end
21
+
22
+ it 'should GET' do
23
+ api = Mailinator::Api.new
24
+ params = {custom: :custom, token: token}
25
+ url = 'url'
26
+ uri = URI("#{api.send(:base_url)}/#{url}")
27
+ uri.query = URI.encode_www_form(params.merge(params))
28
+ response = double(:response, {code: '200', body: {id: 1}.to_json})
29
+
30
+ expect(api)
31
+ .to receive(:get)
32
+ .with(url, params)
33
+ .and_call_original
34
+
35
+ expect(Net::HTTP)
36
+ .to receive(:get_response)
37
+ .with(uri) { response }
38
+
39
+ api.get(url, params)
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator::Config do
4
+ it 'should assign the token propery' do
5
+ token = 'ABCD'
6
+ config = subject
7
+ config.token = token
8
+ expect(config.token).to eq(token)
9
+ end
10
+
11
+ it 'should raise an error if no token specified' do
12
+ expect { subject.token }.to raise_error(Mailinator::TokenError)
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator::Email do
4
+ before do
5
+ Mailinator.configure do |config|
6
+ config.token = 'ABCD'
7
+ end
8
+ end
9
+
10
+ it 'should get an email' do
11
+ body = 'This is a body'
12
+ message = Mailinator::Email.get('abcd1234')
13
+ expect(message.id).to eq('1419696967-44152505-recipient')
14
+ expect(message.body).to eq(body)
15
+ expect(message.body_html).to include("<p>#{body}</p>")
16
+ expect(message.read?).to_not be
17
+ expect(message.inbox_fetches_left).to eq(696)
18
+ expect(message.email_fetches_left).to eq(10)
19
+ expect(message.sender).to eq('example@example.net')
20
+ expect(message.reply_to).to eq('example@example.net')
21
+ expect(message.from).to eq('Sender')
22
+ expect(message.ip).to eq('127.0.0.1')
23
+ expect(message.received).to match(a_string_matching('from 127-0-0-1.dynamic-ip.example.net'))
24
+ expect(message.date).to be_a(DateTime)
25
+ expect(message.time).to eq(1419696967076)
26
+ expect(message.forwards_left).to eq(10)
27
+ expect(message.original).to be_a(Hash)
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator::Inbox do
4
+ let(:inbox) { Mailinator::Inbox.get('abcd1234') }
5
+
6
+ before do
7
+ Mailinator.configure do |config|
8
+ config.token = 'ABCD'
9
+ end
10
+ end
11
+
12
+ it 'should get an inbox' do
13
+ expect(inbox.messages).to be_a(Array)
14
+ expect(inbox.original).to be_a(Hash)
15
+ expect(inbox.messages.first).to include(id: '1419696967-44152505-recipient')
16
+ expect(inbox.messages.last).to include(id: '1419710848-46252175-recipient')
17
+ end
18
+
19
+ it 'should #download an email' do
20
+ expect(inbox.messages.first.download).to be_a(Mailinator::Models::Email)
21
+ expect(inbox.messages.first.download).to eq(Mailinator::Email.get(inbox.messages.first.id))
22
+ inbox.messages.first.download do |message|
23
+ expect(message).to eq(Mailinator::Email.get(inbox.messages.first.id))
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator::Models::Base do
4
+
5
+ let(:data) { {custom: :custom} }
6
+
7
+ it 'should #transform_data with defaults' do
8
+ class CustomModel < Mailinator::Models::Base; end
9
+
10
+ klass = CustomModel.new(data)
11
+
12
+ expect(klass).to be_a(Mailinator::Models::Base)
13
+ expect(klass.custom).to eq(data[:custom])
14
+ expect(klass.original).to eq(data)
15
+ end
16
+
17
+ it 'should #transform_data' do
18
+ class CustomModel < Mailinator::Models::Base
19
+ def transform_data
20
+ {
21
+ custom: @data[:custom]
22
+ }
23
+ end
24
+ end
25
+
26
+ klass = CustomModel.new(data)
27
+
28
+ expect(klass).to be_a(Mailinator::Models::Base)
29
+ expect(klass.custom).to eq(data[:custom])
30
+ expect(klass.original).to eq(data)
31
+ end
32
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mailinator do
4
+ describe 'configuration' do
5
+ let(:token) { 'ABCD' }
6
+
7
+ it 'should configure the token' do
8
+ Mailinator.configure do |config|
9
+ config.token = token
10
+ end
11
+
12
+ expect(Mailinator.config.token).to eq token
13
+ end
14
+
15
+ it 'should configure the token, short version' do
16
+ Mailinator.config.token = token
17
+ expect(Mailinator.config.token).to eq token
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'mailinator'
2
+
3
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ config.color = true
7
+ config.filter_run focus: true
8
+ config.run_all_when_everything_filtered = true
9
+ end
@@ -0,0 +1,28 @@
1
+ require 'fakeweb'
2
+
3
+ FakeWeb.allow_net_connect = false
4
+
5
+ def fixture_file(filename)
6
+ return '' if filename == ''
7
+
8
+ file_path = File.join(File.expand_path(File.dirname(__FILE__)), '../', 'fixtures/', filename)
9
+ File.read(file_path)
10
+ end
11
+
12
+ def register_uri(url, file, method = :get)
13
+ FakeWeb.register_uri(method, url, response: fixture_file(file))
14
+ end
15
+
16
+ register_uri('https://api.mailinator.com/api/inbox?to=abcd1234&token=ABCD', 'inbox.response')
17
+ register_uri('https://api.mailinator.com/api/email?msgid=abcd1234&token=ABCD', 'email.response')
18
+ register_uri('https://api.mailinator.com/api/email?msgid=1419696967-44152505-recipient&token=ABCD', 'email.response')
19
+ register_uri('https://api.mailinator.com/api/not-found?token=ABCD', 'not-found.response')
20
+ register_uri('https://api.mailinator.com/api/error?token=ABCD', 'error.response')
21
+
22
+ # NOTE: fix for travis ruby 1.9.3
23
+ # it replaces https:// to http://:443
24
+ register_uri('http://api.mailinator.com:443/api/inbox?to=abcd1234&token=ABCD', 'inbox.response')
25
+ register_uri('http://api.mailinator.com:443/api/email?msgid=abcd1234&token=ABCD', 'email.response')
26
+ register_uri('http://api.mailinator.com:443/api/email?msgid=1419696967-44152505-recipient&token=ABCD', 'email.response')
27
+ register_uri('http://api.mailinator.com:443/api/not-found?token=ABCD', 'not-found.response')
28
+ register_uri('http://api.mailinator.com:443/api/error?token=ABCD', 'error.response')
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mailinator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alejandro Dev.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - aeinformatico@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - Guardfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/mailinator.rb
70
+ - lib/mailinator/api.rb
71
+ - lib/mailinator/config.rb
72
+ - lib/mailinator/email.rb
73
+ - lib/mailinator/inbox.rb
74
+ - lib/mailinator/model.rb
75
+ - lib/mailinator/models/email.rb
76
+ - lib/mailinator/models/entry.rb
77
+ - lib/mailinator/models/inbox.rb
78
+ - lib/mailinator/version.rb
79
+ - mailinator.gemspec
80
+ - spec/fixtures/email.response
81
+ - spec/fixtures/error.response
82
+ - spec/fixtures/inbox.response
83
+ - spec/fixtures/not-found.response
84
+ - spec/lib/mailinator/api_spec.rb
85
+ - spec/lib/mailinator/config_spec.rb
86
+ - spec/lib/mailinator/email_spec.rb
87
+ - spec/lib/mailinator/inbox_spec.rb
88
+ - spec/lib/mailinator/model_spec.rb
89
+ - spec/mailinator_spec.rb
90
+ - spec/spec_helper.rb
91
+ - spec/support/fake_web.rb
92
+ homepage: https://github.com/ainformatico/mailinator
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Mailinator REST API wrapper
116
+ test_files:
117
+ - spec/fixtures/email.response
118
+ - spec/fixtures/error.response
119
+ - spec/fixtures/inbox.response
120
+ - spec/fixtures/not-found.response
121
+ - spec/lib/mailinator/api_spec.rb
122
+ - spec/lib/mailinator/config_spec.rb
123
+ - spec/lib/mailinator/email_spec.rb
124
+ - spec/lib/mailinator/inbox_spec.rb
125
+ - spec/lib/mailinator/model_spec.rb
126
+ - spec/mailinator_spec.rb
127
+ - spec/spec_helper.rb
128
+ - spec/support/fake_web.rb