elabs_matchers 0.0.6 → 0.0.7
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/elabs_matchers.gemspec +0 -1
- data/lib/elabs_matchers/matchers/{allow.rb → be_valid_with.rb} +25 -14
- data/lib/elabs_matchers/matchers/contain_hash.rb +1 -1
- data/lib/elabs_matchers/matchers/have_table_row.rb +29 -19
- data/lib/elabs_matchers/version.rb +1 -1
- data/lib/elabs_matchers.rb +1 -1
- data/spec/elabs_matchers/matchers/be_valid_with_spec.rb +81 -0
- data/spec/elabs_matchers/matchers/have_table_row_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +37 -75
- data/Gemfile.lock +0 -78
- data/spec/elabs_matchers/matchers/allow_spec.rb +0 -81
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 775e0037ad133043d76380525391978398cd42c9
|
4
|
+
data.tar.gz: 46a7b64b13ce24b91460892d7ea54e0422816f94
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2029037fccd2e72e97458fda8e4a860deb750a0da0125288543099436d69ebe7eb4b203a07db44207a2562801982722c49d9279dfc2dad02210b6bfe794c3bb
|
7
|
+
data.tar.gz: 7afe7bc2a56957f5071be4849edf40d82ac0b9884d5091a3851d5ff5b491e786d2235e0f27a237b932e258a658a15d8c78a99be9afb0517e22ae1437ce6af3e4
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ gem "elabs_matchers"
|
|
24
24
|
|
25
25
|
### Model matchers:
|
26
26
|
```ruby
|
27
|
-
record.should
|
27
|
+
record.should be_valid_with("Blog post").as(:title)
|
28
28
|
hash.contain_hash({ "baz" => "bar" })
|
29
29
|
array.only_include("bar", "foo")
|
30
30
|
record.should persist(:title, "Blog post")
|
data/elabs_matchers.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module ElabsMatchers
|
2
2
|
module Matchers
|
3
|
-
module
|
3
|
+
module BeValidWith
|
4
4
|
if defined?(ActiveModel)
|
5
5
|
rspec :type => :model
|
6
6
|
|
7
|
-
class
|
7
|
+
class BeValidWithMatcher
|
8
8
|
attr_reader :record, :attributes
|
9
9
|
|
10
10
|
def initialize(values)
|
@@ -28,7 +28,7 @@ module ElabsMatchers
|
|
28
28
|
# @param [*Array] attributes The method name(s) that has the validation(s) attached to it
|
29
29
|
#
|
30
30
|
# Example:
|
31
|
-
# post.should
|
31
|
+
# post.should be_valid_with("Elabs").as(:title)
|
32
32
|
|
33
33
|
def as(*attributes)
|
34
34
|
@attributes = [*attributes]
|
@@ -43,6 +43,10 @@ module ElabsMatchers
|
|
43
43
|
common_failure_message(:invalid)
|
44
44
|
end
|
45
45
|
|
46
|
+
def description
|
47
|
+
"be valid with #{@values.inspect} as #{@attributes.inspect}"
|
48
|
+
end
|
49
|
+
|
46
50
|
private
|
47
51
|
|
48
52
|
def correct_number_of_errors?
|
@@ -90,7 +94,7 @@ module ElabsMatchers
|
|
90
94
|
def values ; [*@values] ; end
|
91
95
|
|
92
96
|
def common_failure_message(match_type)
|
93
|
-
"Expected #{expected_values_explain} to be #{match_type} on #{record.class.model_name
|
97
|
+
"Expected #{expected_values_explain} to be #{match_type} on #{record.class.model_name}'s #{attributes_values_explain} attributes but it wasn't."
|
94
98
|
end
|
95
99
|
|
96
100
|
def expected_values_explain
|
@@ -109,21 +113,28 @@ module ElabsMatchers
|
|
109
113
|
# @param [*Array] values Sample value(s) to check the validation against
|
110
114
|
#
|
111
115
|
# Example:
|
112
|
-
# post.should
|
113
|
-
# post.should_not
|
116
|
+
# post.should be_valid_with("Elabs").as(:title)
|
117
|
+
# post.should_not be_valid_with("").as(:title)
|
114
118
|
#
|
115
|
-
# post.should
|
116
|
-
# post.should_not
|
119
|
+
# post.should be_valid_with("Elabs").as(:title, :body)
|
120
|
+
# post.should_not be_valid_with("").as(:title, :body)
|
117
121
|
#
|
118
|
-
# post.should
|
119
|
-
# post.should_not
|
122
|
+
# post.should be_valid_with("Elabs", "Sweden").as(:title)
|
123
|
+
# post.should_not be_valid_with("", nil).as(:title)
|
120
124
|
#
|
121
|
-
# post.should
|
122
|
-
# post.should_not
|
125
|
+
# post.should be_valid_with("Elabs", "Sweden").as(:title, :body)
|
126
|
+
# post.should_not be_valid_with("", nil).as(:title, :body)
|
123
127
|
|
124
|
-
def
|
125
|
-
|
128
|
+
def be_valid_with(*values)
|
129
|
+
BeValidWithMatcher.new(values)
|
126
130
|
end
|
131
|
+
|
132
|
+
##
|
133
|
+
#
|
134
|
+
# This is a DEPRECATED alias for `be_valid_with`. This no longer works
|
135
|
+
# with newer versions of RSpec
|
136
|
+
#
|
137
|
+
alias_method :allow, :be_valid_with
|
127
138
|
end
|
128
139
|
end
|
129
140
|
end
|
@@ -36,7 +36,7 @@ module ElabsMatchers
|
|
36
36
|
ElabsMatchers.table_row_selector[row, table]
|
37
37
|
else
|
38
38
|
exps = row.map do |header, value|
|
39
|
-
col_index = table.all("th").index { |th| th.text.include?(header.to_s) }
|
39
|
+
col_index = table.all("th").to_a.index { |th| th.text.include?(header.to_s) }
|
40
40
|
col_index = if col_index then col_index + 1 else 0 end
|
41
41
|
|
42
42
|
XPath.generate do |x|
|
@@ -50,7 +50,7 @@ module ElabsMatchers
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
XPath.descendant
|
53
|
+
XPath.descendant(:tr)[exps.reduce(:&)]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -63,28 +63,30 @@ module ElabsMatchers
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def ascii_table
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
column_lengths[i]
|
66
|
+
synchronize do
|
67
|
+
if table
|
68
|
+
column_lengths = []
|
69
|
+
table.all("tr").map do |tr|
|
70
|
+
tr.all("td,th").each_with_index do |td, i|
|
71
|
+
size = td_content(td).strip.size
|
72
|
+
if (column_lengths[i] || 0) < size
|
73
|
+
column_lengths[i] = size
|
74
|
+
end
|
73
75
|
end
|
74
76
|
end
|
75
|
-
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
table.all("tr").map do |tr|
|
79
|
+
middle = []
|
80
|
+
space = if tr.all("td,th").first.tag_name == "th" then "_" else " " end
|
81
|
+
wall = "|"
|
81
82
|
|
82
|
-
|
83
|
-
|
84
|
-
|
83
|
+
tr.all("td,th").each_with_index do |td, i|
|
84
|
+
middle << td_content(td).strip.ljust(column_lengths[i], space)
|
85
|
+
end
|
85
86
|
|
86
|
-
|
87
|
-
|
87
|
+
[wall, space, middle.join(space + wall + space), space, wall].join
|
88
|
+
end.join("\n")
|
89
|
+
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
@@ -93,6 +95,14 @@ module ElabsMatchers
|
|
93
95
|
text ||= td.find("input, textarea")[:value] if td.has_css?("input")
|
94
96
|
text || ""
|
95
97
|
end
|
98
|
+
|
99
|
+
def synchronize
|
100
|
+
if page.respond_to?(:document)
|
101
|
+
page.document.synchronize { yield }
|
102
|
+
else
|
103
|
+
yield
|
104
|
+
end
|
105
|
+
end
|
96
106
|
end
|
97
107
|
|
98
108
|
|
data/lib/elabs_matchers.rb
CHANGED
@@ -13,7 +13,7 @@ module ElabsMatchers
|
|
13
13
|
require "elabs_matchers/helpers/reload_record"
|
14
14
|
require "elabs_matchers/helpers/select_year_and_month"
|
15
15
|
|
16
|
-
require "elabs_matchers/matchers/
|
16
|
+
require "elabs_matchers/matchers/be_valid_with"
|
17
17
|
require "elabs_matchers/matchers/contain_hash"
|
18
18
|
require "elabs_matchers/matchers/have_attribute"
|
19
19
|
require "elabs_matchers/matchers/have_fields"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fixtures/post"
|
3
|
+
|
4
|
+
describe ElabsMatchers::Matchers::BeValidWith do
|
5
|
+
let(:post) { ElabsMatchers::Orm::Post.create }
|
6
|
+
subject { post }
|
7
|
+
|
8
|
+
context "with one example value" do
|
9
|
+
context "with one attribute" do
|
10
|
+
it { should be_valid_with("Elabs").as(:title) }
|
11
|
+
it { should_not be_valid_with("", []).as(:title) }
|
12
|
+
|
13
|
+
it { expect { should be_valid_with("").as(:title) }.to fail_assertion }
|
14
|
+
it { expect { should_not be_valid_with("Elabs").as(:title) }.to fail_assertion }
|
15
|
+
it { expect { should_not be_valid_with("").as(:signature) }.to fail_assertion }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "with several attributes" do
|
19
|
+
it { should be_valid_with("Elabs").as(:title, :body) }
|
20
|
+
it { should_not be_valid_with("").as(:title, :body) }
|
21
|
+
|
22
|
+
it { expect { should be_valid_with("").as(:title, :body) }.to fail_assertion }
|
23
|
+
it { expect { should_not be_valid_with("Elabs").as(:title, :body) }.to fail_assertion }
|
24
|
+
|
25
|
+
it { expect { should be_valid_with("").as(:title, :signature) }.to fail_assertion }
|
26
|
+
it { expect { should_not be_valid_with("").as(:title, :signature) }.to fail_assertion }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with several example values" do
|
31
|
+
context "with one attribute" do
|
32
|
+
it { should be_valid_with("Elabs", "Sweden").as(:title) }
|
33
|
+
it { should_not be_valid_with("", nil).as(:title) }
|
34
|
+
|
35
|
+
it { expect { should be_valid_with("Elabs", "").as(:title) }.to fail_assertion }
|
36
|
+
it { expect { should_not be_valid_with("", "Elabs").as(:title) }.to fail_assertion }
|
37
|
+
it { should be_valid_with("", "Elabs").as(:signature) }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with several attributes" do
|
41
|
+
it { should be_valid_with("Elabs", "Sweden").as(:title, :body) }
|
42
|
+
it { should_not be_valid_with("", nil).as(:title, :body) }
|
43
|
+
|
44
|
+
it { expect { should be_valid_with("Elabs", "").as(:title, :body) }.to fail_assertion }
|
45
|
+
it { expect { should_not be_valid_with("", "Elabs").as(:title, :body) }.to fail_assertion }
|
46
|
+
|
47
|
+
it { expect { should be_valid_with("", "Elabs").as(:title, :signature) }.to fail_assertion }
|
48
|
+
it { expect { should_not be_valid_with("", "Elabs").as(:title, :signature) }.to fail_assertion }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "non-string values" do
|
53
|
+
it { should be_valid_with(Date.today).as(:published_on) }
|
54
|
+
it { should be_valid_with(Time.now).as(:published_on) }
|
55
|
+
it { should be_valid_with(DateTime.now).as(:published_on) }
|
56
|
+
|
57
|
+
it { should be_valid_with(nil).as(:signature) }
|
58
|
+
it { should_not be_valid_with(nil).as(:title) }
|
59
|
+
it { should be_valid_with(9).as(:title) }
|
60
|
+
it { should be_valid_with(:bar).as(:title) }
|
61
|
+
|
62
|
+
it { should be_valid_with(["Peter", "Bob"], ["Marry", "Anna"]).as(:authors) }
|
63
|
+
it { should be_valid_with(:first_name => "Peter", :last_name => "Smith").as(:co_author) }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "some aditional examples just for illustrating more use-cases" do
|
67
|
+
context "inclusion" do
|
68
|
+
it { should be_valid_with("sci-fi", "thriller").as(:category) }
|
69
|
+
it { should_not be_valid_with("pocket", nil).as(:category) }
|
70
|
+
it { expect { should be_valid_with("pocket", "").as(:category) }.to fail_assertion }
|
71
|
+
it { expect { should_not be_valid_with("sci-fi", "thriller").as(:category) }.to fail_assertion }
|
72
|
+
end
|
73
|
+
|
74
|
+
context "numericality" do
|
75
|
+
it { should be_valid_with(9, "9", "9e3", 0.1).as(:price) }
|
76
|
+
it { should_not be_valid_with("cheap", nil).as(:price) }
|
77
|
+
it { expect { should be_valid_with("cheap", nil).as(:price) }.to fail_assertion }
|
78
|
+
it { expect { should_not be_valid_with(9, "9", "9e3", 0.1).as(:price) }.to fail_assertion }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -89,7 +89,7 @@ describe ElabsMatchers::Matchers::HaveTableRow, :type => :feature do
|
|
89
89
|
before do
|
90
90
|
ElabsMatchers.table_row_selector = lambda do |row, table|
|
91
91
|
exps = row.map do |header, value|
|
92
|
-
col_index = table.all("th").index { |th| th.text.include?(header.to_s) }
|
92
|
+
col_index = table.all("th").to_a.index { |th| th.text.include?(header.to_s) }
|
93
93
|
col_index = if col_index then col_index + 1 else 0 end
|
94
94
|
|
95
95
|
XPath.generate do |x|
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,7 @@ require "elabs_matchers"
|
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.mock_with :rspec
|
11
|
-
config.include Capybara
|
11
|
+
config.include Capybara::DSL
|
12
12
|
|
13
13
|
%w[helpers matchers].each do |dir|
|
14
14
|
Dir[File.join(File.expand_path(File.dirname(__FILE__)), "../lib/elabs_matchers/#{dir}/*.rb")].each do |file|
|
metadata
CHANGED
@@ -1,176 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elabs_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Everyone at Elabs
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec-core
|
16
|
-
prerelease: false
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
|
-
none: false
|
23
20
|
type: :runtime
|
21
|
+
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- -
|
24
|
+
- - ">="
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: '0'
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec-expectations
|
32
|
-
prerelease: false
|
33
29
|
requirement: !ruby/object:Gem::Requirement
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
|
-
none: false
|
39
34
|
type: :runtime
|
35
|
+
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
|
-
- -
|
38
|
+
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: '0'
|
45
|
-
none: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
|
-
prerelease: false
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
|
-
none: false
|
55
48
|
type: :development
|
49
|
+
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- -
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
|
-
none: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
|
-
prerelease: false
|
65
57
|
requirement: !ruby/object:Gem::Requirement
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
|
-
none: false
|
71
62
|
type: :development
|
63
|
+
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
65
|
requirements:
|
74
|
-
- -
|
66
|
+
- - ">="
|
75
67
|
- !ruby/object:Gem::Version
|
76
68
|
version: '0'
|
77
|
-
none: false
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: capybara
|
80
|
-
prerelease: false
|
81
71
|
requirement: !ruby/object:Gem::Requirement
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
|
-
none: false
|
87
76
|
type: :development
|
77
|
+
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
79
|
requirements:
|
90
|
-
- -
|
80
|
+
- - ">="
|
91
81
|
- !ruby/object:Gem::Version
|
92
82
|
version: '0'
|
93
|
-
none: false
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: yard
|
96
|
-
prerelease: false
|
97
85
|
requirement: !ruby/object:Gem::Requirement
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
|
-
none: false
|
103
90
|
type: :development
|
91
|
+
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
93
|
requirements:
|
106
|
-
- -
|
94
|
+
- - ">="
|
107
95
|
- !ruby/object:Gem::Version
|
108
96
|
version: '0'
|
109
|
-
none: false
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: activesupport
|
112
|
-
prerelease: false
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
|
-
none: false
|
119
104
|
type: :development
|
105
|
+
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- -
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
|
-
none: false
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: activemodel
|
128
|
-
prerelease: false
|
129
113
|
requirement: !ruby/object:Gem::Requirement
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - ">="
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: '0'
|
134
|
-
none: false
|
135
118
|
type: :development
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - ! '>='
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
141
|
-
none: false
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: redcarpet
|
144
119
|
prerelease: false
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
none: false
|
151
|
-
type: :development
|
152
120
|
version_requirements: !ruby/object:Gem::Requirement
|
153
121
|
requirements:
|
154
|
-
- -
|
122
|
+
- - ">="
|
155
123
|
- !ruby/object:Gem::Version
|
156
124
|
version: '0'
|
157
|
-
none: false
|
158
125
|
- !ruby/object:Gem::Dependency
|
159
126
|
name: pry
|
160
|
-
prerelease: false
|
161
127
|
requirement: !ruby/object:Gem::Requirement
|
162
128
|
requirements:
|
163
|
-
- -
|
129
|
+
- - ">="
|
164
130
|
- !ruby/object:Gem::Version
|
165
131
|
version: '0'
|
166
|
-
none: false
|
167
132
|
type: :development
|
133
|
+
prerelease: false
|
168
134
|
version_requirements: !ruby/object:Gem::Requirement
|
169
135
|
requirements:
|
170
|
-
- -
|
136
|
+
- - ">="
|
171
137
|
- !ruby/object:Gem::Version
|
172
138
|
version: '0'
|
173
|
-
none: false
|
174
139
|
description: Provides a set of usefull rspec matchers to be used with RSpec and/or
|
175
140
|
Capybara
|
176
141
|
email:
|
@@ -179,9 +144,8 @@ executables: []
|
|
179
144
|
extensions: []
|
180
145
|
extra_rdoc_files: []
|
181
146
|
files:
|
182
|
-
- .gitignore
|
147
|
+
- ".gitignore"
|
183
148
|
- Gemfile
|
184
|
-
- Gemfile.lock
|
185
149
|
- README.md
|
186
150
|
- Rakefile
|
187
151
|
- development.txt
|
@@ -251,7 +215,7 @@ files:
|
|
251
215
|
- lib/elabs_matchers/helpers/normalize_keys.rb
|
252
216
|
- lib/elabs_matchers/helpers/reload_record.rb
|
253
217
|
- lib/elabs_matchers/helpers/select_year_and_month.rb
|
254
|
-
- lib/elabs_matchers/matchers/
|
218
|
+
- lib/elabs_matchers/matchers/be_valid_with.rb
|
255
219
|
- lib/elabs_matchers/matchers/contain_hash.rb
|
256
220
|
- lib/elabs_matchers/matchers/have_attribute.rb
|
257
221
|
- lib/elabs_matchers/matchers/have_fields.rb
|
@@ -267,7 +231,7 @@ files:
|
|
267
231
|
- spec/elabs_matchers/helpers/normalize_keys_spec.rb
|
268
232
|
- spec/elabs_matchers/helpers/reload_record_spec.rb
|
269
233
|
- spec/elabs_matchers/helpers/select_year_and_month_spec.rb
|
270
|
-
- spec/elabs_matchers/matchers/
|
234
|
+
- spec/elabs_matchers/matchers/be_valid_with_spec.rb
|
271
235
|
- spec/elabs_matchers/matchers/contain_hash_spec.rb
|
272
236
|
- spec/elabs_matchers/matchers/have_attribute_spec.rb
|
273
237
|
- spec/elabs_matchers/matchers/have_fields_spec.rb
|
@@ -284,34 +248,33 @@ files:
|
|
284
248
|
- todo.txt
|
285
249
|
homepage: http://github.com/elabs/elabs_matchers
|
286
250
|
licenses: []
|
251
|
+
metadata: {}
|
287
252
|
post_install_message:
|
288
253
|
rdoc_options: []
|
289
254
|
require_paths:
|
290
255
|
- lib
|
291
256
|
required_ruby_version: !ruby/object:Gem::Requirement
|
292
257
|
requirements:
|
293
|
-
- -
|
258
|
+
- - ">="
|
294
259
|
- !ruby/object:Gem::Version
|
295
260
|
version: '0'
|
296
|
-
none: false
|
297
261
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
262
|
requirements:
|
299
|
-
- -
|
263
|
+
- - ">="
|
300
264
|
- !ruby/object:Gem::Version
|
301
265
|
version: '0'
|
302
|
-
none: false
|
303
266
|
requirements: []
|
304
267
|
rubyforge_project: elabs_matchers
|
305
|
-
rubygems_version:
|
268
|
+
rubygems_version: 2.2.2
|
306
269
|
signing_key:
|
307
|
-
specification_version:
|
270
|
+
specification_version: 4
|
308
271
|
summary: Provides a set of usefull rspec matchers
|
309
272
|
test_files:
|
310
273
|
- spec/elabs_matchers/helpers/fixtures_spec.rb
|
311
274
|
- spec/elabs_matchers/helpers/normalize_keys_spec.rb
|
312
275
|
- spec/elabs_matchers/helpers/reload_record_spec.rb
|
313
276
|
- spec/elabs_matchers/helpers/select_year_and_month_spec.rb
|
314
|
-
- spec/elabs_matchers/matchers/
|
277
|
+
- spec/elabs_matchers/matchers/be_valid_with_spec.rb
|
315
278
|
- spec/elabs_matchers/matchers/contain_hash_spec.rb
|
316
279
|
- spec/elabs_matchers/matchers/have_attribute_spec.rb
|
317
280
|
- spec/elabs_matchers/matchers/have_fields_spec.rb
|
@@ -325,4 +288,3 @@ test_files:
|
|
325
288
|
- spec/fixtures/file.txt
|
326
289
|
- spec/fixtures/post.rb
|
327
290
|
- spec/spec_helper.rb
|
328
|
-
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
elabs_matchers (0.0.5)
|
5
|
-
rspec-core
|
6
|
-
rspec-expectations
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activemodel (3.2.8)
|
12
|
-
activesupport (= 3.2.8)
|
13
|
-
builder (~> 3.0.0)
|
14
|
-
activesupport (3.2.8)
|
15
|
-
i18n (~> 0.6)
|
16
|
-
multi_json (~> 1.0)
|
17
|
-
addressable (2.3.2)
|
18
|
-
builder (3.0.3)
|
19
|
-
capybara (1.1.2)
|
20
|
-
mime-types (>= 1.16)
|
21
|
-
nokogiri (>= 1.3.3)
|
22
|
-
rack (>= 1.0.0)
|
23
|
-
rack-test (>= 0.5.4)
|
24
|
-
selenium-webdriver (~> 2.0)
|
25
|
-
xpath (~> 0.1.4)
|
26
|
-
childprocess (0.3.5)
|
27
|
-
ffi (~> 1.0, >= 1.0.6)
|
28
|
-
coderay (1.0.6)
|
29
|
-
diff-lcs (1.1.3)
|
30
|
-
ffi (1.1.5)
|
31
|
-
i18n (0.6.1)
|
32
|
-
libwebsocket (0.1.5)
|
33
|
-
addressable
|
34
|
-
method_source (0.7.1)
|
35
|
-
mime-types (1.19)
|
36
|
-
multi_json (1.3.6)
|
37
|
-
nokogiri (1.5.5)
|
38
|
-
pry (0.9.9.6)
|
39
|
-
coderay (~> 1.0.5)
|
40
|
-
method_source (~> 0.7.1)
|
41
|
-
slop (>= 2.4.4, < 3)
|
42
|
-
rack (1.4.1)
|
43
|
-
rack-test (0.6.1)
|
44
|
-
rack (>= 1.0)
|
45
|
-
rake (0.9.2.2)
|
46
|
-
redcarpet (2.1.1)
|
47
|
-
rspec (2.11.0)
|
48
|
-
rspec-core (~> 2.11.0)
|
49
|
-
rspec-expectations (~> 2.11.0)
|
50
|
-
rspec-mocks (~> 2.11.0)
|
51
|
-
rspec-core (2.11.1)
|
52
|
-
rspec-expectations (2.11.3)
|
53
|
-
diff-lcs (~> 1.1.3)
|
54
|
-
rspec-mocks (2.11.2)
|
55
|
-
rubyzip (0.9.9)
|
56
|
-
selenium-webdriver (2.25.0)
|
57
|
-
childprocess (>= 0.2.5)
|
58
|
-
libwebsocket (~> 0.1.3)
|
59
|
-
multi_json (~> 1.0)
|
60
|
-
rubyzip
|
61
|
-
slop (2.4.4)
|
62
|
-
xpath (0.1.4)
|
63
|
-
nokogiri (~> 1.3)
|
64
|
-
yard (0.8.2.1)
|
65
|
-
|
66
|
-
PLATFORMS
|
67
|
-
ruby
|
68
|
-
|
69
|
-
DEPENDENCIES
|
70
|
-
activemodel
|
71
|
-
activesupport
|
72
|
-
capybara
|
73
|
-
elabs_matchers!
|
74
|
-
pry
|
75
|
-
rake
|
76
|
-
redcarpet
|
77
|
-
rspec
|
78
|
-
yard
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "fixtures/post"
|
3
|
-
|
4
|
-
describe ElabsMatchers::Matchers::Allow do
|
5
|
-
let(:post) { ElabsMatchers::Orm::Post.create }
|
6
|
-
subject { post }
|
7
|
-
|
8
|
-
context "with one example value" do
|
9
|
-
context "with one attribute" do
|
10
|
-
it { should allow("Elabs").as(:title) }
|
11
|
-
it { should_not allow("", []).as(:title) }
|
12
|
-
|
13
|
-
it { expect { should allow("").as(:title) }.to fail_assertion }
|
14
|
-
it { expect { should_not allow("Elabs").as(:title) }.to fail_assertion }
|
15
|
-
it { expect { should_not allow("").as(:signature) }.to fail_assertion }
|
16
|
-
end
|
17
|
-
|
18
|
-
context "with several attributes" do
|
19
|
-
it { should allow("Elabs").as(:title, :body) }
|
20
|
-
it { should_not allow("").as(:title, :body) }
|
21
|
-
|
22
|
-
it { expect { should allow("").as(:title, :body) }.to fail_assertion }
|
23
|
-
it { expect { should_not allow("Elabs").as(:title, :body) }.to fail_assertion }
|
24
|
-
|
25
|
-
it { expect { should allow("").as(:title, :signature) }.to fail_assertion }
|
26
|
-
it { expect { should_not allow("").as(:title, :signature) }.to fail_assertion }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "with several example values" do
|
31
|
-
context "with one attribute" do
|
32
|
-
it { should allow("Elabs", "Sweden").as(:title) }
|
33
|
-
it { should_not allow("", nil).as(:title) }
|
34
|
-
|
35
|
-
it { expect { should allow("Elabs", "").as(:title) }.to fail_assertion }
|
36
|
-
it { expect { should_not allow("", "Elabs").as(:title) }.to fail_assertion }
|
37
|
-
it { should allow("", "Elabs").as(:signature) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with several attributes" do
|
41
|
-
it { should allow("Elabs", "Sweden").as(:title, :body) }
|
42
|
-
it { should_not allow("", nil).as(:title, :body) }
|
43
|
-
|
44
|
-
it { expect { should allow("Elabs", "").as(:title, :body) }.to fail_assertion }
|
45
|
-
it { expect { should_not allow("", "Elabs").as(:title, :body) }.to fail_assertion }
|
46
|
-
|
47
|
-
it { expect { should allow("", "Elabs").as(:title, :signature) }.to fail_assertion }
|
48
|
-
it { expect { should_not allow("", "Elabs").as(:title, :signature) }.to fail_assertion }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "non-string values" do
|
53
|
-
it { should allow(Date.today).as(:published_on) }
|
54
|
-
it { should allow(Time.now).as(:published_on) }
|
55
|
-
it { should allow(DateTime.now).as(:published_on) }
|
56
|
-
|
57
|
-
it { should allow(nil).as(:signature) }
|
58
|
-
it { should_not allow(nil).as(:title) }
|
59
|
-
it { should allow(9).as(:title) }
|
60
|
-
it { should allow(:bar).as(:title) }
|
61
|
-
|
62
|
-
it { should allow(["Peter", "Bob"], ["Marry", "Anna"]).as(:authors) }
|
63
|
-
it { should allow(:first_name => "Peter", :last_name => "Smith").as(:co_author) }
|
64
|
-
end
|
65
|
-
|
66
|
-
context "some aditional examples just for illustrating more use-cases" do
|
67
|
-
context "inclusion" do
|
68
|
-
it { should allow("sci-fi", "thriller").as(:category) }
|
69
|
-
it { should_not allow("pocket", nil).as(:category) }
|
70
|
-
it { expect { should allow("pocket", "").as(:category) }.to fail_assertion }
|
71
|
-
it { expect { should_not allow("sci-fi", "thriller").as(:category) }.to fail_assertion }
|
72
|
-
end
|
73
|
-
|
74
|
-
context "numericality" do
|
75
|
-
it { should allow(9, "9", "9e3", 0.1).as(:price) }
|
76
|
-
it { should_not allow("cheap", nil).as(:price) }
|
77
|
-
it { expect { should allow("cheap", nil).as(:price) }.to fail_assertion }
|
78
|
-
it { expect { should_not allow(9, "9", "9e3", 0.1).as(:price) }.to fail_assertion }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|