spec/model/introspection_spec.rb in her-0.5.4 vs spec/model/introspection_spec.rb in her-0.5.5
- old
+ new
@@ -10,14 +10,18 @@
builder.adapter :test do |stub|
stub.post("/users") { |env| [200, {}, { :id => 1, :name => "Tobias Funke" }.to_json] }
stub.get("/users/1") { |env| [200, {}, { :id => 1, :name => "Tobias Funke" }.to_json] }
stub.put("/users/1") { |env| [200, {}, { :id => 1, :name => "Tobias Funke" }.to_json] }
stub.delete("/users/1") { |env| [200, {}, { :id => 1, :name => "Tobias Funke" }.to_json] }
+ stub.get("/projects/1/comments") { |env| [200, {}, [{ :id => 1, :body => "Hello!" }].to_json] }
end
end
spawn_model "Foo::User"
+ spawn_model "Foo::Comment" do
+ collection_path "projects/:project_id/comments"
+ end
end
describe "#inspect" do
it "outputs resource attributes for an existing resource" do
@user = Foo::User.find(1)
@@ -33,9 +37,17 @@
@user = Foo::User.new(:name => "Tobias Funke", :password => "Funke")
@user.instance_eval {def password; 'filtered'; end}
@user.inspect.should include("name=\"Tobias Funke\"")
@user.inspect.should include("password=\"filtered\"")
@user.inspect.should_not include("password=\"Funke\"")
+ end
+ end
+
+ describe "#inspect with errors in resource path" do
+ it "prints the resource path as “unknown”" do
+ @comment = Foo::Comment.all(:project_id => 1).first
+ path = '<unknown path, missing `project_id`>'
+ ["#<Foo::Comment(#{path}) body=\"Hello!\" id=1>", "#<Foo::Comment(#{path}) id=1 body=\"Hello!\">"].should include(@comment.inspect)
end
end
end
describe "#her_nearby_class" do