swiss_knife 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pkg
3
3
  .DS_Store
4
4
  spec/support/public/javascripts/*.js
5
5
  spec/support/public/stylesheets/*.css
6
+ *.log
data/Gemfile.lock CHANGED
@@ -1,39 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swiss_knife (0.1.6)
4
+ swiss_knife (0.1.7)
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.5)
12
- actionpack (= 3.0.5)
11
+ actionmailer (3.0.6)
12
+ actionpack (= 3.0.6)
13
13
  mail (~> 2.2.15)
14
- actionpack (3.0.5)
15
- activemodel (= 3.0.5)
16
- activesupport (= 3.0.5)
14
+ actionpack (3.0.6)
15
+ activemodel (= 3.0.6)
16
+ activesupport (= 3.0.6)
17
17
  builder (~> 2.1.2)
18
18
  erubis (~> 2.6.6)
19
- i18n (~> 0.4)
19
+ i18n (~> 0.5.0)
20
20
  rack (~> 1.2.1)
21
- rack-mount (~> 0.6.13)
21
+ rack-mount (~> 0.6.14)
22
22
  rack-test (~> 0.5.7)
23
23
  tzinfo (~> 0.3.23)
24
- activemodel (3.0.5)
25
- activesupport (= 3.0.5)
24
+ activemodel (3.0.6)
25
+ activesupport (= 3.0.6)
26
26
  builder (~> 2.1.2)
27
- i18n (~> 0.4)
28
- activerecord (3.0.5)
29
- activemodel (= 3.0.5)
30
- activesupport (= 3.0.5)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.6)
29
+ activemodel (= 3.0.6)
30
+ activesupport (= 3.0.6)
31
31
  arel (~> 2.0.2)
32
32
  tzinfo (~> 0.3.23)
33
- activeresource (3.0.5)
34
- activemodel (= 3.0.5)
35
- activesupport (= 3.0.5)
36
- activesupport (3.0.5)
33
+ activeresource (3.0.6)
34
+ activemodel (= 3.0.6)
35
+ activesupport (= 3.0.6)
36
+ activesupport (3.0.6)
37
37
  arel (2.0.9)
38
38
  builder (2.1.2)
39
39
  diff-lcs (1.1.2)
@@ -41,7 +41,7 @@ GEM
41
41
  abstract (>= 1.0.0)
42
42
  fakeweb (1.3.0)
43
43
  i18n (0.5.0)
44
- mail (2.2.15)
44
+ mail (2.2.16)
45
45
  activesupport (>= 2.3.6)
46
46
  i18n (>= 0.4.0)
47
47
  mime-types (~> 1.16)
@@ -49,22 +49,22 @@ GEM
49
49
  mime-types (1.16)
50
50
  nokogiri (1.4.4)
51
51
  polyglot (0.3.1)
52
- rack (1.2.1)
53
- rack-mount (0.6.13)
52
+ rack (1.2.2)
53
+ rack-mount (0.6.14)
54
54
  rack (>= 1.0.0)
55
55
  rack-test (0.5.7)
56
56
  rack (>= 1.0)
57
- rails (3.0.5)
58
- actionmailer (= 3.0.5)
59
- actionpack (= 3.0.5)
60
- activerecord (= 3.0.5)
61
- activeresource (= 3.0.5)
62
- activesupport (= 3.0.5)
57
+ rails (3.0.6)
58
+ actionmailer (= 3.0.6)
59
+ actionpack (= 3.0.6)
60
+ activerecord (= 3.0.6)
61
+ activeresource (= 3.0.6)
62
+ activesupport (= 3.0.6)
63
63
  bundler (~> 1.0)
64
- railties (= 3.0.5)
65
- railties (3.0.5)
66
- actionpack (= 3.0.5)
67
- activesupport (= 3.0.5)
64
+ railties (= 3.0.6)
65
+ railties (3.0.6)
66
+ actionpack (= 3.0.6)
67
+ activesupport (= 3.0.6)
68
68
  rake (>= 0.8.7)
69
69
  thor (~> 0.14.4)
70
70
  rake (0.8.7)
@@ -81,10 +81,11 @@ GEM
81
81
  activesupport (~> 3.0)
82
82
  railties (~> 3.0)
83
83
  rspec (~> 2.5.0)
84
+ sqlite3 (1.3.3)
84
85
  thor (0.14.6)
85
86
  treetop (1.4.9)
86
87
  polyglot (>= 0.3.1)
87
- tzinfo (0.3.24)
88
+ tzinfo (0.3.26)
88
89
 
89
90
  PLATFORMS
90
91
  ruby
@@ -93,4 +94,5 @@ DEPENDENCIES
93
94
  fakeweb
94
95
  nokogiri
95
96
  rspec-rails (~> 2.5.0)
97
+ sqlite3
96
98
  swiss_knife!
data/README.rdoc CHANGED
@@ -177,6 +177,11 @@ If you're inspecting some XML snippet, you can use the <tt>have_node</tt> matche
177
177
  string.should have_text("Lorem ipsum")
178
178
  string.should have_text(/Lorem ipsum/)
179
179
 
180
+ ==== allow
181
+
182
+ record.should allow("john@doe.com").as(:email)
183
+ record.should_not allow(nil, "").as(:email)
184
+
180
185
  == Maintainer
181
186
 
182
187
  * Nando Vieira (<http://simplesideias.com.br>)
@@ -0,0 +1,44 @@
1
+ module SwissKnife
2
+ module RSpec
3
+ module Matchers
4
+ def allow(value, *values)
5
+ Allow.new(value, *values)
6
+ end
7
+
8
+ class Allow
9
+ attr_reader :values, :attribute, :record
10
+
11
+ def initialize(*values)
12
+ @values = values
13
+ end
14
+
15
+ def matches?(record)
16
+ @record = record
17
+
18
+ values.collect {|value|
19
+ record.send("#{attribute}=", value)
20
+ record.valid?
21
+ record.errors[attribute].empty?
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
42
+ end
43
+ end
44
+ end
@@ -1,4 +1,5 @@
1
1
  require "swiss_knife/rspec/have_tag"
2
2
  require "swiss_knife/rspec/have_text"
3
+ require "swiss_knife/rspec/allow"
3
4
 
4
5
  RSpec.configure {|config| config.include(SwissKnife::RSpec::Matchers)} if defined?(RSpec)
@@ -2,7 +2,7 @@ module SwissKnife
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 6
5
+ PATCH = 7
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/spec/schema.rb ADDED
@@ -0,0 +1,5 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :users do |t|
3
+ t.string :name, :email
4
+ end
5
+ end
data/spec/spec_helper.rb CHANGED
@@ -13,14 +13,14 @@ FakeWeb.allow_net_connect = false
13
13
  # Load support files
14
14
  Dir[File.dirname(__FILE__) + "/support/rspec/**/*.rb"].each {|file| require file}
