I have a Rails app that serves up JSON, and want to test some code that request and process some json via http. What's the best way to test this code without stubbing http request-response?
I'm thinking of firing webrick to serve Rails app, but technically inept to do so. Any pointer to code example is appreciated.
# lib/bam.rb
require 'open-uri'
class Bam
  def bam host='localhost'
    hash = JSON.parse( open("http://#{host}/bam.json) )
    # process hash
  end
end
# spec/bam_spec.rb
RSpec.describe 'Bam' do
  before(:all) do
    # fire up webrick
  end
  after(:all) do
    # shutdown webrick
  end
  it 'bam' do
    hash = Bam.new.bam
    hash.should eq('bam' => 'bam')
  end
end
