-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
152 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,50 @@ | ||
shared_examples "a resource" do |_collection, _params, _update_params| | ||
let(:collection) { client.send(_collection) } | ||
let(:params) { instance_exec(&_params) || {} } | ||
let(:update_params) { instance_exec(&_update_params) } | ||
|
||
it "by creating a record" do | ||
record = collection.create(params) | ||
record.identity.should_not be_nil | ||
end | ||
|
||
context "that is paged" do | ||
before(:each) do | ||
2.times.each { collection.create(instance_exec(&_params)) } | ||
end | ||
it "by retrieving the first page" do | ||
collection.all("per_page" => "1").size.should == 1 | ||
end | ||
|
||
shared_examples "a model" do | ||
it "by updating a record" | ||
it "by destroy a record" | ||
it "by retrieving the next page" do | ||
first_page = collection.all("per_page" => "1").to_a | ||
second_page = collection.all("per_page" => 1).next_page.to_a | ||
second_page.should_not == first_page | ||
end | ||
|
||
it "by retrieving the previous page" do | ||
first_page = collection.all("per_page" => "1").to_a | ||
previous_to_second_page = collection.all("per_page" => 1).next_page.previous_page.to_a | ||
previous_to_second_page.should == first_page | ||
end | ||
end | ||
|
||
it "by fetching a specific record" do | ||
record = collection.create(params) | ||
collection.get(record.identity).should == record | ||
end | ||
|
||
it "by updating a record" do | ||
record = collection.create(params) | ||
record.merge_attributes(update_params) | ||
record.save | ||
update_params.each {|k,v| record.send(k).should == v} | ||
end | ||
|
||
it "by destroy a record" do | ||
record = collection.create(params) | ||
record.identity.should_not be_nil | ||
record.destroy | ||
record.should be_destroyed | ||
end | ||
end |
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