Skip to content

Commit

Permalink
Add {{{ }}} around test blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
thomsbg authored and remi committed Aug 27, 2012
1 parent c3f74be commit 2a6db54
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions spec/model/orm_spec.rb
Expand Up @@ -316,7 +316,7 @@ def organization=(organization)
end

context "saving resources with overridden to_params" do
before do
before do # {{{
Her::API.setup :url => "https://api.example.com" do |builder|
builder.use Her::Middleware::FirstLevelParseJSON
builder.use Faraday::Request::UrlEncoded
Expand All @@ -329,29 +329,29 @@ def organization=(organization)
[200, {}, body]
end
end
end
end # }}}

spawn_model "Foo::User" do
def to_params
{ :fullname => "Lindsay Fünke" }
end
end
end
end # }}}

it "changes the request parameters for one-line resource creation" do
it "changes the request parameters for one-line resource creation" do # {{{
@user = Foo::User.create(:fullname => "Tobias Fünke")
@user.fullname.should == "Lindsay Fünke"
end
end # }}}

it "changes the request parameters for Model.new + #save" do
it "changes the request parameters for Model.new + #save" do # {{{
@user = Foo::User.new(:fullname => "Tobias Fünke")
@user.save
@user.fullname.should == "Lindsay Fünke"
end
end # }}}
end

context "checking resource equality" do
before do
before do # {{{
Her::API.setup :url => "https://api.example.com" do |builder|
builder.use Her::Middleware::FirstLevelParseJSON
builder.use Faraday::Request::UrlEncoded
Expand All @@ -364,52 +364,52 @@ def to_params

spawn_model "Foo::User"
spawn_model "Foo::Admin"
end
end # }}}

let(:user) { Foo::User.find(1) }

it "returns true for the exact same object" do
it "returns true for the exact same object" do # {{{
user.should == user
end
end # }}}

it "returns true for the same resource via find" do
it "returns true for the same resource via find" do # {{{
user.should == Foo::User.find(1)
end
end # }}}

it "returns true for the same class with identical data" do
it "returns true for the same class with identical data" do # {{{
user.should == Foo::User.new(:id => 1, :fullname => "Lindsay Fünke")
end
end # }}}

it "returns true for a different resource with the same data" do
it "returns true for a different resource with the same data" do # {{{
user.should == Foo::Admin.find(1)
end
end # }}}

it "returns false for the same class with different data" do
it "returns false for the same class with different data" do # {{{
user.should_not == Foo::User.new(:id => 2, :fullname => "Tobias Fünke")
end
end # }}}

it "returns false for a non-resource with the same data" do
it "returns false for a non-resource with the same data" do # {{{
fake_user = stub(:data => { :id => 1, :fullname => "Lindsay Fünke" })
user.should_not == fake_user
end
end # }}}

it "delegates eql? to ==" do
it "delegates eql? to ==" do # {{{
other = Object.new
user.expects(:==).with(other).returns(true)
user.eql?(other).should be_true
end
end # }}}

it "treats equal resources as equal for Array#uniq" do
it "treats equal resources as equal for Array#uniq" do # {{{
user2 = Foo::User.find(1)
[user, user2].uniq.should == [user]
end
end # }}}

it "treats equal resources as equal for hash keys" do
it "treats equal resources as equal for hash keys" do # {{{
Foo::User.find(1)
hash = { user => true }
hash[Foo::User.find(1)] = false
hash.size.should == 1
hash.should == { user => false }
end
end # }}}
end
end

0 comments on commit 2a6db54

Please sign in to comment.