spec/spec_helper.rb in urban_dictionary-1.0.0 vs spec/spec_helper.rb in urban_dictionary-1.1.0
- old
+ new
@@ -3,35 +3,38 @@
require 'multi_json'
require 'shellwords'
require 'stringio'
require 'webmock/rspec'
-RSpec.configure do |config|
- config.run_all_when_everything_filtered = true
- config.filter_run :focus
- config.order = 'random'
-end
-
-module Test
- def self.load_fixture(name)
- File.read(File.expand_path("../html/#{name}", __FILE__))
- end
-
+module TestHelpers
class IO < StringIO
def content
rewind
read
end
+ end
- def include?(str)
- content.include?(str)
- end
+ def load_fixture(name)
+ File.read(File.expand_path("../html/#{name}", __FILE__))
end
+
+ def mk_word(term, definitions, examples)
+ UrbanDictionary::Word.new(
+ term,
+ Array(definitions).zip(Array(examples)).map {|ea| UrbanDictionary::Entry.new(*ea) }
+ )
+ end
end
class String
# Convert an input string to ARGV-like args as a shell would
def to_argv
Shellwords.split(self)
end
end
+RSpec.configure do |config|
+ config.run_all_when_everything_filtered = true
+ config.filter_run :focus
+ config.order = 'random'
+ config.include TestHelpers
+end