Permalink
Browse files

prepare testing setup:

* add spec_helper with simplecov and setup helpers
* initialize pinboard api credentials for testing
* filter sensitive data from vcr
* setup Guardfile for local CI
  • Loading branch information...
1 parent c6fe063 commit 4cad4d3ecc6c07f536445c6f9d5bbfcba64e26de @phlipper committed Jul 7, 2012
Showing with 46 additions and 0 deletions.
  1. +8 −0 Guardfile
  2. +14 −0 spec/spec_helper.rb
  3. +10 −0 spec/support/pinboard_configuration.rb
  4. +14 −0 spec/support/vcr.rb
View
@@ -0,0 +1,8 @@
+# More info at https://github.com/guard/guard#readme
+
+guard "minitest" do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^(.+)/(.+)\.rb$}) { |m| "spec/#{m[1]}/#{m[2]}_spec.rb" }
+ watch(%r{^(.+)/(.+)/(.+)\.rb$}) { |m| "spec/#{m[3]}_spec.rb" }
+ watch("spec/spec_helper.rb") { "spec/" }
+end
View
@@ -0,0 +1,14 @@
+require "simplecov"
+SimpleCov.add_filter "spec"
+SimpleCov.command_name "MiniTest"
+SimpleCov.start
+
+require "minitest/autorun"
+require "minitest/pride"
+require "mocha"
+
+require File.expand_path("../../lib/pinboard_api", __FILE__)
+
+# Requires supporting ruby files with custom matchers and macros, etc,
+# in spec/support/ and its subdirectories.
+Dir[File.join("./spec/support/**/*.rb")].sort.each { |f| require f }
@@ -0,0 +1,10 @@
+PinboardApi.username = ENV["PINBOARD_USERNAME"]
+PinboardApi.password = ENV["PINBOARD_PASSWORD"]
+
+PinboardApi.ssl_options = ENV["PINBOARD_SSL_OPTIONS"] || begin
+ if File.exists?("/opt/local/share/curl/curl-ca-bundle.crt")
+ { ca_file: "/opt/local/share/curl/curl-ca-bundle.crt" }
+ else
+ { ca_path: "/System/Library/OpenSSL" }
+ end
+end
View
@@ -0,0 +1,14 @@
+require "vcr"
+require "base64"
+
+VCR.configure do |c|
+ c.default_cassette_options = { record: :once, serialize_with: :json }
+ c.hook_into :faraday
+ c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
+ c.filter_sensitive_data("[USERNAME]") { PinboardApi.username }
+ c.filter_sensitive_data("[PASSWORD]") { PinboardApi.password }
+ c.filter_sensitive_data("[FILTERED]") do
+ credentials = [PinboardApi.username, PinboardApi.password].join(":")
+ Base64.encode64(credentials).chomp
+ end
+end

0 comments on commit 4cad4d3

Please sign in to comment.