spec/lib/extensions/api_response_spec.rb in memcached-manager-0.4.0 vs spec/lib/extensions/api_response_spec.rb in memcached-manager-1.0.0
- old
+ new
@@ -4,25 +4,27 @@
# thing and call methods from it, so instead I'm just calling it manually
describe Sinatra::APIResponse do
context "#api_response" do
it "should have a block given" do
- lambda { Class.new.extend(Sinatra::APIResponse).api_response }.should raise_error('No block given')
+ expect { Class.new.extend(Sinatra::APIResponse).api_response }.to raise_error('No block given')
end
context 'error' do
+ let(:klass) { Class.new.extend(Sinatra::APIResponse) }
+
it "should respond with the errors" do
- klass = Class.new.extend(Sinatra::APIResponse)
- klass.stubs(:errors).returns([{foo: 'bar'}])
- klass.api_response {{yeah: 'yeahs'}}.should =~ /errors.*foo.*bar/
+ allow(klass).to receive(:errors).and_return([{foo: 'bar'}])
+ expect(klass.api_response {{yeah: 'yeahs'}}).to match /errors.*foo.*bar/
end
end
context 'no error' do
+ let(:klass) { Class.new.extend(Sinatra::APIResponse) }
+
it "should respond with what's inside the block" do
- klass = Class.new.extend(Sinatra::APIResponse)
- klass.stubs(:errors).returns([])
- klass.api_response { {foo: 'bar'} }.should =~ /foo.*bar/
+ allow(klass).to receive(:errors).and_return([])
+ expect(klass.api_response { {foo: 'bar'} }).to match /foo.*bar/
end
end
end
end