effective_test_bot 0.0.10 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -30
  3. data/lib/effective_test_bot/engine.rb +10 -1
  4. data/lib/effective_test_bot/version.rb +2 -1
  5. data/lib/generators/effective_test_bot/install_generator.rb +1 -20
  6. data/lib/generators/templates/effective_test_bot.rb +3 -1
  7. data/lib/generators/templates/{minitest/test_helper.rb → test_helper.rb} +9 -5
  8. data/lib/tasks/effective_test_bot_tasks.rake +4 -22
  9. data/test/concerns/acts_as_test_botable.rb +57 -0
  10. data/test/support/effective_test_bot_assertions.rb +26 -0
  11. data/{app/helpers/effective_test_bot_helper.rb → test/support/effective_test_bot_form_helper.rb} +14 -45
  12. data/test/support/effective_test_bot_login_helper.rb +31 -0
  13. data/test/support/effective_test_bot_test_helper.rb +18 -0
  14. data/test/test_bot/integration/devise_test.rb +51 -0
  15. data/test/test_bot/integration/minitest_test.rb +49 -59
  16. data/test/test_bot/models/user_test.rb +1 -1
  17. data/test/test_botable/crud_test.rb +181 -0
  18. metadata +24 -15
  19. data/lib/generators/templates/rspec/rails_helper.rb +0 -62
  20. data/lib/generators/templates/rspec/spec_helper.rb +0 -90
  21. data/spec/features/crud/crud_spec.rb +0 -50
  22. data/spec/features/devise/sign_in_spec.rb +0 -43
  23. data/spec/features/devise/sign_up_spec.rb +0 -29
  24. data/spec/features/home_page_spec.rb +0 -8
  25. data/spec/models/user_spec.rb +0 -19
  26. data/test/fixtures/users.yml +0 -3
  27. data/test/test_bot/integration/devise/sign_in_test.rb +0 -37
  28. data/test/test_bot/integration/devise/sign_up_test.rb +0 -25
  29. data/test/test_bot/models/database_test.rb +0 -24
