Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Forked from tammersaleh/agents_spec.rb
Created October 30, 2011 19:49
Show Gist options
  • Save dchelimsky/1326341 to your computer and use it in GitHub Desktop.
Save dchelimsky/1326341 to your computer and use it in GitHub Desktop.
describe "GET /agents.json" do
it_behaves_like "API controller", :params => { ... }, :environment => { ... }
end
shared_context "API Controller", :as => :api do |params, environment|
before do
regexp = Regexp.new("(GET|PUT|POST|DELETE|HEAD) ([^ ]+)")
if match = regexp.match(example.full_description)
http_method = match[1].downcase
request_path = match[2]
send(http_method, request_path, params, environment)
else
raise "#{example.full_description.inspect} doesn't match #{regexp.inspect}"
end
end
subject {response}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment