Skip to content

Commit

Permalink
Release 1.1.1:
Browse files Browse the repository at this point in the history
* Add support for activemodel/activesupport 4
* Restore compatibility with ActiveModel > 4.1.
  • Loading branch information
gkellogg committed Sep 26, 2015
2 parents 75cfd11 + c0a1813 commit 81a4ef0
Show file tree
Hide file tree
Showing 44 changed files with 869 additions and 1,042 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ env:
- CI=true
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.2.0
- jruby-19mode
- 2.0
- 2.1
- 2.2
- jruby
- rbx-2
sudo: false
16 changes: 9 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ source "https://rubygems.org"
gemspec

gem 'rake', '~> 10.0'
gem 'rdf', git: "git://github.com/ruby-rdf/rdf.git", branch: "develop"

group :development, :test do
gem 'redcarpet', '~> 3.2.2' unless RUBY_ENGINE == 'jruby'
gem 'psych', platforms: [:mri, :rbx]
end

group :test do
gem 'coveralls', :require => false
gem 'rspec', '~> 2.14.1'
gem 'rdf-spec', '= 1.1.3' # later version depend on rspec-its which implies rspec >= 3.0
gem 'yard', '~> 0.8'
gem 'simplecov', '~> 0.10', :require => false
gem 'redcarpet', '~> 3.2.2' unless RUBY_ENGINE == 'jruby'
gem 'guard', '~> 2.13.0'
gem 'guard-rspec', '~> 3.1.0'
gem 'guard-ctags-bundler', '~> 1.4.0'
gem 'guard' #, '~> 2.13.0'
gem 'guard-rspec' #, '~> 3.1.0'
gem 'guard-ctags-bundler' #, '~> 1.4.0'
end

#group :debug do
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.1
1.1.1
36 changes: 18 additions & 18 deletions spec/attributes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"

describe "RDF::Resource attributes" do
before do
let(:person) do
Spira.repository = RDF::Repository.new

class Person < Spira::Base
Expand All @@ -12,46 +12,46 @@ class Person < Spira::Base
friend = Person.new(:name => "Dick")
friend.save!

@person = Person.new(:name => "Charlie")
@person.friends << friend
@person.save!
p = Person.new(:name => "Charlie")
p.friends << friend
p.save!
end

describe "#reload" do
it "should reload single-value attributes from the repository" do
@person.name = "Jennifer"
person.name = "Jennifer"

lambda {
@person.reload
}.should change(@person, :name).from("Jennifer").to("Charlie")
expect {
person.reload
}.to change(person, :name).from("Jennifer").to("Charlie")
end

it "should reload list attributes from the repository" do
friend = Person.new(:name => "Bob")
friend.save!
@person.friends << friend
person.friends << friend

@person.should have(2).friends
expect(person.friends.length).to eql 2

@person.reload
@person.should have(1).friends
person.reload
expect(person.friends.length).to eql 1
end
end

context "when assigning a value to a non-existing property" do
context "via #update_attributes" do
it "should raise a NoMethodError" do
lambda {
@person.update_attributes(:nonexisting_attribute => 0)
}.should raise_error NoMethodError
expect {
person.update_attributes(:nonexisting_attribute => 0)
}.to raise_error NoMethodError
end
end

context "via #write_attribute" do
it "should raise a Spira::PropertyMissingError" do
lambda {
@person.send :write_attribute, :nonexisting_attribute, 0
}.should raise_error Spira::PropertyMissingError
expect {
person.send :write_attribute, :nonexisting_attribute, 0
}.to raise_error Spira::PropertyMissingError
end
end
end
Expand Down
36 changes: 17 additions & 19 deletions spec/base_uri_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

describe 'Default URIs' do

before :each do
Spira.repository = ::RDF::Repository.new
end
before(:each) {Spira.repository = RDF::Repository.new}

context "classes with a base URI" do

Expand All @@ -21,55 +19,55 @@ class ::HashBaseURITest < Spira::Base
end

it "have a base URI method" do
BaseURITest.should respond_to :base_uri
expect(BaseURITest).to respond_to :base_uri
end

it "have a correct base URI" do
BaseURITest.base_uri.should == "http://example.org/example"
expect(BaseURITest.base_uri).to eql "http://example.org/example"
end

it "provide an id_for method" do
BaseURITest.should respond_to :id_for
expect(BaseURITest).to respond_to :id_for
end

it "provide a uri based on the base URI for string arguments" do
BaseURITest.id_for('bob').should == RDF::URI.new('http://example.org/example/bob')
expect(BaseURITest.id_for('bob')).to eql RDF::URI.new('http://example.org/example/bob')
end

it "use the string form of an absolute URI as an absolute URI" do
uri = 'http://example.org/example/bob'
BaseURITest.id_for(uri).should == RDF::URI.new(uri)
expect(BaseURITest.id_for(uri)).to eql RDF::URI.new(uri)
end

it "allow any type to be used as a URI fragment, via to_s" do
uri = 'http://example.org/example/5'
BaseURITest.id_for(5).should == RDF::URI.new(uri)
expect(BaseURITest.id_for(5)).to eql RDF::URI.new(uri)
end

it "allow appending fragment RDF::URIs to base_uris" do
BaseURITest.for(RDF::URI('test')).subject.to_s.should == 'http://example.org/example/test'
expect(BaseURITest.for(RDF::URI('test')).subject.to_s).to eql 'http://example.org/example/test'
end

it "do not raise an exception to project with a relative URI" do
lambda {x = BaseURITest.for 'bob'}.should_not raise_error
expect {x = BaseURITest.for 'bob'}.not_to raise_error
end

it "return an absolute, correct RDF::URI from #uri when created with a relative uri" do
test = BaseURITest.for('bob')
test.uri.should be_a RDF::URI
test.uri.to_s.should == "http://example.org/example/bob"
expect(test.uri).to be_a RDF::URI
expect(test.uri.to_s).to eql "http://example.org/example/bob"
end

it "save objects created with a relative URI as absolute URIs" do
test = BaseURITest.for('bob')
test.name = 'test'
test.save!
saved = BaseURITest.for('bob')
saved.name.should == 'test'
expect(saved.name).to eql 'test'
end

it "do not append a / if the base URI ends with a #" do
HashBaseURITest.id_for('bob').should == RDF::URI.new('http://example.org/example#bob')
expect(HashBaseURITest.id_for('bob')).to eql RDF::URI.new('http://example.org/example#bob')
end
end

Expand All @@ -81,19 +79,19 @@ class ::NoBaseURITest < Spira::Base
end

it "have a base URI method" do
NoBaseURITest.should respond_to :base_uri
expect(NoBaseURITest).to respond_to :base_uri
end

it "provide a id_for method" do
NoBaseURITest.should respond_to :id_for
expect(NoBaseURITest).to respond_to :id_for
end

it "have a nil base_uri" do
NoBaseURITest.base_uri.should be_nil
expect(NoBaseURITest.base_uri).to be_nil
end

it "raise an ArgumentError when projected with a relative URI" do
lambda { x = NoBaseURITest.id_for('bob')}.should raise_error ArgumentError
expect { x = NoBaseURITest.id_for('bob')}.to raise_error ArgumentError
end
end

Expand Down
Loading

0 comments on commit 81a4ef0

Please sign in to comment.