@@ -1,62 +0,0 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV['RAILS_ENV'] ||= 'test'
3
- require 'spec_helper'
4
- require File.expand_path('../../config/environment', __FILE__)
5
- require 'rspec/rails'
6
-
7
- require 'capybara/rspec'
8
- require 'capybara/webkit'
9
- require 'capybara-screenshot/rspec'
10
-
11
- Capybara.default_driver = :webkit
12
- Capybara.javascript_driver = :webkit
13
- Capybara::Screenshot.prune_strategy = :keep_last_run
14
- Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
15
-
16
- # Add additional requires below this line. Rails is not loaded until this point!
17
-
18
- # Requires supporting ruby files with custom matchers and macros, etc, in
19
- # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
20
- # run as spec files by default. This means that files in spec/support that end
21
- # in _spec.rb will both be required and run as specs, causing the specs to be
22
- # run twice. It is recommended that you do not name files matching this glob to
23
- # end with _spec.rb. You can configure this pattern with the --pattern
24
- # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
25
- #
26
- # The following line is provided for convenience purposes. It has the downside
27
- # of increasing the boot-up time by auto-requiring all files in the support
28
- # directory. Alternatively, in the individual `*_spec.rb` files, manually
29
- # require only the support files necessary.
30
- #
31
- # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
32
-
33
- # Checks for pending migrations before tests are run.
34
- # If you are not using ActiveRecord, you can remove this line.
35
- ActiveRecord::Migration.maintain_test_schema!
36
-
37
- RSpec.configure do |config|
38
- config.include Capybara::DSL
39
-
40
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
41
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
42
-
43
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
44
- # examples within a transaction, remove the following line or assign false
45
- # instead of true.
46
- config.use_transactional_fixtures = true
47
-
48
- # RSpec Rails can automatically mix in different behaviours to your tests
49
- # based on their file location, for example enabling you to call `get` and
50
- # `post` in specs under `spec/controllers`.
51
- #
52
- # You can disable this behaviour by removing the line below, and instead
53
- # explicitly tag your specs with their type, e.g.:
54
- #
55
- # RSpec.describe UsersController, :type => :controller do
56
- # # ...
57
- # end
58
- #
59
- # The different available types are documented in the features, such as in
60
- # https://relishapp.com/rspec/rspec-rails/docs
61
- config.infer_spec_type_from_file_location!
62
- end
@@ -1,90 +0,0 @@
1
- # This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
- #
15
- # The `.rspec` file also contains a few flags that are not defaults but that
16
- # users commonly want.
17
- #
18
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
-
20
- RSpec.configure do |config|
21
- config.files_or_directories_to_run = ['spec', '../effective_test_bot/spec']
22
-
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # The settings below are suggested to provide a good initial experience
47
- # with RSpec, but feel free to customize to your heart's content.
48
- =begin
49
- # These two settings work together to allow you to limit a spec run
50
- # to individual examples or groups you care about by tagging them with
51
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
52
- # get run.
53
- config.filter_run :focus
54
- config.run_all_when_everything_filtered = true
55
-
56
- # Limits the available syntax to the non-monkey patched syntax that is
57
- # recommended. For more details, see:
58
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
59
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
60
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
61
- config.disable_monkey_patching!
62
-
63
- # Many RSpec users commonly either run the entire suite or an individual
64
- # file, and it's useful to allow more verbose output when running an
65
- # individual spec file.
66
- if config.files_to_run.one?
67
- # Use the documentation formatter for detailed output,
68
- # unless a formatter has already been configured
69
- # (e.g. via a command-line flag).
70
- config.default_formatter = 'doc'
71
- end
72
-
73
- # Print the 10 slowest examples and example groups at the
74
- # end of the spec run, to help surface which specs are running
75
- # particularly slow.
76
- config.profile_examples = 10
77
-
78
- # Run specs in random order to surface order dependencies. If you find an
79
- # order dependency and want to debug it, you can fix the order by providing
80
- # the seed, which is printed after each run.
81
- # --seed 1234
82
- config.order = :random
83
-
84
- # Seed global randomization in this process using the `--seed` CLI option.
85
- # Setting this allows you to use `--seed` to deterministically reproduce
86
- # test failures related to randomization by passing the same `--seed` value
87
- # as the one that triggered the failure.
88
- Kernel.srand config.seed
89
- =end
90
- end
@@ -1,50 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe 'CRUD Compliance Tests' do
4
- ['Clinic'].each do |resource|
5
- feature "#{resource} CRUD Compliance" do
6
- let(:obj) { resource.constantize.new() }
7
-
8
- scenario 'Has an empty index screen', :js => true do
9
- visit polymorphic_path(obj)
10
- page.save_screenshot('something.png')
11
-
12
- expect(page.status_code).to eq 200
13
- expect(page).to have_content 'There are no'
14
- end
15
-
16
- end
17
- end
18
- end
19
-
20
-
21
- # feature 'CRUD Compliance Test' do
22
- # [:clinic].each do |resource|
23
- # feature ''
24
- # end
25
- # end
26
-
27
-
28
- # RSpec.describe 'FactoryGirl' do
29
- # FactoryGirl.factories.map(&:name).each do |factory_name|
30
- # describe "#{ factory_name } factory" do
31
- # it 'should be valid' do
32
- # factory = FactoryGirl.build(factory_name)
33
- # if factory.respond_to?(:valid?)
34
- # expect(factory).to be_valid, -> { factory.errors.full_messages.join("\n") }
35
- # end
36
- # end
37
-
38
- # FactoryGirl.factories[factory_name].definition.defined_traits.map(&:name).each do |trait_name|
39
- # context "with trait #{ trait_name }" do
40
- # it 'should be valid' do
41
- # factory = FactoryGirl.build(factory_name, trait_name)
42
- # if factory.respond_to?(:valid?)
43
- # expect(factory).to be_valid, -> { factory.errors.full_messages.join("\n") }
44
- # end
45
- # end
46
- # end
47
- # end
48
- # end
49
- # end
50
- # end
@@ -1,43 +0,0 @@
1
- require 'rails_helper'
2
-
3
- if defined?(Devise) && defined?(User)
4
-
5
- feature 'Devise Sign In' do
6
- let(:user) do
7
- User.new(email: "user_#{Time.now.to_i}@example.com", password: '1234567890').tap { |u| u.save(validate: false) }
8
- end
9
-
10
- it 'allows a valid sign in' do
11
- visit new_user_session_path
12
-
13
- within('form#new_user') do
14
- fill_in 'user_email', with: user.email
15
- fill_in 'user_password', with: user.password
16
-
17
- find('input[type=submit]').click
18
- end
19
-
20
- expect(page.status_code).to eq 200
21
- expect(page).to have_content I18n.t('devise.sessions.signed_in')
22
-
23
- existing_user = User.find_by_email(user.email)
24
- expect(existing_user.sign_in_count).to eq 1
25
- end
26
-
27
- it 'prevents sign in when provided an invalid password' do
28
- visit new_user_session_path
29
-
30
- within('form#new_user') do
31
- fill_in 'user_email', with: user.email
32
- fill_in 'user_password', with: 'invalid_password'
33
-
34
- find('input[type=submit]').click
35
- end
36
-
37
- expect(page.status_code).to eq 200
38
- expect(page).to have_content I18n.t('devise.failure.invalid', authentication_keys: Devise.authentication_keys.join(', '))
39
- end
40
-
41
- end
42
-
43
- end # /defined?(Devise)
@@ -1,29 +0,0 @@
1
- require 'rails_helper'
2
-
3
- if defined?(Devise) && defined?(User)
4
-
5
- feature 'Devise Sign Up' do
6
- let(:email) { "user_#{Time.now.to_i}@example.com" }
7
- let(:password) { "pass_#{Time.now.to_i}" }
8
-
9
- it 'allows a valid sign up' do
10
- visit new_user_registration_path
11
-
12
- within('form#new_user') do
13
- fill_in 'user_email', with: email
14
- fill_in 'user_password', with: password
15
- fill_in 'user_password_confirmation', with: password
16
-
17
- find('input[type=submit]').click
18
- end
19
-
20
- expect(page.status_code).to eq 200
21
- expect(page).to have_content I18n.t('devise.registrations.signed_up')
22
-
23
- user = User.find_by_email(email)
24
- expect(user.present?).to eq true
25
- expect(user.valid?).to eq true
26
- end
27
- end
28
-
29
- end # /defined?(Devise)
@@ -1,8 +0,0 @@
1
- require 'rails_helper'
2
-
3
- feature 'Home Page' do
4
- it 'loads successfully' do
5
- visit root_url
6
- expect(page.status_code).to eq 200
7
- end
8
- end
@@ -1,19 +0,0 @@
1
- require 'rails_helper'
2
-
3
- if defined?(Devise) && defined?(User)
4
-
5
- describe User, type: :model do
6
- let(:user) { User.new() }
7
-
8
- it { should validate_presence_of(:email) }
9
- it { should validate_presence_of(:password) }
10
- it { should validate_presence_of(:encrypted_password) }
11
-
12
- it 'fails validation when password and password_confirmation are different' do
13
- user.password = '123456789'
14
- user.password_confirmation = '987654321'
15
- expect(user.valid?).to eq false
16
- end
17
- end
18
-
19
- end # /defined?(Devise) && defined?(User)
@@ -1,3 +0,0 @@
1
- normal:
2
- email: 'normal@agilestyle.com'
3
- encrypted_password: <%= puts "FIXTURES RUN"; Devise::Encryptor.digest(User, 'password') %>
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
-
3
- if defined?(Devise) && defined?(User)
4
- module TestBot
5
- class SignInTest < ActionDispatch::IntegrationTest
6
- let(:user) { users(:normal) }
7
-
8
- test 'valid sign in' do
9
- visit new_user_session_path
10
-
11
- within('form#new_user') do
12
- fill_in 'user_email', with: user.email
13
- fill_in 'user_password', with: 'password'
14
- find('input[type=submit]').click
15
- end
16
-
17
- assert_equal 200, page.status_code
18
- assert_content I18n.t('devise.sessions.signed_in')
19
-
20
- assert_equal 1, User.find_by_email(user.email).sign_in_count
21
- end
22
-
23
- test 'invalid sign in' do
24
- visit new_user_session_path
25
-
26
- within('form#new_user') do
27
- fill_in 'user_email', with: user.email
28
- fill_in 'user_password', with: 'not-correct-password'
29
- find('input[type=submit]').click
30
- end
31
-
32
- assert_equal 200, page.status_code
33
- assert_content I18n.t('devise.failure.invalid', authentication_keys: Devise.authentication_keys.join(', '))
34
- end
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
-
3
- if defined?(Devise) && defined?(User)
4
- module TestBot
5
- class SignUpTest < ActionDispatch::IntegrationTest
6
- let(:user) { users(:normal) }
7
-
8
- test 'valid sign up' do
9
- visit new_user_registration_path
10
-
11
- email = Faker::Internet.email
12
- password = Faker::Internet.password
13
-
14
- within('form#new_user') do
15
- fill_form(:email => email, :password => password, :password_confirmation => password)
16
- submit_form
17
- end
18
-
19
- assert_equal page.status_code, 200
20
- assert_content I18n.t('devise.registrations.signed_up')
21
- assert User.find_by_email(email).present?
22
- end
23
- end
24
- end
25
- end
@@ -1,24 +0,0 @@
1
- require 'test_helper'
2
-
3
- # module TestBot
4
- # class DatabaseTest < ActiveSupport::TestCase
5
- # test 'should be 1 user record available' do
6
- # assert_equal 1, User.count
7
- # end
8
-
9
- # test 'should be 0 user records available after delete' do
10
- # User.destroy_all
11
- # assert_equal 0, User.count
12
- # end
13
-
14
- # test 'should be 2 user records if I create one' do
15
- # assert_equal 1, User.count
16
- # assert User.create(:email => 'someone@somehting.com', :password => '123456789', :password_confirmation => '123456789')
17
-
18
- # assert_equal 2, User.count
19
-
20
- # end
21
-
22
-
23
- # end
24
- # end