dynport_tools 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.5
|
data/dynport_tools.gemspec
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{dynport_tools}
|
|
8
|
-
s.version = "0.2.
|
|
8
|
+
s.version = "0.2.5"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Tobias Schwab"]
|
|
@@ -34,12 +34,13 @@ Gem::Specification.new do |s|
|
|
|
34
34
|
"lib/dynport_tools.rb",
|
|
35
35
|
"lib/dynport_tools/deep_merger.rb",
|
|
36
36
|
"lib/dynport_tools/differ.rb",
|
|
37
|
+
"lib/dynport_tools/have_attributes.rb",
|
|
37
38
|
"lib/dynport_tools/jenkins.rb",
|
|
38
39
|
"lib/dynport_tools/redis_dumper.rb",
|
|
39
40
|
"lib/dynport_tools/xml_file.rb",
|
|
40
|
-
"lib/have_attributes.rb",
|
|
41
41
|
"spec/dynport_tools/deep_merger_spec.rb",
|
|
42
42
|
"spec/dynport_tools/differ_spec.rb",
|
|
43
|
+
"spec/dynport_tools/have_attributes_spec.rb",
|
|
43
44
|
"spec/dynport_tools/jenkins_spec.rb",
|
|
44
45
|
"spec/dynport_tools/redis_dumper_spec.rb",
|
|
45
46
|
"spec/dynport_tools/xml_file_spec.rb",
|
data/lib/dynport_tools.rb
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
module HaveAttributesMatcher
|
|
1
|
+
module DynportTools::HaveAttributesMatcher
|
|
3
2
|
class HaveAttributes
|
|
4
3
|
def initialize(expected)
|
|
5
4
|
@expected = expected
|
|
6
5
|
end
|
|
7
6
|
|
|
8
7
|
def differ
|
|
9
|
-
@differ ||= Differ.new(:diff_all => false)
|
|
8
|
+
@differ ||= DynportTools::Differ.new(:diff_all => false)
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
def matches?(target)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require "ostruct"
|
|
3
|
+
|
|
4
|
+
describe "DynportTools::HaveAttributesMatcher" do
|
|
5
|
+
include DynportTools::HaveAttributesMatcher
|
|
6
|
+
|
|
7
|
+
it "returns a correct error message error message" do
|
|
8
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAttributes.new(:a => 1)
|
|
9
|
+
matcher.matches?(:a => 2).should == false
|
|
10
|
+
matcher.failure_message.should == "expected a to be <1> but was <2>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "returns true when arrays are equal" do
|
|
14
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAttributes.new(:a => 1)
|
|
15
|
+
matcher.matches?(:a => 1).should be_true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "returns true when expected hash as viewer values than target" do
|
|
19
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAttributes.new(:a => 1)
|
|
20
|
+
matcher.matches?(:a => 1, :b => 2).should be_true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "returns false when expected hash as viewer values than target but HaveAllAttributes is used" do
|
|
24
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAllAttributes.new(:a => 1)
|
|
25
|
+
matcher.matches?(:a => 1, :b => 2).should be_false
|
|
26
|
+
matcher.failure_message.should == "expected b to be <nil> but was <2>"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "returns true when object returns the correct values" do
|
|
30
|
+
struct = OpenStruct.new(:a => 1, :b => 2)
|
|
31
|
+
matcher = DynportTools::HaveAttributesMatcher::ReturnValues.new(:a => 1)
|
|
32
|
+
matcher.matches?(struct).should be_true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "returns false when object returns other values" do
|
|
36
|
+
struct = OpenStruct.new(:a => 1, :b => 3)
|
|
37
|
+
matcher = DynportTools::HaveAttributesMatcher::ReturnValues.new(:a => 1, :b => 2)
|
|
38
|
+
matcher.matches?(struct).should be_false
|
|
39
|
+
matcher.failure_message.should == "expected b to return <2> but did <3>"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "returns the correct error message for complex hashes" do
|
|
43
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAttributes.new(:a => { :b => [1] })
|
|
44
|
+
matcher.matches?(:a => { :b => [2] }).should be_false
|
|
45
|
+
matcher.failure_message.should == "expected a[b][0] to be <1> but was <2>"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "returns false when target hash as viewer values than expected" do
|
|
49
|
+
matcher = DynportTools::HaveAttributesMatcher::HaveAttributes.new(:a => 1, :b => 2)
|
|
50
|
+
matcher.matches?(:a => 1).should be_false
|
|
51
|
+
end
|
|
52
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dynport_tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 29
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 5
|
|
10
|
+
version: 0.2.5
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Tobias Schwab
|
|
@@ -207,12 +207,13 @@ files:
|
|
|
207
207
|
- lib/dynport_tools.rb
|
|
208
208
|
- lib/dynport_tools/deep_merger.rb
|
|
209
209
|
- lib/dynport_tools/differ.rb
|
|
210
|
+
- lib/dynport_tools/have_attributes.rb
|
|
210
211
|
- lib/dynport_tools/jenkins.rb
|
|
211
212
|
- lib/dynport_tools/redis_dumper.rb
|
|
212
213
|
- lib/dynport_tools/xml_file.rb
|
|
213
|
-
- lib/have_attributes.rb
|
|
214
214
|
- spec/dynport_tools/deep_merger_spec.rb
|
|
215
215
|
- spec/dynport_tools/differ_spec.rb
|
|
216
|
+
- spec/dynport_tools/have_attributes_spec.rb
|
|
216
217
|
- spec/dynport_tools/jenkins_spec.rb
|
|
217
218
|
- spec/dynport_tools/redis_dumper_spec.rb
|
|
218
219
|
- spec/dynport_tools/xml_file_spec.rb
|