foreigner-matcher 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,7 +2,7 @@
2
2
  .bundle
3
3
  .rvmrc
4
4
  .rspec
5
- Gemfile.lock
6
5
  pkg/*
7
6
  doc/*
8
7
  spec/config/database.yml
8
+ *.swp
data/Gemfile CHANGED
@@ -8,9 +8,8 @@ group :development do
8
8
  end
9
9
 
10
10
  group :test do
11
- gem "rspec", "~> 2.5"
12
- gem "ruby-debug", "~> 0.10.4"
13
- gem "activerecord", ">= 2.3.11"
11
+ gem "rspec", "~> 2.6.0"
12
+ gem "activerecord", "~> 3.0.0"
14
13
  gem "mysql2", "~> 0.2.7"
15
14
  gem "mysql", "~> 2.8.1"
16
15
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ foreigner-matcher (0.0.2)
5
+ foreigner (~> 0.9.1)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (3.0.8)
11
+ activesupport (= 3.0.8)
12
+ builder (~> 2.1.2)
13
+ i18n (~> 0.5.0)
14
+ activerecord (3.0.8)
15
+ activemodel (= 3.0.8)
16
+ activesupport (= 3.0.8)
17
+ arel (~> 2.0.10)
18
+ tzinfo (~> 0.3.23)
19
+ activesupport (3.0.8)
20
+ arel (2.0.10)
21
+ builder (2.1.2)
22
+ diff-lcs (1.1.2)
23
+ foreigner (0.9.2)
24
+ i18n (0.5.0)
25
+ kramdown (0.13.3)
26
+ mysql (2.8.1)
27
+ mysql2 (0.2.10)
28
+ rspec (2.6.0)
29
+ rspec-core (~> 2.6.0)
30
+ rspec-expectations (~> 2.6.0)
31
+ rspec-mocks (~> 2.6.0)
32
+ rspec-core (2.6.4)
33
+ rspec-expectations (2.6.0)
34
+ diff-lcs (~> 1.1.2)
35
+ rspec-mocks (2.6.0)
36
+ tzinfo (0.3.28)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ activerecord (~> 3.0.0)
43
+ foreigner-matcher!
44
+ kramdown (~> 0.13.2)
45
+ mysql (~> 2.8.1)
46
+ mysql2 (~> 0.2.7)
47
+ rspec (~> 2.6.0)
data/README.md CHANGED
@@ -46,6 +46,13 @@ In addition to the table name, you can include any options that add_foreign_key
46
46
 
47
47
  These examples will also work passing <tt>:user</tt> as the table name. Why? The example has a <tt>belongs_to</tt> relationship, and my feeling is that it reads better to say "it should have foreign key for user". This is just my taste; use what makes sense to you!
48
48
 
49
+ ## My Testing Environment
50
+
51
+ Specs have been run with [Ruby 1.9.2p180](http://www.ruby-lang.org/) and [Ruby Enterprise Edition 2011.03](http://www.rubyenterpriseedition.com/) with the following combinations:
52
+
53
+ * ActiveRecord ~> 3.0.0, Rspec ~> 2.6.0
54
+ * ActiveRecord ~> 2.3.11, Rsepc ~> 1.3.2
55
+
49
56
  ## Copyright
50
57
 
51
58
  Copyright (c) 2011 Cameron Dykes. See LICENSE.txt for further details.
@@ -13,16 +13,16 @@ module ForeignerMatcher # :nodoc:
13
13
 
14
14
  def description
15
15
  desc = "have a foreign key for #{@parent}"
16
- desc += " with #{@options.inspect}" unless @options.empty?
16
+ desc += " with #{ordered_options}" unless @options.empty?
17
17
  desc
18
18
  end
19
19
 
20
20
  def failure_message_for_should
21
- "expected #{child_foreign_keys} to include #{foreign_key_definition}"
21
+ "expected #{display_child_foreign_keys} to include #{foreign_key_definition}"
22
22
  end
23
23
 
24
24
  def failure_message_for_should_not
25
- "expected #{child_foreign_keys} to exclude #{foreign_key_definition}"
25
+ "expected #{display_child_foreign_keys} to exclude #{foreign_key_definition}"
26
26
  end
27
27
 
28
28
  private
@@ -37,6 +37,19 @@ module ForeignerMatcher # :nodoc:
37
37
  def child_foreign_keys
38
38
  @child.connection.foreign_keys(@child.class.table_name)
39
39
  end
40
+
41
+ def ordered_options
42
+ ordered = @options.to_a.sort { |a,b| a[0].to_s <=> b[0].to_s }
43
+ display = "{"
44
+ display << ordered.collect { |opt| "#{opt[0].inspect}=>#{opt[1].inspect}" }.join(', ')
45
+ display << "}"
46
+ display
47
+ end
48
+
49
+ def display_child_foreign_keys
50
+ fks = child_foreign_keys
51
+ fks.empty? ? 'foreign keys' : fks
52
+ end
40
53
  end
41
54
 
42
55
  end
@@ -1,5 +1,5 @@
1
1
  module Foreigner
2
2
  module Matcher
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'ruby-debug'
2
1
  require 'yaml'
3
2
  require 'active_record'
4
3
  require 'foreigner-matcher'
@@ -10,12 +10,12 @@ describe TableWithoutForeignKey do
10
10
 
11
11
  it 'should set failure_message_for_should message' do
12
12
  matcher.matches?(subject)
13
- matcher.failure_message_for_should.should == "expected to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('table_without_foreign_keys', 'users', :primary_key => 'id', :column => 'user_id', :name => 'table_without_foreign_keys_user_id_fk')}"
13
+ matcher.failure_message_for_should.should == "expected foreign keys to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('table_without_foreign_keys', 'users', :primary_key => 'id', :column => 'user_id', :name => 'table_without_foreign_keys_user_id_fk')}"
14
14
  end
15
15
 
16
16
  it 'should set failure_message_for_should_not message' do
17
17
  matcher.matches?(subject)
18
- matcher.failure_message_for_should_not.should == "expected to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('table_without_foreign_keys', 'users', :primary_key => 'id', :column => 'user_id', :name => 'table_without_foreign_keys_user_id_fk')}"
18
+ matcher.failure_message_for_should_not.should == "expected foreign keys to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('table_without_foreign_keys', 'users', :primary_key => 'id', :column => 'user_id', :name => 'table_without_foreign_keys_user_id_fk')}"
19
19
  end
20
20
  end
21
21
 
metadata CHANGED
@@ -1,51 +1,39 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: foreigner-matcher
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Cameron Dykes
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-04-12 00:00:00 -05:00
12
+ date: 2011-06-17 00:00:00.000000000 -05:00
19
13
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: foreigner
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &14843940 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
19
+ requirements:
27
20
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 57
30
- segments:
31
- - 0
32
- - 9
33
- - 1
21
+ - !ruby/object:Gem::Version
34
22
  version: 0.9.1
35
23
  type: :runtime
36
- version_requirements: *id001
37
- description: Adds rspec matcher to verify the presence of foreign keys generated by Foreigner in a table schema
38
- email:
24
+ prerelease: false
25
+ version_requirements: *14843940
26
+ description: Adds rspec matcher to verify the presence of foreign keys generated by
27
+ Foreigner in a table schema
28
+ email:
39
29
  - yellow5c@gmail.com
40
30
  executables: []
41
-
42
31
  extensions: []
43
-
44
32
  extra_rdoc_files: []
45
-
46
- files:
33
+ files:
47
34
  - .gitignore
48
35
  - Gemfile
36
+ - Gemfile.lock
49
37
  - LICENSE.txt
50
38
  - README.md
51
39
  - Rakefile
@@ -65,45 +53,26 @@ files:
65
53
  has_rdoc: true
66
54
  homepage: https://github.com/yellow5/foreigner-matcher
67
55
  licenses: []
68
-
69
56
  post_install_message:
70
57
  rdoc_options: []
71
-
72
- require_paths:
58
+ require_paths:
73
59
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
60
+ required_ruby_version: !ruby/object:Gem::Requirement
75
61
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
81
- - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
67
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
90
- - 0
91
- version: "0"
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
92
72
  requirements: []
93
-
94
73
  rubyforge_project: foreigner-matcher
95
- rubygems_version: 1.5.2
74
+ rubygems_version: 1.6.2
96
75
  signing_key:
97
76
  specification_version: 3
98
77
  summary: Rspec matcher for testing the presence of foreign keys generated by Foreigner
99
- test_files:
100
- - spec/config/database.yml.example
101
- - spec/foreigner_matcher_spec.rb
102
- - spec/spec_helper.rb
103
- - spec/support/test_models.rb
104
- - spec/test_models/comment_spec.rb
105
- - spec/test_models/search_spec.rb
106
- - spec/test_models/special_user_record_spec.rb
107
- - spec/test_models/table_without_foreign_key_spec.rb
108
- - spec/test_models/user_login_spec.rb
109
- - spec/test_models/user_type_spec.rb
78
+ test_files: []