rspec-rails-ext 1.7.1 → 1.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v1.8. Added ComparableArray
1
2
  v1.7.1. Added be_not_acceptable
2
3
  v1.7. Added use_layout matcher
3
4
  v1.6.3. Changed the output when status/locations don't match
data/Manifest CHANGED
@@ -7,5 +7,7 @@ lib/controller_example_group.rb
7
7
  lib/mocks.rb
8
8
  lib/responses.rb
9
9
  lib/rspec_rails_extensions.rb
10
+ lib/rspec_rails_extensions/comparable_array.rb
10
11
  lib/use_layout.rb
11
12
  rspec-rails-ext.gemspec
13
+ spec/lib/rspec_rails_extensions/comparable_array_spec.rb
data/README.rdoc CHANGED
@@ -79,4 +79,18 @@ These extra helpers let you write specifications in a more english-like manner.
79
79
  response.should render_template('thingies/show')
80
80
  end
81
81
 
82
- Isn't that lovely?
82
+ Isn't that lovely?
83
+
84
+ == ComparableArray
85
+
86
+ Ever wanted to check an array contains the right elements, but not cared about the order they were returned? Enter ComparableArray!
87
+
88
+ ComparableArray.new([:foo, :bar]).should =~ [:bar, :foo]
89
+
90
+ And there's even a shorthand for it
91
+
92
+ (~[:foo, :bar]).should =~ [:bar, :foo]
93
+
94
+ It's not required by default, you need to explicity require it.
95
+
96
+ require "rspec_rails_extensions/comparable_array"
@@ -0,0 +1,27 @@
1
+ class ComparableArray
2
+ attr_reader :array
3
+
4
+ def initialize array
5
+ @array = array.dup
6
+ end
7
+
8
+ def =~ other_array
9
+ array.size == other_array.size && array.all? {|e| other_array.include?(e) }
10
+ end
11
+
12
+ def method_missing method, *args
13
+ if array.respond_to?(method)
14
+ array.send(method, *args)
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ module FuzzyArrayExtension
23
+ def ~@
24
+ ComparableArray.new(self)
25
+ end
26
+ end
27
+ Array.send(:include, FuzzyArrayExtension)
@@ -2,27 +2,27 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rspec-rails-ext}
5
- s.version = "1.7.1"
5
+ s.version = "1.8"
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, Caius Durling"]
9
- s.date = %q{2009-11-10}
9
+ s.date = %q{2010-08-10}
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", "README.rdoc", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "lib/use_layout.rb"]
13
- s.files = ["CHANGELOG", "LICENCE", "Manifest", "README.rdoc", "Rakefile", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "lib/use_layout.rb", "rspec-rails-ext.gemspec"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "lib/rspec_rails_extensions/comparable_array.rb", "lib/use_layout.rb"]
13
+ s.files = ["CHANGELOG", "LICENCE", "Manifest", "README.rdoc", "Rakefile", "lib/controller_example_group.rb", "lib/mocks.rb", "lib/responses.rb", "lib/rspec_rails_extensions.rb", "lib/rspec_rails_extensions/comparable_array.rb", "lib/use_layout.rb", "rspec-rails-ext.gemspec", "spec/lib/rspec_rails_extensions/comparable_array_spec.rb"]
14
14
  s.homepage = %q{http://github.com/brightbox/rspec-rails-extensions/tree/master}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rspec-rails-ext", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{rspec-rails-ext}
18
- s.rubygems_version = %q{1.3.5}
18
+ s.rubygems_version = %q{1.3.7}
19
19
  s.summary = %q{Helpers for prettying up your RSpec-Rails specifications}
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
23
  s.specification_version = 3
24
24
 
25
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
26
  else
27
27
  end
28
28
  else
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../../lib/rspec_rails_extensions/comparable_array.rb")
2
+
3
+ describe ComparableArray do
4
+ describe "#=~" do
5
+ before { @a = ComparableArray.new([:foo, :bar]) }
6
+ it "should match identical array" do
7
+ (@a =~ [:foo, :bar]).should == true
8
+ end
9
+ it "should match array with same elements in different order" do
10
+ (@a =~ [:bar, :foo]).should == true
11
+ end
12
+ it "should not match array with different number of elements" do
13
+ (@a =~ [:foo, :bar, :sed]).should == false
14
+ end
15
+ it "should not match array with same number of different elements" do
16
+ (@a =~ [:foo, :sed]).should == false
17
+ end
18
+ end
19
+ end
20
+
21
+ describe Array do
22
+ describe "~" do
23
+ it "should wrap self in ComparableArray" do
24
+ (~[]).should be_a_kind_of(ComparableArray)
25
+ (~[:foo]).should be_a_kind_of(ComparableArray)
26
+ (~[:foo]).array.should == [:foo]
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 8
9
+ version: "1.8"
5
10
  platform: ruby
6
11
  authors:
7
12
  - Rahoul Baruah, Caius Durling
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-10 00:00:00 +00:00
17
+ date: 2010-08-10 00:00:00 +01:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -26,6 +31,7 @@ extra_rdoc_files:
26
31
  - lib/mocks.rb
27
32
  - lib/responses.rb
28
33
  - lib/rspec_rails_extensions.rb
34
+ - lib/rspec_rails_extensions/comparable_array.rb
29
35
  - lib/use_layout.rb
30
36
  files:
31
37
  - CHANGELOG
@@ -37,8 +43,10 @@ files:
37
43
  - lib/mocks.rb
38
44
  - lib/responses.rb
39
45
  - lib/rspec_rails_extensions.rb
46
+ - lib/rspec_rails_extensions/comparable_array.rb
40
47
  - lib/use_layout.rb
41
48
  - rspec-rails-ext.gemspec
49
+ - spec/lib/rspec_rails_extensions/comparable_array_spec.rb
42
50
  has_rdoc: true
43
51
  homepage: http://github.com/brightbox/rspec-rails-extensions/tree/master
44
52
  licenses: []
@@ -54,21 +62,28 @@ rdoc_options:
54
62
  require_paths:
55
63
  - lib
56
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
57
66
  requirements:
58
67
  - - ">="
59
68
  - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
60
72
  version: "0"
61
- version:
62
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
63
75
  requirements:
64
76
  - - ">="
65
77
  - !ruby/object:Gem::Version
78
+ hash: 11
79
+ segments:
80
+ - 1
81
+ - 2
66
82
  version: "1.2"
67
- version:
68
83
  requirements: []
69
84
 
70
85
  rubyforge_project: rspec-rails-ext
71
- rubygems_version: 1.3.5
86
+ rubygems_version: 1.3.7
72
87
  signing_key:
73
88
  specification_version: 3
74
89
  summary: Helpers for prettying up your RSpec-Rails specifications