[DRE-commits] [ruby-yajl] 01/02: Patche tests to support new RSpec and mocks
Balasankar C
balasankarc-guest at moszumanska.debian.org
Wed Jul 8 14:46:28 UTC 2015
This is an automated email from the git hooks/post-receive script.
balasankarc-guest pushed a commit to branch master
in repository ruby-yajl.
commit 217e4091bbb8c4d46a183be0b0cc61dc45fbd8ea
Author: Balasankar C <balasankarc at autistici.org>
Date: Wed Jul 8 20:16:03 2015 +0530
Patche tests to support new RSpec and mocks
---
debian/patches/RSpec3-test-fix | 105 +++++++++++++++++++++++++++++++++++++++++
debian/patches/mocks-test-fix | 43 +++++++++++++++++
debian/patches/series | 2 +
3 files changed, 150 insertions(+)
diff --git a/debian/patches/RSpec3-test-fix b/debian/patches/RSpec3-test-fix
new file mode 100644
index 0000000..15c7bac
--- /dev/null
+++ b/debian/patches/RSpec3-test-fix
@@ -0,0 +1,105 @@
+Description: Fix tests to run with RSpec 3.x
+ RSpec 3.x redefined the matchers like be_true and be_false to be_truthy and
+ be_falsey respectively. Fixing the tests to follow those modifications.
+Author: Balasankar C <balasankarc at autistici.org>
+Last-Update: 2015-07-08
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/spec/encoding/encoding_spec.rb
++++ b/spec/encoding/encoding_spec.rb
+@@ -225,7 +225,7 @@
+ nilpassed = true if chunk.nil?
+ s << chunk
+ end
+- nilpassed.should be_true
++ nilpassed.should be_truthy
+ s.rewind
+ s.read.should eql("{\"foo\":\"bar\"}")
+ end
+@@ -312,4 +312,4 @@
+ Yajl::Encoder.encode(root)
+ }.should raise_error(Yajl::EncodeError)
+ end
+-end
+\ No newline at end of file
++end
+--- a/spec/json_gem_compatibility/compatibility_spec.rb
++++ b/spec/json_gem_compatibility/compatibility_spec.rb
+@@ -7,40 +7,40 @@
+ it "shoud not mixin #to_json on base objects until compatability has been enabled" do
+ d = Dummy.new
+
+- d.respond_to?(:to_json).should_not be_true
+- "".respond_to?(:to_json).should_not be_true
+- 1.respond_to?(:to_json).should_not be_true
+- "1.5".to_f.respond_to?(:to_json).should_not be_true
+- [].respond_to?(:to_json).should_not be_true
+- {:foo => "bar"}.respond_to?(:to_json).should_not be_true
+- true.respond_to?(:to_json).should_not be_true
+- false.respond_to?(:to_json).should_not be_true
+- nil.respond_to?(:to_json).should_not be_true
++ d.respond_to?(:to_json).should_not be_truthy
++ "".respond_to?(:to_json).should_not be_truthy
++ 1.respond_to?(:to_json).should_not be_truthy
++ "1.5".to_f.respond_to?(:to_json).should_not be_truthy
++ [].respond_to?(:to_json).should_not be_truthy
++ {:foo => "bar"}.respond_to?(:to_json).should_not be_truthy
++ true.respond_to?(:to_json).should_not be_truthy
++ false.respond_to?(:to_json).should_not be_truthy
++ nil.respond_to?(:to_json).should_not be_truthy
+ end
+
+ it "should mixin #to_json on base objects after compatability has been enabled" do
+ require 'yajl/json_gem'
+ d = Dummy.new
+
+- d.respond_to?(:to_json).should be_true
+- "".respond_to?(:to_json).should be_true
+- 1.respond_to?(:to_json).should be_true
+- "1.5".to_f.respond_to?(:to_json).should be_true
+- [].respond_to?(:to_json).should be_true
+- {:foo => "bar"}.respond_to?(:to_json).should be_true
+- true.respond_to?(:to_json).should be_true
+- false.respond_to?(:to_json).should be_true
+- nil.respond_to?(:to_json).should be_true
++ d.respond_to?(:to_json).should be_truthy
++ "".respond_to?(:to_json).should be_truthy
++ 1.respond_to?(:to_json).should be_truthy
++ "1.5".to_f.respond_to?(:to_json).should be_truthy
++ [].respond_to?(:to_json).should be_truthy
++ {:foo => "bar"}.respond_to?(:to_json).should be_truthy
++ true.respond_to?(:to_json).should be_truthy
++ false.respond_to?(:to_json).should be_truthy
++ nil.respond_to?(:to_json).should be_truthy
+ end
+
+ it "should require yajl/json_gem to enable the compatability API" do
+- defined?(JSON).should be_true
++ defined?(JSON).should be_truthy
+
+- JSON.respond_to?(:parse).should be_true
+- JSON.respond_to?(:generate).should be_true
+- JSON.respond_to?(:pretty_generate).should be_true
+- JSON.respond_to?(:load).should be_true
+- JSON.respond_to?(:dump).should be_true
++ JSON.respond_to?(:parse).should be_truthy
++ JSON.respond_to?(:generate).should be_truthy
++ JSON.respond_to?(:pretty_generate).should be_truthy
++ JSON.respond_to?(:load).should be_truthy
++ JSON.respond_to?(:dump).should be_truthy
+ end
+
+ it "should allow default parsing options be set with JSON.default_options" do
+@@ -70,9 +70,9 @@
+ end
+
+ it "should have the standard parsing and encoding exceptions mapped" do
+- JSON::JSONError.new.is_a?(StandardError).should be_true
+- JSON::ParserError.new.is_a?(JSON::JSONError).should be_true
+- JSON::GeneratorError.new.is_a?(JSON::JSONError).should be_true
++ JSON::JSONError.new.is_a?(StandardError).should be_truthy
++ JSON::ParserError.new.is_a?(JSON::JSONError).should be_truthy
++ JSON::GeneratorError.new.is_a?(JSON::JSONError).should be_truthy
+
+ lambda {
+ JSON.parse("blah")
diff --git a/debian/patches/mocks-test-fix b/debian/patches/mocks-test-fix
new file mode 100644
index 0000000..9c452aa
--- /dev/null
+++ b/debian/patches/mocks-test-fix
@@ -0,0 +1,43 @@
+Description: Fix tests to run with new ruby-mocks
+ In new versions of ruby-mocks, the use of doubles or partial doubles from
+ rspec-mocks outside of the per-test lifecycle is not supported. Fix the tests
+ to use a temporary scope
+Author: Balasankar C <balasankarc at autistici.org>
+Last-Update: 2015-07-08
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/spec/http/http_error_spec.rb
++++ b/spec/http/http_error_spec.rb
+@@ -10,15 +10,17 @@
+
+ describe "Yajl HTTP error" do
+ before(:all) do
+- @request = File.new(File.expand_path(File.dirname(__FILE__) + "/fixtures/http.error.dump"), 'r')
+- @uri = 'file://'+File.expand_path(File.dirname(__FILE__) + "/fixtures/http/http.error.dump")
+- TCPSocket.should_receive(:new).and_return(@request)
+- @request.should_receive(:write)
++ RSpec::Mocks.with_temporary_scope do
++ @request = File.new(File.expand_path(File.dirname(__FILE__) + "/fixtures/http.error.dump"), 'r')
++ @uri = 'file://'+File.expand_path(File.dirname(__FILE__) + "/fixtures/http/http.error.dump")
++ TCPSocket.should_receive(:new).and_return(@request)
++ @request.should_receive(:write)
+
+- begin
+- Yajl::HttpStream.get(@uri)
+- rescue Yajl::HttpStream::HttpError => e
+- @error = e
++ begin
++ Yajl::HttpStream.get(@uri)
++ rescue Yajl::HttpStream::HttpError => e
++ @error = e
++ end
+ end
+ end
+
+@@ -29,4 +31,4 @@
+ it "should provide the HTTP response headers" do
+ @error.headers.keys.should include('ETag', 'Content-Length', 'Server')
+ end
+-end
+\ No newline at end of file
++end
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..49ebfda
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,2 @@
+mocks-test-fix
+RSpec3-test-fix
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-yajl.git
More information about the Pkg-ruby-extras-commits
mailing list