Skip to content

Commit

Permalink
Run specs in a random order
Browse files Browse the repository at this point in the history
  • Loading branch information
abrisse committed Feb 22, 2017
1 parent 3637f65 commit 8e27022
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .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:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/has_many_spec.rb
Expand Up @@ -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')}
Expand Down
6 changes: 2 additions & 4 deletions spec/repository_spec.rb
Expand Up @@ -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
Expand Down
33 changes: 15 additions & 18 deletions spec/validations_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit 8e27022

Please sign in to comment.