Sha256: ad7f5e0dd48b46ddaef844ef1925102311cebdb644e8b398f527ae71a2eafa80
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Her::Model do before do Her::API.setup :url => "https://api.example.com" do |connection| connection.use Her::Middleware::FirstLevelParseJSON connection.adapter :test do |stub| stub.get("/users/1") { |env| [200, {}, { :id => 1, :name => "Tobias Fünke" }.to_json] } stub.get("/users/1/comments") { |env| [200, {}, [{ :id => 4, :body => "They're having a FIRESALE?" }].to_json] } end end spawn_model("Foo::User") { has_many :comments } spawn_model("Foo::Comment") end subject { Foo::User.find(1) } describe :has_key? do it { should_not have_key(:unknown_method_for_a_user) } it { should_not have_key(:unknown_method_for_a_user) } it { should have_key(:name) } it { should have_key(:comments) } end describe :serialization do it 'should be serialized without an error' do expect { Marshal.dump(subject.comments) }.not_to raise_error end it 'should correctly load serialized object' do serialized_comments = Marshal.load(Marshal.dump(subject.comments)) expect(subject.comments.size).to eq(serialized_comments.size) expect(subject.comments.first.id).to eq(serialized_comments.first.id) expect(subject.comments.first.body).to eq(serialized_comments.first.body) end end describe :[] do it { should_not have_key(:unknown_method_for_a_user) } specify { expect(subject[:name]).to eq("Tobias Fünke") } specify { expect(subject[:comments].first.body).to eq("They're having a FIRESALE?") } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
castle-her-1.0.1 | spec/model_spec.rb |