swiss_knife 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/Gemfile.lock +58 -41
- data/lib/swiss_knife/rspec/allow.rb +39 -41
- data/lib/swiss_knife/rspec.rb +3 -1
- data/lib/swiss_knife/version.rb +1 -1
- data/spec/support/config/boot.rb +2 -2
- data/spec/swiss_knife/rspec/allow_spec.rb +4 -4
- data/swiss_knife.gemspec +2 -1
- metadata +75 -65
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--format
|
1
|
+
--color --format documentation --debug
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
swiss_knife (0.2.
|
4
|
+
swiss_knife (0.2.3)
|
5
5
|
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
-
actionmailer (3.0.
|
12
|
-
actionpack (= 3.0.
|
13
|
-
mail (~> 2.2.
|
14
|
-
actionpack (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
11
|
+
actionmailer (3.0.9)
|
12
|
+
actionpack (= 3.0.9)
|
13
|
+
mail (~> 2.2.19)
|
14
|
+
actionpack (3.0.9)
|
15
|
+
activemodel (= 3.0.9)
|
16
|
+
activesupport (= 3.0.9)
|
17
17
|
builder (~> 2.1.2)
|
18
18
|
erubis (~> 2.6.6)
|
19
19
|
i18n (~> 0.5.0)
|
@@ -21,71 +21,87 @@ GEM
|
|
21
21
|
rack-mount (~> 0.6.14)
|
22
22
|
rack-test (~> 0.5.7)
|
23
23
|
tzinfo (~> 0.3.23)
|
24
|
-
activemodel (3.0.
|
25
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.9)
|
25
|
+
activesupport (= 3.0.9)
|
26
26
|
builder (~> 2.1.2)
|
27
27
|
i18n (~> 0.5.0)
|
28
|
-
activerecord (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
31
|
-
arel (~> 2.0.
|
28
|
+
activerecord (3.0.9)
|
29
|
+
activemodel (= 3.0.9)
|
30
|
+
activesupport (= 3.0.9)
|
31
|
+
arel (~> 2.0.10)
|
32
32
|
tzinfo (~> 0.3.23)
|
33
|
-
activeresource (3.0.
|
34
|
-
activemodel (= 3.0.
|
35
|
-
activesupport (= 3.0.
|
36
|
-
activesupport (3.0.
|
33
|
+
activeresource (3.0.9)
|
34
|
+
activemodel (= 3.0.9)
|
35
|
+
activesupport (= 3.0.9)
|
36
|
+
activesupport (3.0.9)
|
37
|
+
archive-tar-minitar (0.5.2)
|
37
38
|
arel (2.0.10)
|
38
39
|
builder (2.1.2)
|
40
|
+
columnize (0.3.4)
|
39
41
|
diff-lcs (1.1.2)
|
40
42
|
erubis (2.6.6)
|
41
43
|
abstract (>= 1.0.0)
|
42
44
|
fakeweb (1.3.0)
|
43
45
|
i18n (0.5.0)
|
46
|
+
linecache19 (0.5.12)
|
47
|
+
ruby_core_source (>= 0.1.4)
|
44
48
|
mail (2.2.19)
|
45
49
|
activesupport (>= 2.3.6)
|
46
50
|
i18n (>= 0.4.0)
|
47
51
|
mime-types (~> 1.16)
|
48
52
|
treetop (~> 1.4.8)
|
49
53
|
mime-types (1.16)
|
50
|
-
nokogiri (1.
|
54
|
+
nokogiri (1.5.0)
|
51
55
|
polyglot (0.3.1)
|
52
|
-
rack (1.2.
|
56
|
+
rack (1.2.3)
|
53
57
|
rack-mount (0.6.14)
|
54
58
|
rack (>= 1.0.0)
|
55
59
|
rack-test (0.5.7)
|
56
60
|
rack (>= 1.0)
|
57
|
-
rails (3.0.
|
58
|
-
actionmailer (= 3.0.
|
59
|
-
actionpack (= 3.0.
|
60
|
-
activerecord (= 3.0.
|
61
|
-
activeresource (= 3.0.
|
62
|
-
activesupport (= 3.0.
|
61
|
+
rails (3.0.9)
|
62
|
+
actionmailer (= 3.0.9)
|
63
|
+
actionpack (= 3.0.9)
|
64
|
+
activerecord (= 3.0.9)
|
65
|
+
activeresource (= 3.0.9)
|
66
|
+
activesupport (= 3.0.9)
|
63
67
|
bundler (~> 1.0)
|
64
|
-
railties (= 3.0.
|
65
|
-
railties (3.0.
|
66
|
-
actionpack (= 3.0.
|
67
|
-
activesupport (= 3.0.
|
68
|
+
railties (= 3.0.9)
|
69
|
+
railties (3.0.9)
|
70
|
+
actionpack (= 3.0.9)
|
71
|
+
activesupport (= 3.0.9)
|
68
72
|
rake (>= 0.8.7)
|
73
|
+
rdoc (~> 3.4)
|
69
74
|
thor (~> 0.14.4)
|
70
|
-
rake (0.
|
71
|
-
|
72
|
-
|
73
|
-
rspec-
|
74
|
-
rspec-
|
75
|
-
|
76
|
-
rspec-
|
75
|
+
rake (0.9.2)
|
76
|
+
rdoc (3.8)
|
77
|
+
rspec (2.6.0)
|
78
|
+
rspec-core (~> 2.6.0)
|
79
|
+
rspec-expectations (~> 2.6.0)
|
80
|
+
rspec-mocks (~> 2.6.0)
|
81
|
+
rspec-core (2.6.4)
|
82
|
+
rspec-expectations (2.6.0)
|
77
83
|
diff-lcs (~> 1.1.2)
|
78
|
-
rspec-mocks (2.
|
79
|
-
rspec-rails (2.
|
84
|
+
rspec-mocks (2.6.0)
|
85
|
+
rspec-rails (2.6.1)
|
80
86
|
actionpack (~> 3.0)
|
81
87
|
activesupport (~> 3.0)
|
82
88
|
railties (~> 3.0)
|
83
|
-
rspec (~> 2.
|
89
|
+
rspec (~> 2.6.0)
|
90
|
+
ruby-debug-base19 (0.11.25)
|
91
|
+
columnize (>= 0.3.1)
|
92
|
+
linecache19 (>= 0.5.11)
|
93
|
+
ruby_core_source (>= 0.1.4)
|
94
|
+
ruby-debug19 (0.11.6)
|
95
|
+
columnize (>= 0.3.1)
|
96
|
+
linecache19 (>= 0.5.11)
|
97
|
+
ruby-debug-base19 (>= 0.11.19)
|
98
|
+
ruby_core_source (0.1.5)
|
99
|
+
archive-tar-minitar (>= 0.5.2)
|
84
100
|
sqlite3 (1.3.3)
|
85
101
|
thor (0.14.6)
|
86
102
|
treetop (1.4.9)
|
87
103
|
polyglot (>= 0.3.1)
|
88
|
-
tzinfo (0.3.
|
104
|
+
tzinfo (0.3.29)
|
89
105
|
|
90
106
|
PLATFORMS
|
91
107
|
ruby
|
@@ -93,6 +109,7 @@ PLATFORMS
|
|
93
109
|
DEPENDENCIES
|
94
110
|
fakeweb
|
95
111
|
nokogiri
|
96
|
-
rspec-rails (~> 2.
|
112
|
+
rspec-rails (~> 2.6)
|
113
|
+
ruby-debug19
|
97
114
|
sqlite3
|
98
115
|
swiss_knife!
|
@@ -1,44 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}.all?
|
23
|
-
end
|
24
|
-
|
25
|
-
def as(attribute)
|
26
|
-
@attribute = attribute
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
def description
|
31
|
-
"allow #{values.inspect} values for #{attribute.inspect} attribute"
|
32
|
-
end
|
33
|
-
|
34
|
-
def failure_message
|
35
|
-
"expected #{record.inspect} to allow each of #{values.inspect} as #{attribute.inspect} value"
|
36
|
-
end
|
37
|
-
|
38
|
-
def negative_failure_message
|
39
|
-
"expected #{record.inspect} to reject each of #{values.inspect} as #{attribute.inspect} value"
|
40
|
-
end
|
41
|
-
end
|
1
|
+
RSpec::Matchers.define :allow do |*values|
|
2
|
+
@failed = []
|
3
|
+
@values = values
|
4
|
+
|
5
|
+
match_for_should do |record|
|
6
|
+
@record = record
|
7
|
+
matches_against?(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
match_for_should_not do |record|
|
11
|
+
@record = record
|
12
|
+
matches_against?(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
def matches_against?(compare)
|
16
|
+
raise "The allow matcher requires an attribute; use subject.should allow(*values).as(attribute)" unless @attribute
|
17
|
+
|
18
|
+
@values.each do |value|
|
19
|
+
@record.__send__("#{@attribute}=", value)
|
20
|
+
@record.valid?
|
21
|
+
@failed << value if @record.errors[@attribute].empty? == compare
|
42
22
|
end
|
23
|
+
|
24
|
+
@failed.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
failure_message_for_should do |actual|
|
28
|
+
"expected #{@record.inspect} to allow each of #{@values.inspect} as #{@attribute.inspect} value (didn't accept #{@failed.inspect})"
|
29
|
+
end
|
30
|
+
|
31
|
+
failure_message_for_should_not do |actual|
|
32
|
+
"expected #{@record.inspect} to reject each of #{@values.inspect} as #{@attribute.inspect} value (accepted #{@failed.inspect})"
|
33
|
+
end
|
34
|
+
|
35
|
+
chain :as do |attribute|
|
36
|
+
@attribute = attribute
|
37
|
+
end
|
38
|
+
|
39
|
+
description do
|
40
|
+
"allow #{values.inspect} as #{@attribute}"
|
43
41
|
end
|
44
42
|
end
|
data/lib/swiss_knife/rspec.rb
CHANGED
@@ -2,4 +2,6 @@ require "swiss_knife/rspec/have_tag"
|
|
2
2
|
require "swiss_knife/rspec/have_text"
|
3
3
|
require "swiss_knife/rspec/allow"
|
4
4
|
|
5
|
-
RSpec.configure
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.include(SwissKnife::RSpec::Matchers)
|
7
|
+
end
|
data/lib/swiss_knife/version.rb
CHANGED
data/spec/support/config/boot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
ENV["BUNDLE_GEMFILE"] = File.expand_path(File.dirname(__FILE__) + "/../../../Gemfile")
|
2
2
|
require "bundler"
|
3
|
-
Bundler.setup
|
3
|
+
Bundler.setup(:default, :development, :test)
|
4
4
|
|
5
5
|
require "active_record/railtie"
|
6
6
|
require "action_controller/railtie"
|
@@ -8,7 +8,7 @@ require "action_controller/railtie"
|
|
8
8
|
# require "active_resource/railtie"
|
9
9
|
# require "rails/test_unit/railtie"
|
10
10
|
|
11
|
-
Bundler.require(:default)
|
11
|
+
Bundler.require(:default, :development, :test)
|
12
12
|
|
13
13
|
module SwissKnife
|
14
14
|
class Application < Rails::Application
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "allow matcher" do
|
4
4
|
it "allows blank values" do
|
5
5
|
klass = Class.new(ActiveRecord::Base) do
|
6
6
|
table_name "users"
|
7
7
|
end
|
8
8
|
|
9
9
|
record = klass.new
|
10
|
-
record.should
|
10
|
+
record.should allow_values(nil, "").as(:name)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "requires name to be set" do
|
@@ -17,7 +17,7 @@ describe SwissKnife::RSpec::Matchers::Allow do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
record = klass.new
|
20
|
-
record.should_not
|
20
|
+
record.should_not allow_values(nil, "").as(:name)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "allows values" do
|
@@ -26,6 +26,6 @@ describe SwissKnife::RSpec::Matchers::Allow do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
record = klass.new
|
29
|
-
record.should
|
29
|
+
record.should allow_values("John Doe", "Jane Doe").as(:name)
|
30
30
|
end
|
31
31
|
end
|
data/swiss_knife.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.add_dependency "rails", ">= 3.0.0"
|
21
|
-
s.add_development_dependency "rspec-rails", "~> 2.
|
21
|
+
s.add_development_dependency "rspec-rails", "~> 2.6"
|
22
22
|
s.add_development_dependency "nokogiri"
|
23
23
|
s.add_development_dependency "fakeweb"
|
24
24
|
s.add_development_dependency "sqlite3"
|
25
|
+
s.add_development_dependency "ruby-debug19"
|
25
26
|
end
|
metadata
CHANGED
@@ -1,82 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiss_knife
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Nando Vieira
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: rails
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2156871560 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 3.0.0
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rspec-rails
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *2156871560
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec-rails
|
27
|
+
requirement: &2156871060 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
29
|
+
requirements:
|
32
30
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 2.
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.6'
|
35
33
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: nokogiri
|
39
34
|
prerelease: false
|
40
|
-
|
35
|
+
version_requirements: *2156871060
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: nokogiri
|
38
|
+
requirement: &2156870680 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
46
44
|
type: :development
|
47
|
-
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: fakeweb
|
50
45
|
prerelease: false
|
51
|
-
|
46
|
+
version_requirements: *2156870680
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: fakeweb
|
49
|
+
requirement: &2156870220 !ruby/object:Gem::Requirement
|
52
50
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version:
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
57
55
|
type: :development
|
58
|
-
|
59
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2156870220
|
58
|
+
- !ruby/object:Gem::Dependency
|
60
59
|
name: sqlite3
|
60
|
+
requirement: &2156869800 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
61
67
|
prerelease: false
|
62
|
-
|
68
|
+
version_requirements: *2156869800
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby-debug19
|
71
|
+
requirement: &2156869380 !ruby/object:Gem::Requirement
|
63
72
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version:
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
68
77
|
type: :development
|
69
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2156869380
|
70
80
|
description: Several helpers for Rails 3
|
71
|
-
email:
|
81
|
+
email:
|
72
82
|
- fnando.vieira@gmail.com
|
73
83
|
executables: []
|
74
|
-
|
75
84
|
extensions: []
|
76
|
-
|
77
85
|
extra_rdoc_files: []
|
78
|
-
|
79
|
-
files:
|
86
|
+
files:
|
80
87
|
- .gitignore
|
81
88
|
- .rspec
|
82
89
|
- Gemfile
|
@@ -139,32 +146,35 @@ files:
|
|
139
146
|
- swiss_knife.gemspec
|
140
147
|
homepage: http://rubygems.org/gems/swiss_knife
|
141
148
|
licenses: []
|
142
|
-
|
143
149
|
post_install_message:
|
144
150
|
rdoc_options: []
|
145
|
-
|
146
|
-
require_paths:
|
151
|
+
require_paths:
|
147
152
|
- lib
|
148
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
154
|
none: false
|
150
|
-
requirements:
|
151
|
-
- -
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
version:
|
154
|
-
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
segments:
|
160
|
+
- 0
|
161
|
+
hash: -78419488599710419
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
163
|
none: false
|
156
|
-
requirements:
|
157
|
-
- -
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version:
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
hash: -78419488599710419
|
160
171
|
requirements: []
|
161
|
-
|
162
172
|
rubyforge_project:
|
163
|
-
rubygems_version: 1.8.
|
173
|
+
rubygems_version: 1.8.5
|
164
174
|
signing_key:
|
165
175
|
specification_version: 3
|
166
176
|
summary: Several helpers for Rails 3
|
167
|
-
test_files:
|
177
|
+
test_files:
|
168
178
|
- spec/controllers/application_controller_spec.rb
|
169
179
|
- spec/helpers/helpers_spec.rb
|
170
180
|
- spec/resources/assets.yml
|