shoulda-matchers 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.travis.yml +13 -0
- data/Appraisals +4 -6
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +8 -5
- data/Gemfile.lock +77 -41
- data/NEWS.md +32 -0
- data/README.md +84 -0
- data/Rakefile +5 -36
- data/features/rails_integration.feature +88 -0
- data/features/step_definitions/rails_steps.rb +111 -0
- data/features/support/env.rb +5 -0
- data/gemfiles/3.0.gemfile +14 -0
- data/gemfiles/3.0.gemfile.lock +142 -0
- data/gemfiles/3.1.gemfile +16 -0
- data/gemfiles/3.1.gemfile.lock +164 -0
- data/lib/shoulda/matchers/action_controller/assign_to_matcher.rb +6 -9
- data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +1 -3
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +10 -6
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +1 -4
- data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +6 -6
- data/lib/shoulda/matchers/action_controller/respond_with_content_type_matcher.rb +11 -10
- data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +0 -2
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +17 -14
- data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +24 -16
- data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +52 -15
- data/lib/shoulda/matchers/action_mailer.rb +1 -1
- data/lib/shoulda/matchers/action_mailer/{have_sent_email.rb → have_sent_email_matcher.rb} +37 -21
- data/lib/shoulda/matchers/active_model.rb +1 -0
- data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +9 -10
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +60 -33
- data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +0 -1
- data/lib/shoulda/matchers/active_model/helpers.rb +13 -9
- data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +63 -0
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +38 -8
- data/lib/shoulda/matchers/active_model/validation_matcher.rb +1 -5
- data/lib/shoulda/matchers/active_record.rb +3 -1
- data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +127 -0
- data/lib/shoulda/matchers/active_record/association_matcher.rb +19 -7
- data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +20 -5
- data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +4 -10
- data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +3 -7
- data/lib/shoulda/matchers/active_record/query_the_database_matcher.rb +107 -0
- data/lib/shoulda/matchers/active_record/serialize_matcher.rb +111 -0
- data/lib/shoulda/matchers/integrations/rspec.rb +0 -1
- data/lib/shoulda/matchers/version.rb +1 -1
- data/shoulda-matchers.gemspec +30 -0
- data/spec/fixtures/addresses.yml +3 -0
- data/spec/fixtures/friendships.yml +0 -0
- data/spec/fixtures/posts.yml +5 -0
- data/spec/fixtures/products.yml +0 -0
- data/spec/fixtures/taggings.yml +0 -0
- data/spec/fixtures/tags.yml +9 -0
- data/spec/fixtures/users.yml +6 -0
- data/spec/shoulda/action_controller/assign_to_matcher_spec.rb +61 -0
- data/spec/shoulda/action_controller/filter_param_matcher_spec.rb +20 -0
- data/spec/shoulda/action_controller/redirect_to_matcher_spec.rb +40 -0
- data/spec/shoulda/action_controller/render_template_matcher_spec.rb +69 -0
- data/spec/shoulda/action_controller/render_with_layout_matcher_spec.rb +47 -0
- data/spec/shoulda/action_controller/respond_with_content_type_matcher_spec.rb +28 -0
- data/spec/shoulda/action_controller/respond_with_matcher_spec.rb +83 -0
- data/spec/shoulda/action_controller/route_matcher_spec.rb +65 -0
- data/spec/shoulda/action_controller/set_session_matcher_spec.rb +46 -0
- data/spec/shoulda/action_controller/set_the_flash_matcher_spec.rb +124 -0
- data/spec/shoulda/action_mailer/have_sent_email_spec.rb +293 -0
- data/spec/shoulda/active_model/allow_mass_assignment_of_matcher_spec.rb +95 -0
- data/spec/shoulda/active_model/allow_value_matcher_spec.rb +91 -0
- data/spec/shoulda/active_model/ensure_exclusion_of_matcher_spec.rb +57 -0
- data/spec/shoulda/active_model/ensure_inclusion_of_matcher_spec.rb +71 -0
- data/spec/shoulda/active_model/ensure_length_of_matcher_spec.rb +125 -0
- data/spec/shoulda/active_model/helpers_spec.rb +100 -0
- data/spec/shoulda/active_model/validate_acceptance_of_matcher_spec.rb +43 -0
- data/spec/shoulda/active_model/validate_confirmation_of_matcher_spec.rb +48 -0
- data/spec/shoulda/active_model/validate_format_of_matcher_spec.rb +38 -0
- data/spec/shoulda/active_model/validate_numericality_of_matcher_spec.rb +62 -0
- data/spec/shoulda/active_model/validate_presence_of_matcher_spec.rb +121 -0
- data/spec/shoulda/active_model/validate_uniqueness_of_matcher_spec.rb +143 -0
- data/spec/shoulda/active_record/accept_nested_attributes_for_matcher_spec.rb +84 -0
- data/spec/shoulda/active_record/association_matcher_spec.rb +449 -0
- data/spec/shoulda/active_record/have_db_column_matcher_spec.rb +185 -0
- data/spec/shoulda/active_record/have_db_index_matcher_spec.rb +88 -0
- data/spec/shoulda/active_record/have_readonly_attributes_matcher_spec.rb +46 -0
- data/spec/shoulda/active_record/query_the_database_matcher_spec.rb +45 -0
- data/spec/shoulda/active_record/serialize_matcher_spec.rb +81 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/model_builder.rb +149 -0
- metadata +211 -60
- data/CONTRIBUTION_GUIDELINES.rdoc +0 -10
- data/README.rdoc +0 -80
@@ -1,10 +0,0 @@
|
|
1
|
-
We're using GitHub[http://github.com/thoughtbot/shoulda/tree/master], and we've been getting any combination of github pull requests, tickets, patches, emails, etc. We need to normalize this workflow to make sure we don't miss any fixes.
|
2
|
-
|
3
|
-
* Make sure you're accessing the source from the {official repository}[http://github.com/thoughtbot/shoulda/tree/master].
|
4
|
-
* We prefer git branches over patches, but we can take either.
|
5
|
-
* If you're using git, please make a branch for each separate contribution. We can cherry pick your commits, but pulling from a branch is easier.
|
6
|
-
* If you're submitting patches, please cut each fix or feature into a separate patch.
|
7
|
-
* There should be an issue[http://github.com/thoughtbot/shoulda/issues] for any submission. If you've found a bug and want to fix it, open a new ticket at the same time.
|
8
|
-
* Please <b>don't send pull requests</b> Just update the issue with the url for your fix (or attach the patch) when it's ready. The github pull requests pretty much get dropped on the floor until someone with commit rights notices them in the mailbox.
|
9
|
-
* Contributions without tests won't be accepted. The file <tt>/test/README</tt> explains the testing system pretty thoroughly.
|
10
|
-
|
data/README.rdoc
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
= shoulda-matchers
|
2
|
-
|
3
|
-
{Official Documentation}[http://rubydoc.info/github/thoughtbot/shoulda-matchers/master/frames]
|
4
|
-
|
5
|
-
Test::Unit- and RSpec-compatible one-liners that test common Rails functionality.
|
6
|
-
These tests would otherwise be much longer, more complex, and error-prone.
|
7
|
-
|
8
|
-
Refer to the {shoulda}[https://github.com/thoughtbot/shoulda] gem if you want to know more
|
9
|
-
about using shoulda with Test::Unit.
|
10
|
-
|
11
|
-
Please report bugs on the {shoulda issue tracker}[https://github.com/thoughtbot/shoulda/issues].
|
12
|
-
|
13
|
-
=== ActiveRecord Matchers
|
14
|
-
|
15
|
-
Matchers to test associations:
|
16
|
-
|
17
|
-
describe Post do
|
18
|
-
it { should belong_to(:user) }
|
19
|
-
it { should have_many(:tags).through(:taggings) }
|
20
|
-
end
|
21
|
-
|
22
|
-
describe User do
|
23
|
-
it { should have_many(:posts) }
|
24
|
-
end
|
25
|
-
|
26
|
-
=== ActiveModel Matchers
|
27
|
-
|
28
|
-
Matchers to test validations and mass assignments:
|
29
|
-
|
30
|
-
describe Post do
|
31
|
-
it { should validate_uniqueness_of(:title) }
|
32
|
-
it { should validate_presence_of(:body).with_message(/wtf/) }
|
33
|
-
it { should validate_presence_of(:title) }
|
34
|
-
it { should validate_numericality_of(:user_id) }
|
35
|
-
end
|
36
|
-
|
37
|
-
describe User do
|
38
|
-
it { should_not allow_value("blah").for(:email) }
|
39
|
-
it { should allow_value("a@b.com").for(:email) }
|
40
|
-
it { should ensure_inclusion_of(:age).in_range(1..100) }
|
41
|
-
it { should_not allow_mass_assignment_of(:password) }
|
42
|
-
end
|
43
|
-
|
44
|
-
=== ActionController Matchers
|
45
|
-
|
46
|
-
Matchers to test common patterns:
|
47
|
-
|
48
|
-
describe PostsController, "#show" do
|
49
|
-
context "for a fictional user" do
|
50
|
-
before do
|
51
|
-
get :show, :id => 1
|
52
|
-
end
|
53
|
-
|
54
|
-
it { should assign_to(:user) }
|
55
|
-
it { should respond_with(:success) }
|
56
|
-
it { should render_template(:show) }
|
57
|
-
it { should_not set_the_flash }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
= Installation
|
62
|
-
|
63
|
-
In Rails 3 and Bundler, add the following to your Gemfile:
|
64
|
-
|
65
|
-
group :test do
|
66
|
-
gem "rspec-rails"
|
67
|
-
gem "shoulda-matchers"
|
68
|
-
end
|
69
|
-
|
70
|
-
Shoulda will automatically include matchers into the appropriate example groups.
|
71
|
-
|
72
|
-
= Credits
|
73
|
-
|
74
|
-
Shoulda is maintained and funded by {thoughtbot}[http://thoughtbot.com/community].
|
75
|
-
Thank you to all the {contributors}[https://github.com/thoughtbot/shoulda-matchers/contributors].
|
76
|
-
|
77
|
-
= License
|
78
|
-
|
79
|
-
Shoulda is Copyright © 2006-2010 thoughtbot, inc.
|
80
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|