Sha256: fe0cc22a1e3d5245d0fc0971becd03b273336d929bdda6a1a7c8ef370657ca7a

Contents?: true

Size: 1.29 KB

Versions: 23

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Resource do
  describe '#resource' do
    before do
      class Example < Resource
        property :login
        property :name
        property :age, type: Float
      end
    end

    it "returns a hash with properties and its values" do
      example = Example.new(login: 'jackiechan2010', name: 'Jackie Chan', age: 45)
      example.resource.should == {login: 'jackiechan2010', name: 'Jackie Chan', age: 45}
    end
  end

  context "when using not allowed names" do
    [:resource_id, :resource, :link].each do |unallowed|
      it "warns when method #{unallowed} is redefined" do
        output = out do
          eval <<-RUBY
            class Example < Resource
              def #{unallowed}
              end
            end
          RUBY
        end
        output.should =~ /^warning: redefining '#{unallowed}' may cause serious problems/
      end

      %w(property embeds_one embeds_many has_one has_many belongs_to).each do |kind|
        it "removes method #{unallowed} created by #{kind}" do
          expect {
            eval <<-RUBY
              class Example < Resource
                #{kind} :#{unallowed}
              end
            RUBY
          }.to raise_error "you can't define a key with name '#{unallowed}'"
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
transcriber-0.0.26 spec/unit/resource_spec.rb
transcriber-0.0.25 spec/unit/resource_spec.rb
transcriber-0.0.24 spec/unit/resource_spec.rb
transcriber-0.0.23 spec/unit/resource_spec.rb
transcriber-0.0.22 spec/unit/resource_spec.rb
transcriber-0.0.21 spec/unit/resource_spec.rb
transcriber-0.0.20 spec/unit/resource_spec.rb
transcriber-0.0.19 spec/unit/resource_spec.rb
transcriber-0.0.18 spec/unit/resource_spec.rb
transcriber-0.0.17 spec/unit/resource_spec.rb
transcriber-0.0.16 spec/unit/resource_spec.rb
transcriber-0.0.15 spec/unit/resource_spec.rb
transcriber-0.0.14 spec/unit/resource_spec.rb
transcriber-0.0.13 spec/unit/resource_spec.rb
transcriber-0.0.12 spec/unit/resource_spec.rb
transcriber-0.0.11 spec/unit/resource_spec.rb
transcriber-0.0.10 spec/unit/resource_spec.rb
transcriber-0.0.9 spec/unit/resource_spec.rb
transcriber-0.0.8 spec/unit/resource_spec.rb
transcriber-0.0.7 spec/unit/resource_spec.rb