spec/harpy/resource_spec.rb in harpy-0.2.0 vs spec/harpy/resource_spec.rb in harpy-0.2.1

- old
+ new

@@ -17,10 +17,11 @@ module Harpy module Spec class Company include Harpy::Resource + attr_accessor :tax_id end class User include Harpy::Resource validates_presence_of :firstname before_validation :check_lastname @@ -406,9 +407,17 @@ subject.name.should be_nil end it "doesn't allows accessing undefined attributes when not persisted" do subject.should_receive(:persisted?).and_return true lambda{ subject.name }.should raise_error NoMethodError + end + it "use existing setters if available" do + company = Harpy::Spec::Company.new "tax_id" => "123" + company.tax_id.should == "123" + company.as_json.should == {} + company.attributes = {:tax_id => 123} + company.tax_id.should == 123 + company.as_json.should == {} end end describe "advanced attribute readers" do let(:url){ "http://localhost/company/1" } subject{ Harpy::Spec::Company.new "link" => [{"rel" => "self", "href" => url}] } \ No newline at end of file