spec/spec_helper.rb in rhoconnect-3.4.5 vs spec/spec_helper.rb in rhoconnect-4.0.0.beta.10
- old
+ new
@@ -2,10 +2,12 @@
require 'rspec'
require 'webmock/rspec'
require 'rspec/autorun' # Required for Rcov to run with rspec '~> 2.8.0'
if RUBY_VERSION =~ /1.9/ || defined?(JRUBY_VERSION)
require 'simplecov'
+ require 'simplecov-rcov'
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start do
add_filter '/spec/'
end
end
@@ -43,10 +45,11 @@
end
end
require 'rhoconnect'
include Rhoconnect
+require 'rhoconnect/server'
# require RSpec shared examples
SPEC_PATH = File.expand_path(File.dirname(__FILE__))
Dir["#{SPEC_PATH}/support/**/*.rb"].each { |f| require f }
@@ -138,16 +141,26 @@
Store.put_value(dockey,data)
end
end
end
- def set_zstate(state,assoc_key,append=false)
+ def set_source_queue_state(source, state,assoc_key,append=false)
state.each do |dockey,data|
- Store.put_zdata(dockey,assoc_key,data,append)
+ source.push_queue(dockey,assoc_key,data,append)
end
end
+ def set_doc_state(docobj, state,append=false)
+ state.each do |dockey,data|
+ if data.is_a?(Hash) or data.is_a?(Array)
+ docobj.put_data(dockey,data,append)
+ else
+ docobj.put_value(dockey,data)
+ end
+ end
+ end
+
def set_test_data(dockey,data,error_message=nil,error_name='wrongname')
if error_message
error = {'an_attribute'=>error_message,'name'=>error_name}
data.merge!({ERROR=>error})
end
@@ -171,14 +184,32 @@
Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
end
end
end
- def verify_zresult(result)
+ def verify_doc_result(docobj, result)
result.keys.sort.each do |dockey|
expected = result[dockey]
begin
- data,assoc_keys = Store.get_zdata(dockey)
+ if expected.is_a?(Hash)
+ docobj.get_data(dockey).should == expected
+ elsif expected.is_a?(Array)
+ docobj.get_data(dockey,Array).should == expected
+ else
+ docobj.get_value(dockey).should == expected
+ end
+ rescue RSpec::Expectations::ExpectationNotMetError => e
+ message = "\nVerifying `#{dockey}`\n\n" + e.to_s
+ Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
+ end
+ end
+ end
+
+ def verify_source_queue_data(source, result)
+ result.keys.sort.each do |dockey|
+ expected = result[dockey]
+ begin
+ data,assoc_keys = source.get_queue(dockey)
data.should == expected
rescue RSpec::Expectations::ExpectationNotMetError => e
message = "\nVerifying `#{dockey}`\n\n" + e.to_s
Kernel::raise(RSpec::Expectations::ExpectationNotMetError.new(message))
end