prepare for RSpec 3.0
This commit is contained in:
parent
61a1efdfcf
commit
21838e9c84
7 changed files with 41 additions and 40 deletions
3
Gemfile
3
Gemfile
|
@ -92,8 +92,7 @@ group :test do
|
|||
gem 'database_cleaner'
|
||||
gem 'connection_pool'
|
||||
# need to include rspec components before i18n-spec or rake fails in test environment
|
||||
gem 'rspec-core', '= 2.14.8' # version until we're ready for rspec 3.0
|
||||
gem 'rspec-expectations'
|
||||
gem 'rspec-core', '~> 2.99' # almost ready for RSpec 3
|
||||
gem 'rspec-rerun'
|
||||
gem 'i18n-spec'
|
||||
# code coverage
|
||||
|
|
30
Gemfile.lock
30
Gemfile.lock
|
@ -172,7 +172,7 @@ GEM
|
|||
activesupport (>= 3.2, < 5)
|
||||
hike (1.2.3)
|
||||
i18n (0.6.11)
|
||||
i18n-spec (0.5.1)
|
||||
i18n-spec (0.5.2)
|
||||
iso
|
||||
inherited_resources (1.5.0)
|
||||
has_scope (~> 0.6.0.rc)
|
||||
|
@ -282,22 +282,25 @@ GEM
|
|||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rinku (1.7.3)
|
||||
rspec (2.14.1)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec-core (2.14.8)
|
||||
rspec-expectations (2.14.5)
|
||||
rspec (2.99.0)
|
||||
rspec-core (~> 2.99.0)
|
||||
rspec-expectations (~> 2.99.0)
|
||||
rspec-mocks (~> 2.99.0)
|
||||
rspec-collection_matchers (1.0.0)
|
||||
rspec-expectations (>= 2.99.0.beta1)
|
||||
rspec-core (2.99.1)
|
||||
rspec-expectations (2.99.2)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.6)
|
||||
rspec-rails (2.14.2)
|
||||
rspec-mocks (2.99.2)
|
||||
rspec-rails (2.99.0)
|
||||
actionpack (>= 3.0)
|
||||
activemodel (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec-collection_matchers
|
||||
rspec-core (~> 2.99.0)
|
||||
rspec-expectations (~> 2.99.0)
|
||||
rspec-mocks (~> 2.99.0)
|
||||
rspec-rerun (0.2.0)
|
||||
rspec (>= 2.11.0, < 3)
|
||||
ruby-prof (0.15.1)
|
||||
|
@ -441,8 +444,7 @@ DEPENDENCIES
|
|||
rails-settings-cached
|
||||
ransack
|
||||
resque
|
||||
rspec-core (= 2.14.8)
|
||||
rspec-expectations
|
||||
rspec-core (~> 2.99)
|
||||
rspec-rails
|
||||
rspec-rerun
|
||||
ruby-prof
|
||||
|
|
|
@ -57,7 +57,7 @@ describe 'settling an order', :type => :feature do
|
|||
page.driver.browser.switch_to.alert.accept
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
oa.reload
|
||||
expect(oa.quantity).to eq(4)
|
||||
expect(oa.tolerance).to eq(0)
|
||||
|
@ -74,7 +74,7 @@ describe 'settling an order', :type => :feature do
|
|||
page.driver.browser.switch_to.alert.accept
|
||||
end
|
||||
expect(page).to_not have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_false
|
||||
expect(OrderArticle.exists?(oa.id)).to be false
|
||||
end
|
||||
|
||||
it 'keeps ordered quantities when GroupOrderArticle is deleted from resulting order' do
|
||||
|
@ -84,8 +84,8 @@ describe 'settling an order', :type => :feature do
|
|||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be_true
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be true
|
||||
goa1.reload
|
||||
expect(goa1.result).to eq(0)
|
||||
expect(goa1.quantity).to eq(3)
|
||||
|
@ -100,8 +100,8 @@ describe 'settling an order', :type => :feature do
|
|||
click_link I18n.t('ui.delete')
|
||||
end
|
||||
expect(page).to_not have_selector("#group_order_article_#{goa1.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be_false
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
expect(GroupOrderArticle.exists?(goa1.id)).to be false
|
||||
end
|
||||
|
||||
it 'keeps product when amount is set to zero' do
|
||||
|
@ -116,7 +116,7 @@ describe 'settling an order', :type => :feature do
|
|||
# make sure it still works after reloading
|
||||
visit new_finance_order_path(order_id: order.id)
|
||||
expect(page).to have_selector("#order_article_#{oa.id}")
|
||||
expect(OrderArticle.exists?(oa.id)).to be_true
|
||||
expect(OrderArticle.exists?(oa.id)).to be true
|
||||
oa.reload
|
||||
expect(oa.units_to_order).to eq(0)
|
||||
end
|
||||
|
|
|
@ -30,9 +30,9 @@ describe Article do
|
|||
end
|
||||
|
||||
it 'knows when it is deleted' do
|
||||
expect(supplier.deleted?).to be_false
|
||||
expect(supplier.deleted?).to be false
|
||||
supplier.mark_as_deleted
|
||||
expect(supplier.deleted?).to be_true
|
||||
expect(supplier.deleted?).to be true
|
||||
end
|
||||
|
||||
it 'keeps a price history' do
|
||||
|
@ -70,7 +70,7 @@ describe Article do
|
|||
|
||||
it 'can find updates' do
|
||||
changed = article.shared_article_changed?
|
||||
expect(changed).to_not be_false
|
||||
expect(changed).to_not be_falsey
|
||||
expect(changed.length).to be > 1
|
||||
end
|
||||
|
||||
|
@ -81,12 +81,12 @@ describe Article do
|
|||
article.update_attributes updated_article.attributes.reject{|k,v| k=='id' or k=='type'}
|
||||
expect(article.name).to eq(shared_article.name)
|
||||
# now synchronising shouldn't change anything anymore
|
||||
expect(article.shared_article_changed?).to be_false
|
||||
expect(article.shared_article_changed?).to be_falsey
|
||||
end
|
||||
|
||||
it 'does not need to synchronise an imported article' do
|
||||
article = SharedArticle.find(shared_article.id).build_new_article(supplier)
|
||||
expect(article.shared_article_changed?).to be_false
|
||||
expect(article.shared_article_changed?).to be_falsey
|
||||
end
|
||||
|
||||
it 'adapts to foodcoop units when synchronising' do
|
||||
|
|
|
@ -38,7 +38,7 @@ describe GroupOrderArticle do
|
|||
it 'can unorder a product' do
|
||||
goa.update_quantities(rand(1..99), rand(0..99))
|
||||
goa.update_quantities(0, 0)
|
||||
expect(GroupOrderArticle.exists?(goa.id)).to be_false
|
||||
expect(GroupOrderArticle.exists?(goa.id)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,18 +16,18 @@ describe User do
|
|||
|
||||
describe 'does not have the role' do
|
||||
let(:user) { create :user }
|
||||
it 'admin' do expect(user.role_admin?).to be_false end
|
||||
it 'finance' do expect(user.role_finance?).to be_false end
|
||||
it 'article_meta' do expect(user.role_article_meta?).to be_false end
|
||||
it 'suppliers' do expect(user.role_suppliers?).to be_false end
|
||||
it 'orders' do expect(user.role_orders?).to be_false end
|
||||
it 'admin' do expect(user.role_admin?).to be_falsey end
|
||||
it 'finance' do expect(user.role_finance?).to be_falsey end
|
||||
it 'article_meta' do expect(user.role_article_meta?).to be_falsey end
|
||||
it 'suppliers' do expect(user.role_suppliers?).to be_falsey end
|
||||
it 'orders' do expect(user.role_orders?).to be_falsey end
|
||||
end
|
||||
|
||||
describe do
|
||||
let(:user) { create :user, password: 'blahblah' }
|
||||
|
||||
it 'can authenticate with correct password' do
|
||||
expect(User.authenticate(user.nick, 'blahblah')).to be_true
|
||||
expect(User.authenticate(user.nick, 'blahblah')).to be_truthy
|
||||
end
|
||||
it 'can not authenticate with incorrect password' do
|
||||
expect(User.authenticate(user.nick, 'foobar')).to be_nil
|
||||
|
@ -51,19 +51,19 @@ describe User do
|
|||
end
|
||||
|
||||
it 'can authenticate using email address' do
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_true
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_truthy
|
||||
end
|
||||
|
||||
it 'can authenticate when there is no nick' do
|
||||
user.nick = nil
|
||||
expect(user).to be_valid
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_true
|
||||
expect(User.authenticate(user.email, 'blahblah')).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe 'admin' do
|
||||
let(:user) { create :admin }
|
||||
it 'default admin role' do expect(user.role_admin?).to be_true end
|
||||
it 'default admin role' do expect(user.role_admin?).to be_truthy end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -28,10 +28,10 @@ RSpec.configure do |config|
|
|||
#config.use_transactional_fixtures = true
|
||||
# We use capybara with selenium, and need database_cleaner
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.strategy = (example.metadata[:js] ? :truncation : :transaction)
|
||||
DatabaseCleaner.strategy = (RSpec.current_example.metadata[:js] ? :truncation : :transaction)
|
||||
DatabaseCleaner.start
|
||||
# maximise window so that buttons can be found on popups
|
||||
example.metadata[:js] and page.driver.browser.manage.window.maximize
|
||||
RSpec.current_example.metadata[:js] and page.driver.browser.manage.window.maximize
|
||||
end
|
||||
config.after(:each) do
|
||||
DatabaseCleaner.clean
|
||||
|
|
Loading…
Reference in a new issue