foreigner-matcher 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -1
- data/foreigner-matcher.gemspec +1 -1
- data/lib/foreigner-matcher/version.rb +1 -1
- data/spec/test_models/comment_spec.rb +4 -4
- data/spec/test_models/search_spec.rb +8 -8
- data/spec/test_models/special_user_record_spec.rb +8 -8
- data/spec/test_models/table_without_foreign_key_spec.rb +18 -0
- data/spec/test_models/user_login_spec.rb +4 -4
- data/spec/test_models/user_type_spec.rb +4 -4
- metadata +5 -5
data/README.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
# foreigner-matcher
|
2
2
|
|
3
|
-
RSpec matcher for the [Foreigner gem](https://github.com/matthuhiggins/foreigner).
|
3
|
+
RSpec matcher for the [Foreigner gem](https://github.com/matthuhiggins/foreigner), inspired by [Remarkable](https://github.com/remarkable/remarkable) ActiveRecord matchers.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
For installation with bundler, add the following to the approrpriate group in your Gemfile:
|
8
|
+
|
9
|
+
gem "foreigner-matcher"
|
10
|
+
|
11
|
+
For installation without bundler in Rails 2.3, add the following to your config/environments/test.rb:
|
12
|
+
|
13
|
+
config.gem "foreigner-matcher"
|
14
|
+
|
15
|
+
To install the gem the old fashioned way:
|
16
|
+
|
7
17
|
gem install foreigner-matcher
|
8
18
|
|
9
19
|
## Usage
|
data/foreigner-matcher.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{Rspec matcher for testing the presence of foreign keys generated by Foreigner}
|
13
13
|
s.description = %q{Adds rspec matcher to verify the presence of foreign keys generated by Foreigner in a table schema}
|
14
14
|
|
15
|
-
s.add_dependency "foreigner", "0.9.1"
|
15
|
+
s.add_dependency "foreigner", "~> 0.9.1"
|
16
16
|
|
17
17
|
s.rubyforge_project = "foreigner-matcher"
|
18
18
|
|
@@ -2,18 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Comment do
|
4
4
|
describe 'messages' do
|
5
|
-
it
|
5
|
+
it 'should contain a description' do
|
6
6
|
matcher = have_foreign_key_for(:users, :dependent => :delete)
|
7
|
-
matcher.description.should ==
|
7
|
+
matcher.description.should == 'have a foreign key for users with {:dependent=>:delete}'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should set failure_message_for_should message' do
|
11
11
|
matcher = have_foreign_key_for(:comments)
|
12
12
|
matcher.matches?(subject)
|
13
13
|
matcher.failure_message_for_should.should == "expected #{subject.connection.foreign_keys('comments')} to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('comments', 'comments', :primary_key => 'id', :column => 'comment_id', :name => 'comments_comment_id_fk')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
17
17
|
matcher = have_foreign_key_for(:users, :dependent => :delete)
|
18
18
|
matcher.matches?(subject)
|
19
19
|
matcher.failure_message_for_should_not.should == "expected #{subject.connection.foreign_keys('comments')} to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('comments', 'users', :primary_key => 'id', :column => 'user_id', :name => 'comments_user_id_fk', :dependent => :delete)}"
|
@@ -2,26 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Search do
|
4
4
|
describe 'messages' do
|
5
|
-
it
|
6
|
-
matcher = have_foreign_key_for(:users, :name =>
|
7
|
-
matcher.description.should ==
|
5
|
+
it 'should contain a description' do
|
6
|
+
matcher = have_foreign_key_for(:users, :name => 'user_search_special_fk', :dependent => :delete)
|
7
|
+
matcher.description.should == 'have a foreign key for users with {:dependent=>:delete, :name=>"user_search_special_fk"}'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should set failure_message_for_should message' do
|
11
11
|
matcher = have_foreign_key_for(:searches)
|
12
12
|
matcher.matches?(subject)
|
13
13
|
matcher.failure_message_for_should.should == "expected #{subject.connection.foreign_keys('searches')} to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('searches', 'searches', :primary_key => 'id', :column => 'search_id', :name => 'searches_search_id_fk')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
matcher = have_foreign_key_for(:users, :name =>
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
17
|
+
matcher = have_foreign_key_for(:users, :name => 'user_search_special_fk', :dependent => :delete)
|
18
18
|
matcher.matches?(subject)
|
19
19
|
matcher.failure_message_for_should_not.should == "expected #{subject.connection.foreign_keys('searches')} to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('searches', 'users', :primary_key => 'id', :column => 'user_id', :name => 'user_search_special_fk', :dependent => :delete)}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe 'matcher' do
|
24
|
-
it { should have_foreign_key_for(:user, :name =>
|
25
|
-
it { should have_foreign_key_for(:users, :name =>
|
24
|
+
it { should have_foreign_key_for(:user, :name => 'user_search_special_fk', :dependent => :delete) }
|
25
|
+
it { should have_foreign_key_for(:users, :name => 'user_search_special_fk', :dependent => :delete) }
|
26
26
|
end
|
27
27
|
end
|
@@ -2,26 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe SpecialUserRecord do
|
4
4
|
describe 'messages' do
|
5
|
-
it
|
6
|
-
matcher = have_foreign_key_for(:users, :column =>
|
7
|
-
matcher.description.should ==
|
5
|
+
it 'should contain a description' do
|
6
|
+
matcher = have_foreign_key_for(:users, :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete)
|
7
|
+
matcher.description.should == 'have a foreign key for users with {:column=>"special_user_id", :dependent=>:delete, :name=>"special_user_records_special_user_id_fk"}'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should set failure_message_for_should message' do
|
11
11
|
matcher = have_foreign_key_for(:special_user_records)
|
12
12
|
matcher.matches?(subject)
|
13
13
|
matcher.failure_message_for_should.should == "expected #{subject.connection.foreign_keys('special_user_records')} to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('special_user_records', 'special_user_records', :primary_key => 'id', :column => 'special_user_record_id', :name => 'special_user_records_special_user_record_id_fk')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
matcher = have_foreign_key_for(:users, :column =>
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
17
|
+
matcher = have_foreign_key_for(:users, :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete)
|
18
18
|
matcher.matches?(subject)
|
19
19
|
matcher.failure_message_for_should_not.should == "expected #{subject.connection.foreign_keys('special_user_records')} to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('special_user_records', 'users', :primary_key => 'id', :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete)}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe 'matcher' do
|
24
|
-
it { should have_foreign_key_for(:user, :column =>
|
25
|
-
it { should have_foreign_key_for(:users, :column =>
|
24
|
+
it { should have_foreign_key_for(:user, :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete) }
|
25
|
+
it { should have_foreign_key_for(:users, :column => 'special_user_id', :name => 'special_user_records_special_user_id_fk', :dependent => :delete) }
|
26
26
|
end
|
27
27
|
end
|
@@ -1,6 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe TableWithoutForeignKey do
|
4
|
+
describe 'messages' do
|
5
|
+
let(:matcher) { have_foreign_key_for(:users) }
|
6
|
+
|
7
|
+
it 'should contain a description' do
|
8
|
+
matcher.description.should == 'have a foreign key for users'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should set failure_message_for_should message' do
|
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')}"
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
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')}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
4
22
|
describe 'matcher' do
|
5
23
|
it { should_not have_foreign_key_for(:user) }
|
6
24
|
it { should_not have_foreign_key_for(:users) }
|
@@ -2,18 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe UserLogin do
|
4
4
|
describe 'messages' do
|
5
|
-
it
|
5
|
+
it 'should contain a description' do
|
6
6
|
matcher = have_foreign_key_for(:users, :dependent => :nullify)
|
7
|
-
matcher.description.should ==
|
7
|
+
matcher.description.should == 'have a foreign key for users with {:dependent=>:nullify}'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should set failure_message_for_should message' do
|
11
11
|
matcher = have_foreign_key_for(:user_logins)
|
12
12
|
matcher.matches?(subject)
|
13
13
|
matcher.failure_message_for_should.should == "expected #{subject.connection.foreign_keys('user_logins')} to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('user_logins', 'user_logins', :primary_key => 'id', :column => 'user_login_id', :name => 'user_logins_user_login_id_fk')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
17
17
|
matcher = have_foreign_key_for(:users, :dependent => :nullify)
|
18
18
|
matcher.matches?(subject)
|
19
19
|
matcher.failure_message_for_should_not.should == "expected #{subject.connection.foreign_keys('user_logins')} to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('user_logins', 'users', :primary_key => 'id', :column => 'user_id', :name => 'user_logins_user_id_fk', :dependent => :nullify)}"
|
@@ -2,18 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe UserType do
|
4
4
|
describe 'messages' do
|
5
|
-
it
|
5
|
+
it 'should contain a description' do
|
6
6
|
matcher = have_foreign_key_for(:users)
|
7
|
-
matcher.description.should ==
|
7
|
+
matcher.description.should == 'have a foreign key for users'
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'should set failure_message_for_should message' do
|
11
11
|
matcher = have_foreign_key_for(:user_types)
|
12
12
|
matcher.matches?(subject)
|
13
13
|
matcher.failure_message_for_should.should == "expected #{subject.connection.foreign_keys('user_types')} to include #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('user_types', 'user_types', :primary_key => 'id', :column => 'user_type_id', :name => 'user_types_user_type_id_fk')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should set failure_message_for_should_not message' do
|
17
17
|
matcher = have_foreign_key_for(:users)
|
18
18
|
matcher.matches?(subject)
|
19
19
|
matcher.failure_message_for_should_not.should == "expected #{subject.connection.foreign_keys('user_types')} to exclude #{Foreigner::ConnectionAdapters::ForeignKeyDefinition.new('user_types', 'users', :primary_key => 'id', :column => 'user_id', :name => 'user_types_user_id_fk')}"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreigner-matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cameron Dykes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-12 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
hash: 57
|
30
30
|
segments:
|