mjankowski-shoulda 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -90,19 +90,6 @@ Macros to test the most common controller patterns...
90
90
  end
91
91
  end
92
92
 
93
- Test entire controllers in a few lines...
94
-
95
- class PostsControllerTest < Test::Unit::TestCase
96
- should_be_restful do |resource|
97
- resource.parent = :user
98
-
99
- resource.create.params = { :title => "first post", :body => 'blah blah blah'}
100
- resource.update.params = { :title => "changed" }
101
- end
102
- end
103
-
104
- should_be_restful generates 40 tests on the fly, for both html and xml requests.
105
-
106
93
  === Helpful Assertions (ThoughtBot::Shoulda::Assertions)
107
94
 
108
95
  More to come here, but have fun with what's there.
@@ -66,7 +66,10 @@ module ThoughtBot # :nodoc:
66
66
  end
67
67
 
68
68
  def pretty_error_messages(obj)
69
- obj.errors.map { |a, m| "#{a} #{m} (#{obj.send(a).inspect})" }
69
+ obj.errors.map do |a, m|
70
+ msg = "#{a} #{m}"
71
+ msg << " (#{obj.send(a).inspect})" unless a.to_sym == :base
72
+ end
70
73
  end
71
74
 
72
75
  private
@@ -516,7 +516,7 @@ module ThoughtBot # :nodoc:
516
516
  assert reflection, "#{klass.name} does not have any relationship to #{association}"
517
517
  assert_equal :has_and_belongs_to_many, reflection.macro
518
518
  table = reflection.options[:join_table]
519
- assert ::ActiveRecord::Base.connection.tables.include?(table), "table #{table} doesn't exist"
519
+ assert ::ActiveRecord::Base.connection.tables.include?(table.to_s), "table #{table} doesn't exist"
520
520
  end
521
521
  end
522
522
  end
@@ -25,8 +25,10 @@ module ThoughtBot # :nodoc:
25
25
  collection = [collection] unless collection.is_a?(Array)
26
26
  msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}"
27
27
  case x
28
- when Regexp: assert(collection.detect { |e| e =~ x }, msg)
29
- else assert(collection.include?(x), msg)
28
+ when Regexp
29
+ assert(collection.detect { |e| e =~ x }, msg)
30
+ else
31
+ assert(collection.include?(x), msg)
30
32
  end
31
33
  end
32
34
 
@@ -36,8 +38,10 @@ module ThoughtBot # :nodoc:
36
38
  collection = [collection] unless collection.is_a?(Array)
37
39
  msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg
38
40
  case x
39
- when Regexp: assert(!collection.detect { |e| e =~ x }, msg)
40
- else assert(!collection.include?(x), msg)
41
+ when Regexp
42
+ assert(!collection.detect { |e| e =~ x }, msg)
43
+ else
44
+ assert(!collection.include?(x), msg)
41
45
  end
42
46
  end
43
47
  end
@@ -1,6 +1,6 @@
1
1
  module Thoughtbot # :nodoc:
2
2
  module Shoulda
3
- VERSION = '2.0.4'
3
+ VERSION = '2.0.5'
4
4
 
5
5
  class << self
6
6
  attr_accessor :contexts
@@ -100,7 +100,7 @@ module ThoughtBot # :nodoc:
100
100
  def should_not_set_the_flash
101
101
  should_set_the_flash_to nil
102
102
  end
103
-
103
+
104
104
  # Macro that creates a test asserting that filter_parameter_logging
105
105
  # is set for the specified keys
106
106
  #
@@ -227,9 +227,9 @@ module ThoughtBot # :nodoc:
227
227
  # should_render_with_layout 'special'
228
228
  def should_render_with_layout(expected_layout = 'application')
229
229
  if expected_layout
230
- should "render with #{expected_layout} layout" do
230
+ should "render with #{expected_layout.inspect} layout" do
231
231
  response_layout = @response.layout.blank? ? "" : @response.layout.split('/').last
232
- assert_equal expected_layout,
232
+ assert_equal expected_layout.to_s,
233
233
  response_layout,
234
234
  "Expected to render with layout #{expected_layout} but was rendered with #{response_layout}"
235
235
  end
@@ -288,7 +288,7 @@ module ThoughtBot # :nodoc:
288
288
  # should_route :edit, "/posts/1", :action => :show, :id => 1
289
289
  # should_route :put, "/posts/1", :action => :update, :id => 1
290
290
  # should_route :delete, "/posts/1", :action => :destroy, :id => 1
291
- # should_route :get, "/users/1/posts/1",
291
+ # should_route :get, "/users/1/posts/1",
292
292
  # :action => :show, :id => 1, :user_id => 1
293
293
  #
294
294
  def should_route(method, path, options)
@@ -11,7 +11,7 @@ module ThoughtBot # :nodoc:
11
11
  #
12
12
  # Example:
13
13
  #
14
- # context "Creating a post"
14
+ # context "Creating a post" do
15
15
  # setup { Post.create }
16
16
  # should_change "Post.count", :by => 1
17
17
  # end
@@ -26,8 +26,8 @@ module ThoughtBot # :nodoc:
26
26
  # Combinations of <tt>:by</tt>, <tt>:from</tt>, and <tt>:to</tt> are allowed:
27
27
  #
28
28
  # should_change "@post.title" # => assert the value changed in some way
29
- # should_change "@post.title" :from => "old" # => assert the value changed to anything other than "old"
30
- # should_change "@post.title" :to => "new" # => assert the value changed from anything other than "new"
29
+ # should_change "@post.title", :from => "old" # => assert the value changed to anything other than "old"
30
+ # should_change "@post.title", :to => "new" # => assert the value changed from anything other than "new"
31
31
  def should_change(expression, options = {})
32
32
  by, from, to = get_options!([options], :by, :from, :to)
33
33
  stmt = "change #{expression.inspect}"
@@ -53,7 +53,7 @@ module ThoughtBot # :nodoc:
53
53
  #
54
54
  # Example:
55
55
  #
56
- # context "Updating a post"
56
+ # context "Updating a post" do
57
57
  # setup { @post.update_attributes(:title => "new") }
58
58
  # should_not_change "Post.count"
59
59
  # end
@@ -93,6 +93,7 @@ class PostsControllerTest < Test::Unit::TestCase
93
93
  context "viewing a post on GET to #show" do
94
94
  setup { get :show, :user_id => users(:first), :id => posts(:first) }
95
95
  should_render_with_layout 'wide'
96
+ should_render_with_layout :wide
96
97
  end
97
98
 
98
99
  context "on GET to #new" do
@@ -1,5 +1,5 @@
1
1
  class Dog < ActiveRecord::Base
2
2
  belongs_to :user, :foreign_key => :owner_id
3
3
  belongs_to :address
4
- has_and_belongs_to_many :fleas
4
+ has_and_belongs_to_many :fleas, :join_table => :fleas
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjankowski-shoulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammer Saleh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-07 00:00:00 -07:00
12
+ date: 2008-10-15 00:00:00 -07:00
13
13
  default_executable: convert_to_should_syntax
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency