Как я могу проверить с Rspec, если все поля объекта Hash:Rspec включим Искателя, beetwen Hash и строковые объекты
{"id"=>5392501, "owner"=>"cainlevy", "name"=>"photor", "url"=>"https://api.github.com/repos/cainlevy/photor", "description"=>"Photo Organizer (in Ruby)", "created_at"=>"2012-08-12T22:26:08Z", "pushed_at"=>"2013-02-19T03:11:10Z", "organization"=>"User", "full_name"=>"cainlevy/photor", "language"=>"Ruby", "updated_at"=>"2013-03-13T02:05:33Z"}
является ВКЛЮЧЕНЫ в супернаборе filds, который является объектом Строки:
{"id":5392501,"name":"photor","full_name":"cainlevy/photor","owner":{"login":"cainlevy","id":4449,"avatar_url":"https://secure.gravatar.com/avatar/2573ddee29779e76b7da7d3c2c9ff18d?d=https://a248.e.akamai.net},"private":false,"html_url":"https://github.com/cainlevy/photor","description":"Photo Organizer (in Ruby)","fork":false,"created_at":"2012-08-12T22:26:08Z","updated_at":"2013-03-13T02:05:33Z","pushed_at":"2013-02-19T03:11:10Z","git_url":"git://github.com/cainlevy/photor.git","ssh_url":"[email protected]:cainlevy/photor.git","clone_url":"https://github.com/cainlevy/photor.git","svn_url":"https://github.com/cainlevy/photor","homepage":null,"size":312,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":4,"master_branch":"master","default_branch":"master"}
в настоящее время я собираюсь с fixture_repos[0].to_json.should include compared
где
fixture_repos[0].to_json.class: String
и
compared.class: Hash
и я получаю следующие Неудачи:
no implicit conversion of Hash into String
, который, по-видимому, я не могу избавиться от от conferting строки для хеширования:
fixture_repos[0].to_json.to_h
или наоборот
compared.to_s
UPDATE, вот это полный спектр:
require "spec_helper"
describe Elasticrepo::Extractor do
let(:fixture_repos) { Yajl::Parser.parse(fixture("repositories.json").read) }
context "GET /users/:user/starred" do
describe "#extract" do
let(:compared) {Yajl::Parser.parse(fixture("live_extracted.repos[0].to_json").read) }
it "includes compared fields" do
fixture_repos[0].to_json.should include compared
end
end
end
end
end