spec_helper.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Require this file using `require "spec_helper"`
  2. # to ensure that it is only loaded once.
  3. #
  4. # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
  5. require 'digest/md5'
  6. require 'coveralls'
  7. require 'vcr'
  8. require 'webmock/rspec'
  9. Coveralls.wear!
  10. VCR.configure do |c|
  11. c.cassette_library_dir = "#{File.dirname(__FILE__)}/cassettes"
  12. c.hook_into :webmock
  13. end
  14. require 'polipus'
  15. RSpec.configure do |config|
  16. config.run_all_when_everything_filtered = true
  17. config.filter_run :focus
  18. # Run specs in random order to surface order dependencies. If you find an
  19. # order dependency and want to debug it, you can fix the order by providing
  20. # the seed, which is printed after each run.
  21. # --seed 1234
  22. config.order = 'random'
  23. config.mock_with :flexmock
  24. config.around(:each) do |example|
  25. t = Time.now
  26. print example.metadata[:full_description]
  27. VCR.use_cassette(Digest::MD5.hexdigest(example.metadata[:full_description])) do
  28. example.run
  29. puts " [#{Time.now - t}s]"
  30. end
  31. end
  32. config.before(:each) { Polipus::SignalHandler.disable }
  33. end
  34. def page_factory(url, params = {})
  35. params[:code] = 200 unless params.has_key?(:code)
  36. params[:body] = '<html></html>' unless params.has_key?(:body)
  37. Polipus::Page.new url, params
  38. end