Sha256: bfcfced13162bd0092ce6cff1bca2a20236a0add9185b381392bad12f1ab75b6
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
require 'spec_helper' require 'fdoc/spec_watcher' describe Fdoc::SpecWatcher do context "on rails" do before do # This should be an integration test, but for now a smoke test suffices to # surface obvious bugs and verify some behaviours. @klass = Class.new do def example Struct.new(:metadata).new(:fdoc => 'index') end def response Struct.new(:body, :status).new("{}", 200) end def get(action, params) params end end.new @klass.extend(Fdoc::SpecWatcher) end it 'should verify when params are a hash' do Fdoc::Service.should_receive(:verify!).with do |*args| args[2] == {:id => 1} end @klass.get(:index, {:id => 1}) end it 'should verify when params are JSON' do Fdoc::Service.should_receive(:verify!).with do |*args| args[2] == {'id' => 1} end @klass.get(:index, {:id => 1}.to_json) end end context "on sinatra" do before do # This should be an integration test, but for now a smoke test suffices to # surface obvious bugs and verify some behaviours. @klass = Class.new do def example Struct.new(:metadata).new(:fdoc => 'index') end def last_response Struct.new(:body, :status).new("{}", 200) end def get(action, params) params end end.new @klass.extend(Fdoc::SpecWatcher) end it 'should verify when params are a hash' do Fdoc::Service.should_receive(:verify!).with do |*args| args[2] == {:id => 1} end @klass.get("/", {:id => 1}) end it 'should verify when params are JSON' do Fdoc::Service.should_receive(:verify!).with do |*args| args[2] == {'id' => 1} end @klass.get("/", {:id => 1}.to_json) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fdoc-0.3.1 | spec/fdoc/spec_watcher_spec.rb |
fdoc-0.3.0 | spec/fdoc/spec_watcher_spec.rb |
fdoc-0.2.7 | spec/fdoc/spec_watcher_spec.rb |