15
15
 
16
+ # Load database schema
17
+ load File.dirname(__FILE__) + "/schema.rb"
18
+
16
19
  # Restore default configuration
17
20
  RSpec.configure do |config|
18
- remote_static_files = proc do
21
+ config.around do
19
22
  Dir[Rails.root.join("public/javascripts/*.js")].each {|file| File.unlink(file)}
20
23
  Dir[Rails.root.join("public/stylesheets/*.css")].each {|file| File.unlink(file)}
21
24
  Dir[File.dirname(__FILE__) + "/resources/**/*_packaged.**"].each {|file| File.unlink(file)}
22
25
  end
23
-
24
- config.before(&remote_static_files)
25
- config.after(&remote_static_files)
26
26
  end
@@ -2,11 +2,11 @@ ENV["BUNDLE_GEMFILE"] = File.expand_path(File.dirname(__FILE__) + "/../../../Gem
2
2
  require "bundler"
3
3
  Bundler.setup
4
4
 
5
- # require "active_record/railtie"
5
+ require "active_record/railtie"
6
6
  require "action_controller/railtie"
7
- require "action_mailer/railtie"
8
- require "active_resource/railtie"
9
- require "rails/test_unit/railtie"
7
+ # require "action_mailer/railtie"
8
+ # require "active_resource/railtie"
9
+ # require "rails/test_unit/railtie"
10
10
 
11
11
  Bundler.require(:default)
12
12
 
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: ":memory:"
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe SwissKnife::RSpec::Matchers::Allow do
4
+ it "allows blank values" do
5
+ klass = Class.new(ActiveRecord::Base) do
6
+ table_name "users"
7
+ end
8
+
9
+ record = klass.new
10
+ record.should allow(nil, "").as(:name)
11
+ end
12
+
13
+ it "requires name to be set" do
14
+ klass = Class.new(ActiveRecord::Base) do
15
+ table_name "users"
16
+ validates_presence_of :name
17
+ end
18
+
19
+ record = klass.new
20
+ record.should_not allow(nil, "").as(:name)
21
+ end
22
+
23
+ it "allows values" do
24
+ klass = Class.new(ActiveRecord::Base) do
25
+ table_name "users"
26
+ end
27
+
28
+ record = klass.new
29
+ record.should allow("John Doe", "Jane Doe").as(:name)
30
+ end
31
+ end
data/swiss_knife.gemspec CHANGED
@@ -11,7 +11,6 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://rubygems.org/gems/swiss_knife"
12
12
  s.summary = "Several helpers for Rails 3"
13
13
  s.description = s.summary
14
- s.has_rdoc = true
15
14
 
16
15
  s.files = `git ls-files`.split("\n")
17
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -22,4 +21,5 @@ Gem::Specification.new do |s|
22
21
  s.add_development_dependency "rspec-rails", "~> 2.5.0"
23
22
  s.add_development_dependency "nokogiri"
24
23
  s.add_development_dependency "fakeweb"
24
+ s.add_development_dependency "sqlite3"
25
25
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: swiss_knife
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.6
5
+ version: 0.1.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nando Vieira
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-05 00:00:00 -03:00
14
- default_executable:
13
+ date: 2011-04-18 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rails
@@ -57,6 +56,17 @@ dependencies:
57
56
  version: "0"
58
57
  type: :development
59
58
  version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: sqlite3
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
60
70
  description: Several helpers for Rails 3
61
71
  email:
62
72
  - fnando.vieira@gmail.com
@@ -86,6 +96,7 @@ files:
86
96
  - lib/swiss_knife/railtie.rb
87
97
  - lib/swiss_knife/rake_tasks.rb
88
98
  - lib/swiss_knife/rspec.rb
99
+ - lib/swiss_knife/rspec/allow.rb
89
100
  - lib/swiss_knife/rspec/have_tag.rb
90
101
  - lib/swiss_knife/rspec/have_text.rb
91
102
  - lib/swiss_knife/support/remote_file.rb
@@ -106,11 +117,12 @@ files:
106
117
  - spec/resources/stylesheets/reset.css
107
118
  - spec/resources/stylesheets/ui/tab.css
108
119
  - spec/resources/stylesheets/ui/window.less
120
+ - spec/schema.rb
109
121
  - spec/spec_helper.rb
110
122
  - spec/support/app/controllers/application_controller.rb
111
123
  - spec/support/config/boot.rb
124
+ - spec/support/config/database.yml
112
125
  - spec/support/config/locales/en.yml
113
- - spec/support/log/test.log
114
126
  - spec/support/public/javascripts/.gitkeep
115
127
  - spec/support/public/stylesheets/.gitkeep
116
128
  - spec/support/rspec/remote_file_shared.rb
@@ -121,9 +133,9 @@ files:
121
133
  - spec/swiss_knife/jquery_spec.rb
122
134
  - spec/swiss_knife/jquery_ujs_spec.rb
123
135
  - spec/swiss_knife/modernizr_spec.rb
136
+ - spec/swiss_knife/rspec/allow_spec.rb
124
137
  - spec/swiss_knife/rspec/have_text_spec.rb
125
138
  - swiss_knife.gemspec
126
- has_rdoc: true
127
139
  homepage: http://rubygems.org/gems/swiss_knife
128
140
  licenses: []
129
141
 
@@ -147,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
159
  requirements: []
148
160
 
149
161
  rubyforge_project:
150
- rubygems_version: 1.6.0
162
+ rubygems_version: 1.7.2
151
163
  signing_key:
152
164
  specification_version: 3
153
165
  summary: Several helpers for Rails 3
@@ -166,11 +178,12 @@ test_files:
166
178
  - spec/resources/stylesheets/reset.css
167
179
  - spec/resources/stylesheets/ui/tab.css
168
180
  - spec/resources/stylesheets/ui/window.less
181
+ - spec/schema.rb
169
182
  - spec/spec_helper.rb
170
183
  - spec/support/app/controllers/application_controller.rb
171
184
  - spec/support/config/boot.rb
185
+ - spec/support/config/database.yml
172
186
  - spec/support/config/locales/en.yml
173
- - spec/support/log/test.log
174
187
  - spec/support/public/javascripts/.gitkeep
175
188
  - spec/support/public/stylesheets/.gitkeep
176
189
  - spec/support/rspec/remote_file_shared.rb
@@ -181,4 +194,5 @@ test_files:
181
194
  - spec/swiss_knife/jquery_spec.rb
182
195
  - spec/swiss_knife/jquery_ujs_spec.rb
183
196
  - spec/swiss_knife/modernizr_spec.rb
197
+ - spec/swiss_knife/rspec/allow_spec.rb
184
198
  - spec/swiss_knife/rspec/have_text_spec.rb
@@ -1,8 +0,0 @@
1
- Processing by StubResourcesController#index as HTML
2
- Completed in 15ms
3
- Processing by StubResourcesController#index as HTML
4
- Completed in 14ms
5
- Processing by StubResourcesController#index as HTML
6
- Completed in 50ms
7
- Processing by StubResourcesController#index as HTML
8
- Completed in 20ms