Skip to content

Instantly share code, notes, and snippets.

@supaspoida
Created February 14, 2012 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supaspoida/1830240 to your computer and use it in GitHub Desktop.
Save supaspoida/1830240 to your computer and use it in GitHub Desktop.
How I'd express the donors choose spec
describe DonorsChoose do
describe "requesting data" do
let(:test_title) { "A test project" }
def mock_request(args)
request = double(:fetch => %Q/{"proposals": [{"title": "#{test_title}"}]}/)
DonorsChoose::Request.should_receive(:new).with(args).and_return(request)
end
context "via lat & lng" do
subject do
described_class.projects_near_me("40.4405556", "-79.9961111")
end
before do
mock_request(:centerLat => "40.4405556", :centerLong => "-79.9961111")
end
it { should include_project 'A test project' }
end
context "via zip code" do
subject do
described_class.projects_by_zip("15232")
end
before do
mock_request(:keyword => "15232")
end
it { should include_project 'A test project' }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment