mandrill 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,47 @@
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
+ environment_id="ruby-1.9.3-p125@mandrill"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+
14
+ #
15
+ # First we attempt to load the desired environment directly from the environment
16
+ # file. This is very fast and efficient compared to running through the entire
17
+ # CLI and selector. If you want feedback on which environment was used then
18
+ # insert the word 'use' after --create as this triggers verbose mode.
19
+ #
20
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
21
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
22
+ then
23
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
24
+
25
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
26
+ then
27
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
28
+ fi
29
+ else
30
+ # If the environment file has not yet been created, use the RVM CLI to select.
31
+ if ! rvm --create "$environment_id"
32
+ then
33
+ echo "Failed to create RVM environment '${environment_id}'."
34
+ exit 1
35
+ fi
36
+ fi
37
+
38
+ #
39
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
40
+ # it be automatically loaded. Uncomment the following and adjust the filename if
41
+ # necessary.
42
+ #
43
+ # filename=".gems"
44
+ # if [[ -s "$filename" ]] ; then
45
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
46
+ # fi
47
+
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "httpi"
4
+ gem "json"
5
+
6
+ group :development do
7
+ gem "bundler", ">= 1.0.0"
8
+ gem "fakeweb", ">= 1.3.0"
9
+ gem 'guard-rspec', ">= 0.7.0"
10
+ gem "jeweler", ">= 1.8.3"
11
+ gem "simplecov", ">= 0.6.1"
12
+ gem "rspec", ">= 2.8.0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ fakeweb (1.3.0)
6
+ ffi (1.0.11)
7
+ git (1.2.5)
8
+ guard (1.0.1)
9
+ ffi (>= 0.5.0)
10
+ thor (~> 0.14.6)
11
+ guard-rspec (0.7.0)
12
+ guard (>= 0.10.0)
13
+ httpi (0.9.6)
14
+ rack
15
+ jeweler (1.8.3)
16
+ bundler (~> 1.0)
17
+ git (>= 1.2.5)
18
+ rake
19
+ rdoc
20
+ json (1.6.5)
21
+ multi_json (1.1.0)
22
+ rack (1.4.1)
23
+ rake (0.9.2.2)
24
+ rdoc (3.12)
25
+ json (~> 1.4)
26
+ rspec (2.9.0)
27
+ rspec-core (~> 2.9.0)
28
+ rspec-expectations (~> 2.9.0)
29
+ rspec-mocks (~> 2.9.0)
30
+ rspec-core (2.9.0)
31
+ rspec-expectations (2.9.0)
32
+ diff-lcs (~> 1.1.3)
33
+ rspec-mocks (2.9.0)
34
+ simplecov (0.6.1)
35
+ multi_json (~> 1.0)
36
+ simplecov-html (~> 0.5.3)
37
+ simplecov-html (0.5.3)
38
+ thor (0.14.6)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (>= 1.0.0)
45
+ fakeweb (>= 1.3.0)
46
+ guard-rspec (>= 0.7.0)
47
+ httpi
48
+ jeweler (>= 1.8.3)
49
+ json
50
+ rspec (>= 2.8.0)
51
+ simplecov (>= 0.6.1)
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+ # Capybara request specs
17
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
18
+ end
19
+
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Brian Getting
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,72 @@
1
+ = Mandrill {<img src="http://travis-ci.org/terra-firma/mandrill.png" />}[http://travis-ci.org/terra-firma/mandrill] {<img src="https://gemnasium.com/terra-firma/mandrill.png" alt="Dependency Status" />}[https://gemnasium.com/terra-firma/mandrill]
2
+
3
+ Mandrill is a Ruby gem that provides a wrapper for interacting with the {Mandrill API}[http://mandrillapp.com/api/docs/index.html]. Remember that {Mandrill}[http://mandrillapp.com] has an excellent {SMTP Headers API}[http://help.mandrill.com/customer/portal/articles/456744-smtp-headers-api], which is often a better integration option, particularly if your app sends emails.
4
+
5
+ == Installation
6
+
7
+ (sudo) gem install mandrill
8
+
9
+ == Usage
10
+
11
+ To start with, you will need a {Mandrill account}[http://help.mandrill.com/customer/portal/articles/456476-setup-and-general-information] as a developer so that you can register your app. People that want to use your application will also need to a {create a Mandrill account}[http://help.mandrill.com/customer/portal/articles/456476-setup-and-general-information] (obviously) as well.
12
+
13
+ === Register Your App
14
+
15
+ {Login to your Mandrill account}[https://mandrillapp.com] and click "{register a new app}[https://mandrillapp.com/app/register]" on the "Settings > Applications" page. Once your app is registered, you will get an "App Authentication ID", which we refer to in this document at the "App ID". You're now ready to get started.
16
+
17
+ === Connect Your App
18
+
19
+ The first thing you will need to do is prompt your users to authorize the connection between your application and {Mandrill}[https://mandrillapp.com]. Once they are logged in, simply redirect them:
20
+
21
+ redirect_to Mandrill.authorization_url("your_app_id", "https://yourapp.com/mandrill/callback")
22
+
23
+ Once authorized successfully, a POST request will be sent to the +redirect_url+ with a "key" parameter containing the API key for that user's {Mandrill}[https://mandrillapp.com] account. Be sure to store this key somewhere, as you will need it to run API requests later. If authorization fails for some reason, an "error" parameter will be present in the POST request, containing an error message.
24
+
25
+ def callback
26
+ # POST /mandrill/callback
27
+ if params[:key]
28
+ current_user.mandrill_key = params[:key]
29
+ current_user.save
30
+ ...
31
+ elsif params[:error]
32
+ flash[:alert] = params[:error]
33
+ ...
34
+ end
35
+ end
36
+
37
+ As you can see, we are saving the key that Mandrill returns for the currently logged in user, and we have successfully connected this user account to Mandrill.
38
+
39
+
40
+ === Interacting with the API
41
+
42
+ Once you have a valid API key (your own {account password}[https://mandrillapp.com/settings] works) you can easily interact with the {Mandrill API}[http://mandrillapp.com/api/docs/index.html] by passing in a hash:
43
+
44
+ m = Mandrill::API.new('api-key')
45
+ m.users :ping
46
+ m.users :senders
47
+ # Methods with dashes shouldn't be passed in as symbols
48
+ m.users 'disable-sender', {:domain => "exampledomain.com"}
49
+ m.users 'verify-sender', {:email => 'test@exampledomain.com'}
50
+ m.messages :send {:message => {:html => "HTML message text", :text => "message text"}...}
51
+
52
+ === Errors
53
+
54
+ When an error is received an instance of <code>Mandrill::API::Error</code> will be returned so that you can rescue accordingly:
55
+
56
+ rescue Mandrill::API::Error > error
57
+ ...
58
+
59
+ == Contributing to Mandrill
60
+
61
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
62
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
63
+ * Fork the project.
64
+ * Start a feature/bugfix branch.
65
+ * Commit and push until you are happy with your contribution.
66
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
67
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
68
+
69
+ == Copyright
70
+
71
+ Copyright (c) 2011 Terra Firma Design & Consulting. See LICENSE.txt for further details.
72
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "mandrill"
18
+ gem.homepage = "http://github.com/terra-firma/mandrill"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby gem for interacting with the Mandrill API.}
21
+ gem.description = %Q{Ruby gem for interacting with the Mandrill API.}
22
+ gem.email = "brian@terra-firma-design.com"
23
+ gem.authors = ["Brian Getting"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "mandrill #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/lib/mandrill.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'httpi'
3
+ require 'json'
4
+
5
+ require 'mandrill/api'
@@ -0,0 +1,80 @@
1
+ module Mandrill
2
+ class API
3
+ # Blank Slate
4
+ instance_methods.each do |m|
5
+ undef_method m unless m.to_s =~ /^__|object_id|method_missing|respond_to?|to_s|inspect|kind_of?|should|should_not/
6
+ end
7
+
8
+ # Mandrill API Documentation: http://mandrillapp.com/api/docs
9
+ API_VERSION = "1.0"
10
+ API_URL = "https://mandrillapp.com/api"
11
+ AUTH_URL = "https://mandrillapp.com/api-auth/"
12
+
13
+ # Generate a Mandrill +authorization_url+.
14
+ # Returns a URL to redirect users to so that they will be prompted
15
+ # to enter their Mandrill username and password to authorize a
16
+ # connection between your application and their Mandrill account.
17
+ #
18
+ # If authorized successfully, a POST request will be sent to the
19
+ # +redirect_url+ with a "key" parameter containing the API key for
20
+ # that user's Mandrill account. Be sure to store this key somewhere,
21
+ # as you will need it to run API requests later.
22
+ #
23
+ # If authorization fails for some reason, an "error" parameter will
24
+ # be present in the POST request, containing an error message.
25
+ #
26
+ # == Example
27
+ #
28
+ # redirect_to Mandrill::API.authorization_url("12345","https://example.com/callback")
29
+ #
30
+ def self.authorization_url(app_id, redirect_url)
31
+ "#{AUTH_URL}?id=#{app_id}&redirect_url=#{URI.escape(redirect_url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"
32
+ end
33
+
34
+ # Initialize
35
+ def initialize(api_key, config = {})
36
+ defaults = {
37
+ :api_version => API_VERSION,
38
+ :format => 'json'
39
+ }
40
+ @config = defaults.merge(config).freeze
41
+ @api_key = api_key
42
+ end
43
+
44
+ # Dynamically find API methods
45
+ def method_missing(api_method, *args) # :nodoc:
46
+ call(api_method, *args)
47
+ if @response.code.to_i == 200
48
+ return "PONG!" if @response.body == "\"PONG!\""
49
+ @config[:format] == 'json' ? JSON.parse(@response.body) : @response.body
50
+ else
51
+ raise(API::Error.new(JSON.parse(@response.body)["code"], JSON.parse(@response.body)["message"]))
52
+ end
53
+ end
54
+
55
+ # Check the API to see if a method is supported
56
+ def respond_to?(api_method, *args) # :nodoc:
57
+ call(api_method, *args)
58
+ @response.code == 500 ? false : true
59
+ end
60
+
61
+ # Display the supported methods
62
+ def public_methods # :nodoc:
63
+ [:messages, :senders, :tags, :templates, :urls, :users]
64
+ end
65
+
66
+ # Call the API
67
+ def call(api_method, *args)
68
+ req_endpoint = "#{API_URL}/#{@config[:api_version]}/#{api_method.to_s}/#{args.first.to_s}.#{@config[:format]}"
69
+ req_body = {:key => @api_key}
70
+ req_body.merge!(args.last) if args.last.is_a?(Hash)
71
+ @response = HTTPI.post(req_endpoint, req_body)
72
+ end
73
+
74
+ class Error < StandardError
75
+ def initialize(code, message)
76
+ super "(#{code}) #{message}"
77
+ end
78
+ end
79
+ end
80
+ end
data/mandrill.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "mandrill"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Brian Getting"]
12
+ s.date = "2012-04-03"
13
+ s.description = "Ruby gem for interacting with the Mandrill API."
14
+ s.email = "brian@terra-firma-design.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "Guardfile",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/mandrill.rb",
31
+ "lib/mandrill/api.rb",
32
+ "mandrill.gemspec",
33
+ "spec/mandrill/fixtures/error.json",
34
+ "spec/mandrill/mandrill_spec.rb",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = "http://github.com/terra-firma/mandrill"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.10"
41
+ s.summary = "Ruby gem for interacting with the Mandrill API."
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<httpi>, [">= 0"])
48
+ s.add_runtime_dependency(%q<json>, [">= 0"])
49
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
50
+ s.add_development_dependency(%q<fakeweb>, [">= 1.3.0"])
51
+ s.add_development_dependency(%q<guard-rspec>, [">= 0.7.0"])
52
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.3"])
53
+ s.add_development_dependency(%q<simplecov>, [">= 0.6.1"])
54
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
55
+ else
56
+ s.add_dependency(%q<httpi>, [">= 0"])
57
+ s.add_dependency(%q<json>, [">= 0"])
58
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
59
+ s.add_dependency(%q<fakeweb>, [">= 1.3.0"])
60
+ s.add_dependency(%q<guard-rspec>, [">= 0.7.0"])
61
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
62
+ s.add_dependency(%q<simplecov>, [">= 0.6.1"])
63
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<httpi>, [">= 0"])
67
+ s.add_dependency(%q<json>, [">= 0"])
68
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
69
+ s.add_dependency(%q<fakeweb>, [">= 1.3.0"])
70
+ s.add_dependency(%q<guard-rspec>, [">= 0.7.0"])
71
+ s.add_dependency(%q<jeweler>, [">= 1.8.3"])
72
+ s.add_dependency(%q<simplecov>, [">= 0.6.1"])
73
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
74
+ end
75
+ end
76
+
@@ -0,0 +1,4 @@
1
+ {
2
+ "code":-1,
3
+ "message":"You must specify a tag value"
4
+ }
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ module Mandrill
4
+
5
+ describe "authorization_url" do
6
+ it "should require an app_id and redirect_url" do
7
+ expect {Mandrill::API.authorization_url}.should raise_error(ArgumentError)
8
+ expect {Mandrill::API.authorization_url(@app_id)}.should raise_error(ArgumentError)
9
+ expect {Mandrill::API.authorization_url(@app_id, @callback_url)}.should_not raise_error(ArgumentError)
10
+ end
11
+
12
+ it "should generate an authorization URL" do
13
+ @callback_url = 'https://test.com/callback'
14
+ url = Mandrill::API.authorization_url(@app_id, @callback_url)
15
+ url.should eq("#{Mandrill::API::AUTH_URL}?id=#{@app_id}&redirect_url=#{URI.escape(@callback_url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}")
16
+ end
17
+ end
18
+
19
+ describe API do
20
+ API_URL = "#{Mandrill::API::API_URL}/#{Mandrill::API::API_VERSION}"
21
+
22
+ describe "initializing" do
23
+ it "requires an API key" do
24
+ expect {Mandrill::API.new}.should raise_error(ArgumentError)
25
+ end
26
+
27
+ it "also accepts config options" do
28
+ expect {Mandrill::API.new(@api_key, {:format => 'xml'})}.should_not raise_error(ArgumentError)
29
+ end
30
+ end
31
+
32
+ describe "calling the API" do
33
+ before(:each) do
34
+ @m = Mandrill::API.new(@api_key)
35
+ end
36
+
37
+ it "should call the correct API method" do
38
+ FakeWeb.register_uri(:post, "#{API_URL}/users/info.json", :body => '{"username": "example"}')
39
+ @m.users(:info)['username'].should eq('example')
40
+ end
41
+
42
+ describe "and getting a response" do
43
+ before(:each) do
44
+ FakeWeb.register_uri(:post, "#{API_URL}/users/ping.json", :body => "\"PONG!\"")
45
+ end
46
+
47
+ it "should return 'PONG!' when pinging successfully" do
48
+ @m.users(:ping).should eq("PONG!")
49
+ end
50
+
51
+ it "should respond_to? correctly" do
52
+ FakeWeb.register_uri(:post, "#{API_URL}/users/nomethod.json", :status => [500, "Internal Server Eror"])
53
+ @m.respond_to?('users', :ping).should eq(true)
54
+ @m.respond_to?('users', :nomethod).should eq(false)
55
+ end
56
+
57
+ it "should raise a Mandrill::API error when needed" do
58
+ FakeWeb.register_uri(:post, "#{API_URL}/tags/info.json", :status => [500, "Internal Server Eror"], :body => @error)
59
+ expect {@m.tags(:info)}.should raise_error(Mandrill::API::Error)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,19 @@
1
+ require 'rspec'
2
+ require 'fakeweb'
3
+ require 'mandrill'
4
+
5
+ # Requires supporting files with custom matchers and macros, etc,
6
+ # in ./support/ and its subdirectories.
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+
9
+ FakeWeb.allow_net_connect = false
10
+
11
+ RSpec.configure do |config|
12
+ config.before(:each) do
13
+ FakeWeb.clean_registry
14
+ @app_id = 'valid-app-id'
15
+ @api_key = 'valid-api-key'
16
+ @callback_url = 'https://example.com/callback'
17
+ @error = File.read(File.expand_path('spec/mandrill/fixtures/error.json'))
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mandrill
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian Getting
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httpi
16
+ requirement: &70196095853900 !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: *70196095853900
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &70196095852700 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70196095852700
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70196095813360 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70196095813360
47
+ - !ruby/object:Gem::Dependency
48
+ name: fakeweb
49
+ requirement: &70196095812240 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70196095812240
58
+ - !ruby/object:Gem::Dependency
59
+ name: guard-rspec
60
+ requirement: &70196095811240 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 0.7.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70196095811240
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &70196095808820 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.3
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70196095808820
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov
82
+ requirement: &70196095807680 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 0.6.1
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70196095807680
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &70196095806640 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 2.8.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70196095806640
102
+ description: Ruby gem for interacting with the Mandrill API.
103
+ email: brian@terra-firma-design.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files:
107
+ - LICENSE.txt
108
+ - README.rdoc
109
+ files:
110
+ - .document
111
+ - .rspec
112
+ - .rvmrc
113
+ - Gemfile
114
+ - Gemfile.lock
115
+ - Guardfile
116
+ - LICENSE.txt
117
+ - README.rdoc
118
+ - Rakefile
119
+ - VERSION
120
+ - lib/mandrill.rb
121
+ - lib/mandrill/api.rb
122
+ - mandrill.gemspec
123
+ - spec/mandrill/fixtures/error.json
124
+ - spec/mandrill/mandrill_spec.rb
125
+ - spec/spec_helper.rb
126
+ homepage: http://github.com/terra-firma/mandrill
127
+ licenses:
128
+ - MIT
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ segments:
140
+ - 0
141
+ hash: 2296727217723416764
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ! '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 1.8.10
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Ruby gem for interacting with the Mandrill API.
154
+ test_files: []