brightbox-rspec-rails-ext 1.004 → 1.6.0

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/CHANGELOG CHANGED
@@ -1,5 +1,7 @@
1
+ v1.6.0. Pushed a version that actually works (oops, sorry about that)
2
+ v1.005. Added invalid_model
1
3
  v1.004. Added `rake build`
2
4
  v1.003. Added mocks - prepare_for_errors_on
3
5
  v1.002. Bugfix
4
6
  v1.001. Bugfix
5
- v1.0. Initial release
7
+ v1.000. Initial release
data/Manifest CHANGED
@@ -7,3 +7,4 @@ LICENCE
7
7
  Manifest
8
8
  Rakefile
9
9
  README.rdoc
10
+ rspec-rails-ext.gemspec
data/README.rdoc CHANGED
@@ -14,9 +14,14 @@ Then, within your spec/spec_helper.rb
14
14
 
15
15
  If you try to call ActiveRecord::RecordInvalid.new(@my_object) where @my_object is a mock then your exception will not be raised; instead you get a cryptic error. This is because RecordInvalid expects to be able to call certain methods on your ActiveRecord model, which your mock isn't set up for. So instead, prepare your mock, like so:
16
16
 
17
- @thingy = mock_model Thingy
17
+ @thingy = mock_model Thingy, :field => 'value'
18
18
  prepare_for_errors_on @thingy
19
19
  raise ActiveRecord::RecordInvalid.new(@thingy)
20
+
21
+ There's also a short-cut method:
22
+
23
+ @thingy = invalid_model Thingy, :field => 'value'
24
+ raise ActiveRecord::RecordInvalid.new(@thingy)
20
25
 
21
26
  == Matchers
22
27
 
data/lib/mocks.rb CHANGED
@@ -1,17 +1,27 @@
1
1
  module Spec
2
-   module Rails
3
-     module Mocks
4
-       # Set up the given mock model in preparation for an ActiveRecord::RecordInvalid call
5
-       # For example:
6
-       # @user = mock_model User
7
-       # prepare_for_errors_on @user
8
-       # @user.should_receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(@user))
9
-       # If you tried this without the call to prepare_for_errors_on, the RecordInvalid exception would not be raised.
10
-       def prepare_for_errors_on model
11
-         errors = mock 'errors'
12
-         errors.should_receive(:full_messages).and_return([])
13
-         model.should_receive(:errors).and_return(errors)
14
-       end
15
-     end
16
-   end
2
+ module Rails
3
+ module Mocks
4
+ # Set up the given mock model in preparation for an ActiveRecord::RecordInvalid call
5
+ # For example:
6
+ # @user = mock_model User
7
+ # prepare_for_errors_on @user
8
+ # @user.should_receive(:save!).and_raise(ActiveRecord::RecordInvalid.new(@user))
9
+ # If you tried this without the call to prepare_for_errors_on, the RecordInvalid exception would not be raised.
10
+ def prepare_for_errors_on model
11
+ errors = mock 'errors'
12
+ errors.should_receive(:full_messages).and_return([])
13
+ model.should_receive(:errors).and_return(errors)
14
+ end
15
+
16
+ # Shortcut to create a mock model that is prepared for a ActiveRecord::RecordInvalid.new(@model) call
17
+ # Equivalent to:
18
+ # @model = mock_model Model, :some => :fields
19
+ # prepare_for_errors_on @model
20
+ def invalid_model class_name, stubs = {}
21
+ model = mock_model class_name, stubs
22
+ prepare_for_errors_on model
23
+ return model
24
+ end
25
+ end
26
+ end
17
27
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspec-rails-ext}
5
- s.version = "1.004"
5
+ s.version = "1.6.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rahoul Baruah and Caius Durling"]
9
- s.date = %q{2009-02-13}
9
+ s.date = %q{2009-02-16}
10
10
  s.description = %q{Helpers for prettying up your RSpec-Rails specifications}
11
11
  s.email = %q{support@brightbox.co.uk}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "README.rdoc"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox-rspec-rails-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.004"
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah and Caius Durling
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-13 00:00:00 -08:00
12
+ date: 2009-02-16 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: echoe
17
+ type: :development
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements: