Skip to content

Commit

Permalink
Updating explicit path for rspec matchers
Browse files Browse the repository at this point in the history
Since these are not automatically included, making sure they work.
  • Loading branch information
jeremyf committed Feb 25, 2013
1 parent a92a719 commit 5d93906
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"
require 'ostruct'
require 'webmock/rspec'
require 'lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher'
require File.expand_path("../../../lib/active_fedora/rspec_matchers/belong_to_associated_active_fedora_object_matcher", File.dirname(__FILE__))

describe RSpec::Matchers, "belong_to_associated_active_fedora_object_matcher" do
subject { OpenStruct.new(:pid => pid )}
Expand All @@ -10,16 +10,14 @@
let(:object2) { Object.new }
let(:association) { :association }

before(:each) do
subject.class.should_receive(:find).with(pid).and_return(subject)
end

it 'should match when association is properly stored in fedora' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(association).and_return(object1)
subject.should belong_to_associated_active_fedora_object(association).with_object(object1)
end

it 'should not match when association is different' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(association).and_return(object1)
lambda {
subject.should belong_to_associated_active_fedora_object(association).with_object(object2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"
require 'ostruct'
require 'webmock/rspec'
require 'active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher'
require File.expand_path("../../../lib/active_fedora/rspec_matchers/have_many_associated_active_fedora_objects_matcher", File.dirname(__FILE__))

describe RSpec::Matchers, "have_many_associated_active_fedora_objects_matcher" do
subject { OpenStruct.new(:pid => pid )}
Expand All @@ -11,16 +11,14 @@
let(:object3) { Object.new }
let(:association) { :association }

before(:each) do
subject.class.should_receive(:find).with(pid).and_return(subject)
end

it 'should match when association is properly stored in fedora' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(association).and_return([object1,object2])
subject.should have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
end

it 'should not match when association is different' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(association).and_return([object1,object3])
lambda {
subject.should have_many_associated_active_fedora_objects(association).with_objects([object1, object2])
Expand Down
8 changes: 3 additions & 5 deletions spec/unit/rspec_matchers/have_predicate_matcher_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"
require 'ostruct'
require 'webmock/rspec'
require 'active_fedora/rspec_matchers/have_predicate_matcher'
require File.expand_path("../../../lib/active_fedora/rspec_matchers/have_predicate_matcher", File.dirname(__FILE__))

describe RSpec::Matchers, "have_predicate_matcher" do
subject { OpenStruct.new(:pid => pid )}
Expand All @@ -11,16 +11,14 @@
let(:object3) { Object.new }
let(:predicate) { :predicate }

before(:each) do
subject.class.should_receive(:find).with(pid).and_return(subject)
end

it 'should match when relationship is "what we have in Fedora"' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(:relationships).with(predicate).and_return([object1,object2])
subject.should have_predicate(predicate).with_objects([object1, object2])
end

it 'should not match when relationship is different' do
subject.class.should_receive(:find).with(pid).and_return(subject)
subject.should_receive(:relationships).with(predicate).and_return([object1,object3])
lambda {
subject.should have_predicate(predicate).with_objects([object1, object2])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "spec_helper"
require 'ostruct'
require 'webmock/rspec'
require 'active_fedora/rspec_matchers/match_fedora_datastream_matcher'
require File.expand_path("../../../lib/active_fedora/rspec_matchers/match_fedora_datastream_matcher", File.dirname(__FILE__))

describe RSpec::Matchers, "match_fedora_datastream" do
let(:pid) { 123 }
Expand Down

0 comments on commit 5d93906

Please sign in to comment.