Created
July 28, 2010 17:07
-
-
Save PatrickLef/495327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
module Rack | |
class MockResponse | |
attr_accessor :data | |
end | |
module Test | |
class Session | |
alias_method :get_original, :get | |
def get(uri, to_json = false, params = {}, env = {}, &block) | |
if to_json | |
obj = self.get_original(uri, {}, {}, &block) | |
obj.data = JSON.parse(got.body) | |
return obj | |
end | |
return self.get_original(uri, {}, {}, &block) | |
end | |
end | |
end | |
end | |
describe User, "In user object" do | |
before(:each) do | |
@got = get '/users/validation_rules', true | |
end | |
it "Should recieve a 200 since page exists" do | |
@got.status.should == 200 | |
end | |
it "shoul be a hash" do | |
@got.data.should be_a_kind_of Hash | |
end | |
it "shoul be a hash" do | |
got = get '/foosdsd/bar', true | |
got.status.should == 404 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment