spec/get_spec.rb in ncmb-ruby-client-0.0.8 vs spec/get_spec.rb in ncmb-ruby-client-0.0.9

- old
+ new

@@ -1,42 +1,19 @@ # -*- coding: utf-8 -*- require "spec_helper" describe NCMB do before do yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'setting.yml')) - @ncmb = NCMB.init(application_key: yaml['application_key'], - client_key: yaml['client_key'] - ) + NCMB.initialize application_key: yaml['application_key'], client_key: yaml['client_key'] + @todoClass = todoClass = NCMB::DataStore.new 'GET_TODO' + @todoClass.delete_all + 10.times do |i| + @todoClass.new(text: "Task ##{i + 1}").save + end end it "Get #1" do - queries = {:count => "1", :limit => "20", :order => "-createDate", :skip => "0"} - todo_class = @ncmb.data_store 'TODO' - # {"count":5,"results":[{"objectId":"VwswoCe7PEuSbGEU","createDate":"2014-05-07T12:03:37.428Z","updateDate":"2014-05-07T12:03:37.428Z","acl":{"*":{"read":true,"write":true}},"todo":"タスクの追加"},{"objectId":"pj9scMgCGQ3wyd5m","createDate":"2014-05-07T08:03:56.268Z","updateDate":"2014-05-07T08:03:56.268Z","acl":{"*":{"read":true,"write":true}},"todo":"タスクを追加"},{"objectId":"lq3CIoaSAcM5Du6I","createDate":"2014-05-07T08:03:44.181Z","updateDate":"2014-05-07T08:03:44.181Z","acl":{"*":{"read":true,"write":true}},"todo":"テストのタスク"},{"objectId":"jln8aWojgUDUnCYo","createDate":"2014-05-07T08:02:23.104Z","updateDate":"2014-05-07T08:02:23.104Z","acl":{"*":{"read":true,"write":true}},"todo":"レビューします"},{"objectId":"zhRGEjECBdaUBLLn","createDate":"2014-05-07T08:02:10.573Z","updateDate":"2014-05-07T08:02:10.573Z","acl":{"*":{"read":true,"write":true}},"todo":"記事を書きます"}]} - #puts todo_class.get queries + @items = @todoClass.order('-createDate').skip(0).all + @items.length.should == 10 end - it "Generate signature #3" do - params = { - :where => { - "point" => { - "$within" => { - "$box" => [ - { - "__type" => "GeoPoint", - "latitude" => 35.690921, - "longitude" => 139.700258 - }, - { - "__type" => "GeoPoint", - "latitude" => 35.728926, - "longitude" => 139.71038 - } - ] - } - } - } - } - signature = @ncmb.generate_signature :get, "/#{@ncmb.api_version}/classes/Venue", URI.escape("2014-05-20T04:55:16.395Z", /[^-_.!~*'()a-zA-Z\d]/u), params - expect(signature).to eq("sqlhM3xxNPUxFWDHQ5CdDqBp6dInU/YkO2PzuY31Pbk=") - end end