Sha256: 7e87325019356bfd1d6a39df8d4f6a387189e6fa2a5caccc7d6fcf5ef3f729d5
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require "spec_helper" describe DataMapper::Property::ParseFile do subject { property } let(:property) { Article.properties[:attachment] } describe "#dump" do subject { property.dump value } let(:value) { { "name" => "xx.txt", "url" => "http://a.cn/xx.txt" } } it { should eq(value.merge("__type" => "File")) } context "when value is nil" do let(:value) { nil } it { should be_nil } end context "when value is io" do let(:value) { StringIO.new "xx" } before { value.stub(original_filename: "xx.txt", content_type: "plain/text") } before { DataMapper::Adapters::ParseAdapter.any_instance.stub(upload_file: {"name" => "x", "url" => "y"}) } it { should be_has_key("__type") } it { should be_has_key("name") } it { should be_has_key("url") } end end describe "#load" do subject { property.load value } let(:value) { { "__type" => "File", "name" => "a.png", "url" => "http://a.cn/a.png" } } it { should eq(value) } context "when value is nil" do let(:value) { nil } it { should be_nil } end end describe "#valid?" do subject { property.valid? value } let(:value) { { "__type" => "File", "name" => "a.png", "url" => "http://a.cn/a.png" } } it { should be_true } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dm-parse-0.3.1 | spec/parse_file_spec.rb |
dm-parse-0.3.0 | spec/parse_file_spec.rb |
dm-parse-0.2.3 | spec/parse_file_spec.rb |