-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to rspec3. Not strict depends on activemodel. Multiple activemod... #4
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ spec/reports | |
test/tmp | ||
test/version_tmp | ||
tmp | ||
.idea | ||
gemfiles/*.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
language: ruby | ||
rvm: | ||
- 2.1.0 | ||
rvm: | ||
- 2.0.0 | ||
- 1.9.3 | ||
- 2.1 | ||
- ruby-head | ||
- jruby-19mode # JRuby in 1.9 mode | ||
- rbx-2 | ||
gemfile: | ||
- gemfiles/activemodel_4.0.gemfile | ||
- gemfiles/activemodel_4.1.gemfile | ||
- gemfiles/activemodel_4.2.gemfile | ||
matrix: | ||
allow_failures: | ||
- rvm: ruby-head | ||
bundler_args: --without local_development |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
appraise "activemodel-4.0" do | ||
gem "activemodel", "~> 4.0.0" | ||
end | ||
|
||
appraise "activemodel-4.1" do | ||
gem "activemodel", "~> 4.1.0" | ||
end | ||
|
||
appraise "activemodel-4.2" do | ||
gem "activemodel", "~> 4.2.0.beta4" | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
require 'rspec/core/rake_task' | ||
|
||
Rake::TestTask.new do |t| | ||
t.pattern = 'spec/**/*_spec.rb' | ||
t.libs << 'spec' | ||
end | ||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
desc 'Run tests' | ||
task :default => :test | ||
|
||
desc 'Run console' | ||
task :console do | ||
require 'irb' | ||
require 'irb/completion' | ||
require 'bank/contact' | ||
ARGV.clear | ||
IRB.start | ||
end | ||
task default: :spec |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activemodel", "~> 4.0.0" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
gem "appraisal" | ||
end | ||
|
||
gemspec :path => "../" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activemodel", "~> 4.1.0" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
gem "appraisal" | ||
end | ||
|
||
gemspec :path => "../" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activemodel", "~> 4.2.0.beta4" | ||
|
||
group :test do | ||
gem "simplecov", ">= 0.9.0", :require => false | ||
gem "coveralls", :require => false | ||
end | ||
|
||
group :local_development do | ||
gem "terminal-notifier-guard", :require => false | ||
gem "guard-rspec", ">= 4.3.1", :require => false | ||
gem "guard-bundler", :require => false | ||
gem "guard-preek", :require => false | ||
gem "guard-rubocop", :require => false | ||
gem "guard-reek", :github => "pericles/guard-reek", :require => false | ||
gem "pry" | ||
gem "appraisal" | ||
end | ||
|
||
gemspec :path => "../" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,30 +22,28 @@ def persisted? | |
end | ||
end | ||
|
||
describe IbanValidator do | ||
before { | ||
@model = Company.new | ||
} | ||
RSpec.describe IbanValidator do | ||
let(:model) { ::Company.new } | ||
|
||
it 'should be valid' do | ||
@model.iban = 'FR1420041010050500013M02606' | ||
@model.valid?.must_equal true | ||
model.iban = 'FR1420041010050500013M02606' | ||
expect(model.valid?).to be_truthy | ||
end | ||
|
||
it 'should not be valid' do | ||
@model.iban = 'FR1420041010050500013' | ||
@model.valid?.must_equal false | ||
@model.errors[:iban].must_include 'is invalid' | ||
model.iban = 'FR1420041010050500013' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
expect(model.valid?).to be_falsey | ||
expect(model.errors[:iban]).to include 'is invalid' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it 'should not validate with nil value' do | ||
@model.iban.must_equal nil | ||
@model.valid?.must_equal false | ||
expect(model.iban).to be_nil | ||
expect(model.valid?).to be_falsey | ||
end | ||
|
||
it 'should not use the validator with option allow_nil: true' do | ||
@person = Person.new | ||
@person.iban.must_equal nil | ||
@person.valid?.must_equal true | ||
person = Person.new | ||
expect(person.iban).to be_nil | ||
expect(person.valid?).to be_truthy | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,56 @@ | ||
require 'spec_helper' | ||
|
||
describe Bank::BIC do | ||
before do | ||
@bic = Bank::BIC.new('ABNACHZ8XXX') | ||
end | ||
RSpec.describe Bank::BIC do | ||
let(:bic) { ::Bank::BIC.new('ABNACHZ8XXX') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
|
||
it 'returns the right bank code' do | ||
@bic.bank_code.must_equal 'ABNA' | ||
expect(bic.bank_code).to eq 'ABNA' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it 'returns the right country code' do | ||
@bic.country_code.must_equal 'CH' | ||
expect(bic.country_code).to eq 'CH' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it 'returns the right location code' do | ||
@bic.location_code.must_equal 'Z8' | ||
expect(bic.location_code).to eq 'Z8' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
it 'returns the right branch code' do | ||
@bic.branch_code.must_equal 'XXX' | ||
expect(bic.branch_code).to eq 'XXX' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
|
||
[8, 11].each do |len| | ||
describe 'x' * len do | ||
context 'x' * len do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
it 'has a valid length' do | ||
Bank::BIC.new('x' * len).valid_length?.must_equal true | ||
expect(::Bank::BIC.new('x' * len).valid_length?).to be_truthy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
end | ||
end | ||
|
||
1.upto(20) do |len| | ||
if len != 8 && len != 11 | ||
describe 'x' * len do | ||
context 'x' * len do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
it 'has a valid length' do | ||
Bank::BIC.new('x' * len).valid_length?.must_equal false | ||
expect(::Bank::BIC.new('x' * len).valid_length?).to be_falsey | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
end | ||
end | ||
end | ||
|
||
[ | ||
'UCJAES2MXXX', | ||
'ABAGATWWXXX', | ||
'UCJAES2MXXX' | ||
].each do |code| | ||
describe code do | ||
%w(UCJAES2MXXX ABAGATWWXXX UCJAES2MXXX).each do |code| | ||
context code do | ||
it 'has a valid format' do | ||
Bank::BIC.new(code).valid_format?.must_equal true | ||
expect(::Bank::BIC.new(code).valid_format?).to be_truthy | ||
end | ||
end | ||
end | ||
|
||
[ | ||
'12341234' | ||
].each do |code| | ||
describe code do | ||
context code do | ||
it 'has an invalid format' do | ||
Bank::BIC.new(code).valid_format?.must_equal false | ||
expect(::Bank::BIC.new(code).valid_format?).to be_falsey | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,29 +2,28 @@ | |
|
||
require 'bank/contact' | ||
|
||
describe Bank::Contact do | ||
before do | ||
@iban = Bank::IBAN.new('FR14 2004 1010 0505 0001 3M026 06') | ||
@bic = Bank::BIC.new('BYLADEM1203') | ||
@contact = Bank::Contact.new(@iban, @bic) | ||
end | ||
RSpec.describe Bank::Contact do | ||
let(:iban) { Bank::IBAN.new('FR14 2004 1010 0505 0001 3M026 06') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
let(:bic) { Bank::BIC.new('BYLADEM1203') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
let(:contact) { Bank::Contact.new(iban, bic) } | ||
|
||
it 'should validate' do | ||
@contact.valid?.must_equal true | ||
expect(contact.valid?).to be_truthy | ||
end | ||
|
||
it 'should have the right types' do | ||
@contact.iban.must_be_kind_of Bank::IBAN | ||
@contact.bic.must_be_kind_of Bank::BIC | ||
expect(contact.iban).to be_a Bank::IBAN | ||
expect(contact.bic).to be_a Bank::BIC | ||
end | ||
|
||
it 'should export to_h' do | ||
@contact.to_h.must_equal( | ||
iban: 'FR1420041010050500013M02606', | ||
bic: 'BYLADEM1203') | ||
expect(contact.to_h).to eq({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant curly braces around a hash parameter. |
||
iban: 'FR1420041010050500013M02606', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
bic: 'BYLADEM1203' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
}) | ||
end | ||
|
||
it 'should export to_a' do | ||
@contact.to_a.must_equal(['FR1420041010050500013M02606', 'BYLADEM1203']) | ||
expect(contact.to_a).to eq(['FR1420041010050500013M02606', 'BYLADEM1203']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.