diff --git a/.travis.yml b/.travis.yml index 9ad9f1e..b6764bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby bundler_args: --without debug -script: "bundle exec rspec spec" +script: "bundle exec rake spec" env: - CI=true rvm: diff --git a/Rakefile b/Rakefile index c8caace..f46f884 100644 --- a/Rakefile +++ b/Rakefile @@ -10,7 +10,7 @@ desc 'Run specs' task 'spec' do RSpec::Core::RakeTask.new("spec") do |t| t.pattern = 'spec/**/*.{spec,rb}' - t.rspec_opts = ["-c"] + t.rspec_opts = ["-c --order rand"] end end diff --git a/spec/has_many_spec.rb b/spec/has_many_spec.rb index fe94aab..1a42d21 100644 --- a/spec/has_many_spec.rb +++ b/spec/has_many_spec.rb @@ -95,9 +95,10 @@ class ::Comment < Spira::Base end context "Post class basics" do - before :all do + before :each do Spira.repository = RDF::Repository.load(fixture('has_many.nt')) end + let(:post) {Post.for RDF::URI.new('http://example.org/posts/post1')} let(:empty_post) {Post.for RDF::URI.new('http://example.org/posts/post0')} let(:empty_comment) {Comment.for RDF::URI.new('http://example.org/comments/comment0')} diff --git a/spec/repository_spec.rb b/spec/repository_spec.rb index f013524..a9965c8 100644 --- a/spec/repository_spec.rb +++ b/spec/repository_spec.rb @@ -37,10 +37,8 @@ context "when registering the repository" do - before :all do - class ::Event < Spira::Base - property :name, :predicate => RDF::Vocab::DC.title - end + class ::Event < Spira::Base + property :name, :predicate => RDF::Vocab::DC.title end before :each do diff --git a/spec/validations_spec.rb b/spec/validations_spec.rb index b355411..82fd78c 100644 --- a/spec/validations_spec.rb +++ b/spec/validations_spec.rb @@ -5,34 +5,31 @@ let(:valid) {V2.for(uri, :title => 'xyz')} let(:invalid) {V2.for(uri, :title => 'not xyz')} - before :all do - class ::Bank < Spira::Base - configure :default_vocabulary => RDF::URI.new('http://example.org/banks/vocab') + class ::Bank < Spira::Base + configure :default_vocabulary => RDF::URI.new('http://example.org/banks/vocab') - property :title, :predicate => RDFS.label - property :balance, :type => Integer + property :title, :predicate => RDFS.label + property :balance, :type => Integer - validate :validate_bank + validate :validate_bank - def validate_bank - errors.add(:title, "must not be blank") if title.blank? - errors.add(:balance, "must be a number") unless balance.is_a?(Numeric) - end + def validate_bank + errors.add(:title, "must not be blank") if title.blank? + errors.add(:balance, "must be a number") unless balance.is_a?(Numeric) end + end + before do Spira.repository = RDF::Repository.new end context "when validating" do + class ::V2 < Spira::Base + property :title, :predicate => RDF::Vocab::DC.title + validate :title_is_bad - before :all do - class ::V2 < Spira::Base - property :title, :predicate => RDF::Vocab::DC.title - validate :title_is_bad - - def title_is_bad - errors.add(:title, "is not xyz") unless title == "xyz" - end + def title_is_bad + errors.add(:title, "is not xyz") unless title == "xyz" end end