Integrating VCR and RSpec
This commit is contained in:
parent
008529ded5
commit
3818c6008f
|
@ -1,48 +1,8 @@
|
||||||
# rcov generated
|
|
||||||
coverage
|
coverage
|
||||||
|
|
||||||
# rdoc generated
|
|
||||||
rdoc
|
rdoc
|
||||||
|
|
||||||
# yard generated
|
|
||||||
doc
|
doc
|
||||||
.yardoc
|
.yardoc
|
||||||
|
|
||||||
# bundler
|
|
||||||
.bundle
|
.bundle
|
||||||
|
|
||||||
# jeweler generated
|
|
||||||
pkg
|
pkg
|
||||||
|
.DS_Store
|
||||||
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
tmp
|
||||||
#
|
|
||||||
# * Create a file at ~/.gitignore
|
|
||||||
# * Include files you want ignored
|
|
||||||
# * Run: git config --global core.excludesfile ~/.gitignore
|
|
||||||
#
|
|
||||||
# After doing this, these files will be ignored in all your git projects,
|
|
||||||
# saving you from having to 'pollute' every project you touch with them
|
|
||||||
#
|
|
||||||
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
|
||||||
#
|
|
||||||
# For MacOS:
|
|
||||||
#
|
|
||||||
#.DS_Store
|
|
||||||
|
|
||||||
# For TextMate
|
|
||||||
#*.tmproj
|
|
||||||
#tmtags
|
|
||||||
|
|
||||||
# For emacs:
|
|
||||||
#*~
|
|
||||||
#\#*
|
|
||||||
#.\#*
|
|
||||||
|
|
||||||
# For vim:
|
|
||||||
#*.swp
|
|
||||||
|
|
||||||
# For redcar:
|
|
||||||
#.redcar
|
|
||||||
|
|
||||||
# For rubinius:
|
|
||||||
#*.rbc
|
|
10
Gemfile
10
Gemfile
|
@ -1,16 +1,14 @@
|
||||||
source "http://rubygems.org"
|
source "http://rubygems.org"
|
||||||
# Add dependencies required to use your gem here.
|
|
||||||
# Example:
|
|
||||||
# gem "activesupport", ">= 2.3.5"
|
|
||||||
|
|
||||||
# Add dependencies to develop your gem here.
|
|
||||||
# Include everything needed to run rake, tests, features, etc.
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "shoulda", ">= 0"
|
|
||||||
gem "bundler", "~> 1.0.0"
|
gem "bundler", "~> 1.0.0"
|
||||||
gem "jeweler", "~> 1.6.4"
|
gem "jeweler", "~> 1.6.4"
|
||||||
gem "rcov", ">= 0"
|
gem "rcov", ">= 0"
|
||||||
gem "rdoc", ">= 0"
|
gem "rdoc", ">= 0"
|
||||||
|
|
||||||
|
gem "rspec"
|
||||||
|
gem "vcr"
|
||||||
|
gem "webmock"
|
||||||
end
|
end
|
||||||
|
|
||||||
gem "nokogiri", ">= 0"
|
gem "nokogiri", ">= 0"
|
||||||
|
|
20
Gemfile.lock
20
Gemfile.lock
|
@ -1,6 +1,9 @@
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
addressable (2.2.6)
|
||||||
|
crack (0.3.1)
|
||||||
|
diff-lcs (1.1.3)
|
||||||
git (1.2.5)
|
git (1.2.5)
|
||||||
jeweler (1.6.4)
|
jeweler (1.6.4)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
|
@ -10,7 +13,18 @@ GEM
|
||||||
rake (0.9.2)
|
rake (0.9.2)
|
||||||
rcov (0.9.9)
|
rcov (0.9.9)
|
||||||
rdoc (3.8)
|
rdoc (3.8)
|
||||||
shoulda (2.11.3)
|
rspec (2.7.0)
|
||||||
|
rspec-core (~> 2.7.0)
|
||||||
|
rspec-expectations (~> 2.7.0)
|
||||||
|
rspec-mocks (~> 2.7.0)
|
||||||
|
rspec-core (2.7.0)
|
||||||
|
rspec-expectations (2.7.0)
|
||||||
|
diff-lcs (~> 1.1.2)
|
||||||
|
rspec-mocks (2.7.0)
|
||||||
|
vcr (1.11.3)
|
||||||
|
webmock (1.7.7)
|
||||||
|
addressable (~> 2.2, > 2.2.5)
|
||||||
|
crack (>= 0.1.7)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
@ -21,4 +35,6 @@ DEPENDENCIES
|
||||||
nokogiri
|
nokogiri
|
||||||
rcov
|
rcov
|
||||||
rdoc
|
rdoc
|
||||||
shoulda
|
rspec
|
||||||
|
vcr
|
||||||
|
webmock
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "artist" do
|
||||||
|
it "return valid instance", :vcr do
|
||||||
|
artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
|
||||||
|
artist.should be_a_kind_of(MusicBrainz::Artist)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "search by name", :vcr do
|
||||||
|
matches = MusicBrainz::Artist.search('Kasabian')
|
||||||
|
matches.should have_at_least(1).item
|
||||||
|
matches.first[:name].should eql('Kasabian')
|
||||||
|
end
|
||||||
|
#
|
||||||
|
# should "get correct result by name" do
|
||||||
|
# @artist = MusicBrainz::Artist.find_by_name('Kasabian')
|
||||||
|
# assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# setup do
|
||||||
|
# @artist = MusicBrainz::Artist.find('69b39eab-6577-46a4-a9f5-817839092033')
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# should "return valid instance" do
|
||||||
|
# assert_instance_of(MusicBrainz::Artist, @artist)
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# should "contain correct data" do
|
||||||
|
# assert_equal("69b39eab-6577-46a4-a9f5-817839092033", @artist.id)
|
||||||
|
# assert_equal("Group", @artist.type)
|
||||||
|
# assert_equal("Kasabian", @artist.name)
|
||||||
|
# assert_equal("GB", @artist.country)
|
||||||
|
# assert_equal("1999", @artist.date_begin)
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# should "load release groups" do
|
||||||
|
# release_groups = @artist.release_groups
|
||||||
|
# assert_operator(16, :<=, release_groups.length)
|
||||||
|
# assert_equal('533cbc5f-ec7e-32ab-95f3-8d1f804a5176', release_groups.first.id)
|
||||||
|
# assert_equal('Single', release_groups.first.type)
|
||||||
|
# assert_equal('Club Foot', release_groups.first.title)
|
||||||
|
# assert_equal(Time.utc(2004, 5, 10), release_groups.first.first_release_date)
|
||||||
|
# end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
require 'rubygems'
|
||||||
|
require 'bundler'
|
||||||
|
begin
|
||||||
|
Bundler.setup(:default, :development)
|
||||||
|
rescue Bundler::BundlerError => e
|
||||||
|
$stderr.puts e.message
|
||||||
|
$stderr.puts "Run `bundle install` to install missing gems"
|
||||||
|
exit e.status_code
|
||||||
|
end
|
||||||
|
require "vcr"
|
||||||
|
require "musicbrainz"
|
||||||
|
|
||||||
|
# HTTPI.log = false
|
||||||
|
Dir[File.dirname(__FILE__)+"/../lib/*.rb"].each{ |f| require f }
|
||||||
|
Dir[File.dirname(__FILE__)+"/../spec/support/*.rb"].each{ |f| require f }
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.mock_with :rspec
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
VCR.config do |c|
|
||||||
|
c.cassette_library_dir = File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'vcr')
|
||||||
|
c.stub_with :webmock
|
||||||
|
c.default_cassette_options = { :record => :new_episodes }
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
||||||
|
c.around(:each, :vcr) do |example|
|
||||||
|
name = example.metadata[:full_description].gsub(/\s/, '_')
|
||||||
|
VCR.use_cassette(name) { example.call }
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require 'bundler'
|
require 'bundler'
|
||||||
begin
|
begin
|
||||||
Bundler.setup(:default, :development)
|
Bundler.setup(:default, :test)
|
||||||
rescue Bundler::BundlerError => e
|
rescue Bundler::BundlerError => e
|
||||||
$stderr.puts e.message
|
$stderr.puts e.message
|
||||||
$stderr.puts "Run `bundle install` to install missing gems"
|
$stderr.puts "Run `bundle install` to install missing gems"
|
||||||
|
|
Loading…
Reference in New Issue