Skip to content

Commit 22430d8

Browse files
committed
Merge pull request eliotsykes#69 from leesmith/shoulda-matchers-3.0.0.rc1
Upgrade shoulda-matchers to 3.0.0.rc1
2 parents 5beb63e + 8d16a30 commit 22430d8

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ group :test do
3232
gem 'database_cleaner'
3333
gem 'email_spec'
3434
gem 'poltergeist' # helps with using PhantomJS headless browser in feature specs
35-
gem 'shoulda-matchers', require: false
35+
gem 'shoulda-matchers', '3.0.0.rc1'
3636
gem 'vcr'
3737
gem 'webmock'
3838
end

Gemfile.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ GEM
211211
multi_json (~> 1.0)
212212
rubyzip (~> 1.0)
213213
websocket (~> 1.0)
214-
shoulda-matchers (2.7.0)
215-
activesupport (>= 3.0.0)
214+
shoulda-matchers (3.0.0.rc1)
215+
activesupport (>= 4.0.0)
216216
slop (3.6.0)
217217
spring (1.2.0)
218218
spring-commands-rspec (1.0.4)
@@ -278,7 +278,7 @@ DEPENDENCIES
278278
rspec-rails (~> 3.2)
279279
sass-rails (~> 4.0)
280280
selenium-webdriver
281-
shoulda-matchers
281+
shoulda-matchers (= 3.0.0.rc1)
282282
spring
283283
spring-commands-rspec
284284
sqlite3
@@ -287,3 +287,6 @@ DEPENDENCIES
287287
vcr
288288
web-console (~> 2.0)
289289
webmock
290+
291+
BUNDLED WITH
292+
1.10.3

spec/models/subscription_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
context "columns" do
1212
it { should have_db_column(:email).of_type(:string).with_options(limit: 100, null: false) }
1313
it { should have_db_column(:confirmation_token).of_type(:string).with_options(limit: 100, null: false) }
14-
it { should have_db_column(:confirmed).of_type(:boolean).with_options(default: 'f', null: false) }
14+
it { should have_db_column(:confirmed).of_type(:boolean).with_options(default: false, null: false) }
1515
it { should have_db_column(:start_on).of_type(:date) }
1616
end
1717
end
18-
18+
1919
context "attributes" do
2020

2121
it "has email" do
@@ -50,7 +50,7 @@
5050
end
5151

5252
context "validation" do
53-
53+
5454
before do
5555
@subscription = Subscription.new(confirmation_token: "token", email: "[email protected]")
5656
end
@@ -77,7 +77,7 @@
7777
end
7878

7979
context "scopes" do
80-
80+
8181
describe ".confirmation_overdue" do
8282

8383
before do
@@ -86,7 +86,7 @@
8686
end
8787

8888
after { travel_back }
89-
89+
9090
it "returns unconfirmed subscriptions of age more than 3 days" do
9191
overdue = create(:subscription, confirmed: false, created_at: (3.days + 1.second).ago)
9292
expect(Subscription.confirmation_overdue).to match_array [overdue]
@@ -107,7 +107,7 @@
107107
end
108108

109109
describe "#to_param" do
110-
110+
111111
it "uses confirmation_token as the default identifier for routes" do
112112
subscription = Subscription.new(confirmation_token: "hello-im-a-token-123")
113113
expect(subscription.to_param).to eq("hello-im-a-token-123")
@@ -116,7 +116,7 @@
116116
end
117117

118118
describe ".create_and_request_confirmation(params)" do
119-
119+
120120
it "creates an unconfirmed subscription with the given params" do
121121
params = { email: "[email protected]", start_on: "2015-01-31" }
122122
Subscription.create_and_request_confirmation(params)
@@ -132,15 +132,15 @@
132132
expect(::SecureRandom).to receive(:hex).with(32).and_call_original
133133
subscription = Subscription.create_and_request_confirmation(email: "[email protected]")
134134
subscription.reload
135-
135+
136136
expect(subscription.confirmation_token).to match(/\A[a-z0-9]{64}\z/)
137137
end
138138

139139
it "emails a confirmation request" do
140140
expect(SubscriptionMailer)
141141
.to receive(:send_confirmation_request!)
142142
.with(Subscription)
143-
143+
144144
Subscription.create_and_request_confirmation(email: "[email protected]")
145145
end
146146

@@ -188,11 +188,11 @@
188188
end
189189

190190
describe ".confirm(confirmation_token)" do
191-
191+
192192
it "confirms the subscription matching the confirmation_token" do
193193
token = Subscription.generate_confirmation_token
194194
subscription = Subscription.create!(
195-
email: "[email protected]",
195+
196196
confirmation_token: token
197197
)
198198
expect(subscription.confirmed?).to eq(false)
@@ -206,7 +206,7 @@
206206

207207
it "gracefully handles confirming an already confirmed subscription" do
208208
subscription = Subscription.create!(
209-
email: "[email protected]",
209+
210210
confirmation_token: "xyz"
211211
)
212212
expect(subscription.confirmed?).to eq(false)

spec/models/user_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
RSpec.describe User, :type => :model do
44

5-
it { should validate_uniqueness_of(:email) }
5+
it { should validate_presence_of :email }
6+
it { should validate_presence_of :password }
7+
it { should validate_confirmation_of :password }
8+
it { should validate_uniqueness_of(:email).case_insensitive }
69

710
end

spec/rails_helper.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,20 @@
4949
# https://relishapp.com/rspec/rspec-rails/docs
5050
config.infer_spec_type_from_file_location!
5151
end
52+
53+
Shoulda::Matchers.configure do |config|
54+
config.integrate do |with|
55+
# Choose a test framework:
56+
with.test_framework :rspec
57+
# with.test_framework :minitest
58+
# with.test_framework :minitest_4
59+
# with.test_framework :test_unit
60+
61+
# Choose a library:
62+
# with.library :active_record
63+
# with.library :active_model
64+
# with.library :action_controller
65+
# Or, choose all of the above:
66+
with.library :rails
67+
end
68+
end

0 commit comments

Comments
 (0)