spec/riveter/enquiry_spec.rb in riveter-0.0.5 vs spec/riveter/enquiry_spec.rb in riveter-0.0.6
- old
+ new
@@ -118,11 +118,11 @@
end
describe "called with a block" do
it "invokes the block" do
block = Mock::Block.new()
- allow(subject).to receive(:create_query_filter) { OpenStruct.new(:valid? => true) }
+ allow(subject).to receive(:create_query_filter) { double(:filter, :valid? => true) }
expect(block).to receive(:call).at_least(:once)
subject.query_with do |filter|
block.call
@@ -196,23 +196,23 @@
end
describe "#submit" do
it "yields the query for a valid filter" do
query = Object.new()
- expect(subject).to receive(:create_query_filter) { OpenStruct.new(:valid? => true) }
+ expect(subject).to receive(:create_query_filter) { double(:filter, :valid? => true) }
expect(subject).to receive(:create_query) { query }
subject.submit().should eq(query)
end
it "yields false for an invalid filter" do
- expect(subject).to receive(:create_query_filter) { OpenStruct.new(:valid? => false) }
+ expect(subject).to receive(:create_query_filter) { double(:filter, :valid? => false) }
subject.submit().should eq(false)
end
it "assigns query" do
query = Object.new()
- expect(subject).to receive(:create_query_filter) { OpenStruct.new(:valid? => true) }
+ expect(subject).to receive(:create_query_filter) { double(:filter, :valid? => true) }
expect(subject).to receive(:create_query) { query }
subject.submit()
subject.query.should eq(query)
end
end
@@ -249,16 +249,16 @@
allow(subject).to receive(:query) { nil }
subject.has_data?.should be_false
end
it "yields false when query empty" do
- allow(subject).to receive(:query) { OpenStruct.new(:has_data? => false) }
+ allow(subject).to receive(:query) { double(:query, :has_data? => false) }
subject.has_data?.should be_false
end
it "yields true when query data" do
- allow(subject).to receive(:query) { OpenStruct.new(:has_data? => true) }
+ allow(subject).to receive(:query) { double(:query, :has_data? => true) }
subject.has_data?.should be_true
end
end
describe "#query_results" do
@@ -267,10 +267,10 @@
it "yield false when invalid query" do
subject.query_results.should be_nil
end
it "yield query relation for a valid query" do
- allow(subject).to receive(:query) { OpenStruct.new(:has_data? => true, :relation => []) }
+ allow(subject).to receive(:query) { double(:query, :has_data? => true, :relation => []) }
subject.query_results.should eq([])
end
end