brightbox-rspec-rails-ext 1.003 → 1.004

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,3 +1,4 @@
1
+ v1.004. Added `rake build`
1
2
  v1.003. Added mocks - prepare_for_errors_on
2
3
  v1.002. Bugfix
3
4
  v1.001. Bugfix
data/Manifest CHANGED
@@ -1,5 +1,6 @@
1
1
  CHANGELOG
2
2
  lib/controller_example_group.rb
3
+ lib/mocks.rb
3
4
  lib/responses.rb
4
5
  lib/rspec_rails_extensions.rb
5
6
  LICENCE
data/README.rdoc CHANGED
@@ -6,9 +6,9 @@ Some prettifications for RSpec Rails.
6
6
 
7
7
  sudo gem install brightbox-rspec-rails-ext --source=http://gems.github.com/
8
8
 
9
- Then, within your config/environment.rb:
9
+ Then, within your spec/spec_helper.rb
10
10
 
11
- config.gem 'brightbox-rspec-rails-ext', :lib => 'rspec_rails_extensions', :source => 'http://gems.github.com'
11
+ require 'rspec_rails_extensions'
12
12
 
13
13
  == ActiveRecord::RecordInvalid
14
14
 
@@ -22,23 +22,23 @@ If you try to call ActiveRecord::RecordInvalid.new(@my_object) where @my_object
22
22
 
23
23
  Some helpful matchers for testing HTTP statuses beyond the default be_success (200 OK)
24
24
 
25
- # looks for a 201 Created (useful for API CREATE calls)
26
- response.should be_successfully_created
27
-
28
- # expects a Location field with the given URL (useful for API CREATE calls)
29
- response.should point_to(url)
30
-
31
- # looks for a 422 response (invalid object)
32
- response.should be_unprocessable
33
-
34
- # looks for a 404
35
- response.should be_not_found
36
-
37
- # looks for a 401
38
- response.should be_unauthorised
39
-
40
- # looks for a 500
41
- response.should be_an_error
25
+ # looks for a 201 Created (useful for API CREATE calls)
26
+ response.should be_successfully_created
27
+
28
+ # expects a Location field with the given URL (useful for API CREATE calls)
29
+ response.should point_to(url)
30
+
31
+ # looks for a 422 response (invalid object)
32
+ response.should be_unprocessable
33
+
34
+ # looks for a 404
35
+ response.should be_not_found
36
+
37
+ # looks for a 401
38
+ response.should be_unauthorised
39
+
40
+ # looks for a 500
41
+ response.should be_an_error
42
42
 
43
43
  == Specifying your controllers
44
44
 
data/Rakefile CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'echoe'
2
2
  Echoe.new('rspec-rails-ext') do | gem |
3
- gem.author = 'Rahoul Baruah'
3
+ gem.author = 'Rahoul Baruah and Caius Durling'
4
4
  gem.email = 'support@brightbox.co.uk'
5
5
  gem.summary = 'Helpers for prettying up your RSpec-Rails specifications'
6
- gem.url = 'http://github.com/brightbox-rspec-rails-ext'
7
- end
6
+ gem.url = 'http://github.com/brightbox/rspec-rails-extensions/tree/master'
7
+ end
8
+
9
+ desc "Generates the manifest and the gemspec"
10
+ task :build => [:manifest, :build_gemspec] do
11
+ puts "Built!"
12
+ end
data/lib/mocks.rb ADDED
@@ -0,0 +1,17 @@
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
17
+ end
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspec-rails-ext}
5
- s.version = "1.003"
5
+ s.version = "1.004"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Rahoul Baruah"]
8
+ s.authors = ["Rahoul Baruah and Caius Durling"]
9
9
  s.date = %q{2009-02-13}
10
10
  s.description = %q{Helpers for prettying up your RSpec-Rails specifications}
11
11
  s.email = %q{support@brightbox.co.uk}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/controller_example_group.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "README.rdoc"]
13
- s.files = ["CHANGELOG", "lib/controller_example_group.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "LICENCE", "Manifest", "Rakefile", "README.rdoc", "rspec-rails-ext.gemspec"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "README.rdoc"]
13
+ s.files = ["CHANGELOG", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "LICENCE", "Manifest", "Rakefile", "README.rdoc", "rspec-rails-ext.gemspec"]
14
14
  s.has_rdoc = true
15
- s.homepage = %q{http://github.com/brightbox-rspec-rails-ext}
15
+ s.homepage = %q{http://github.com/brightbox/rspec-rails-extensions/tree/master}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rspec-rails-ext", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
18
18
  s.rubyforge_project = %q{rspec-rails-ext}
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox-rspec-rails-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.003"
4
+ version: "1.004"
5
5
  platform: ruby
6
6
  authors:
7
- - Rahoul Baruah
7
+ - Rahoul Baruah and Caius Durling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
@@ -30,12 +30,14 @@ extensions: []
30
30
  extra_rdoc_files:
31
31
  - CHANGELOG
32
32
  - lib/controller_example_group.rb
33
+ - lib/mocks.rb
33
34
  - lib/responses.rb
34
35
  - lib/rspec_rails_extensions.rb
35
36
  - README.rdoc
36
37
  files:
37
38
  - CHANGELOG
38
39
  - lib/controller_example_group.rb
40
+ - lib/mocks.rb
39
41
  - lib/responses.rb
40
42
  - lib/rspec_rails_extensions.rb
41
43
  - LICENCE
@@ -44,7 +46,7 @@ files:
44
46
  - README.rdoc
45
47
  - rspec-rails-ext.gemspec
46
48
  has_rdoc: true
47
- homepage: http://github.com/brightbox-rspec-rails-ext
49
+ homepage: http://github.com/brightbox/rspec-rails-extensions/tree/master
48
50
  post_install_message:
49
51
  rdoc_options:
50
52
  - --line-numbers