gaku_testing 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8985d28e8b8e0b8c20ca27d04e7a5755b355c07e
4
+ data.tar.gz: 24add0f0aad3bd3cc5b840a0b257e04033dc272d
5
+ SHA512:
6
+ metadata.gz: 331cb59f49071dd77ae925b66c9bc5695080a4999b06e09c8fd6d2f3249e479b81eb115cfa06e3d5cec6656682e54385720482f43573f966a0bfbea6f1f75177
7
+ data.tar.gz: 78e6a5f7bb8dc696bec0ce6c8bab157cc8b969e288b2458d599564b52104343da95d0fdc7a26ac02087e8e1b0ae2767fb6cd1346198df58a235c5b4545d5ab45
@@ -0,0 +1,10 @@
1
+ require 'gaku/core'
2
+
3
+ module Gaku
4
+
5
+ module Testing
6
+ end
7
+
8
+ end
9
+
10
+ require 'gaku/testing/engine'
@@ -0,0 +1,10 @@
1
+ module Gaku
2
+ module Testing
3
+ class Engine < ::Rails::Engine
4
+ engine_name 'gaku_testing'
5
+
6
+ config.autoload_paths += %W(#{config.root}/lib)
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ require 'capybara'
2
+ require 'capybara/dsl'
3
+ require 'capybara/poltergeist'
4
+
5
+ Capybara.default_selector = :css
6
+ Capybara.default_wait_time = 5
7
+ Capybara.default_driver = :rack_test
8
+
9
+ Capybara.register_driver :poltergeist_debug do |app|
10
+ Capybara::Poltergeist::Driver.new(app, :inspector => true, js_errors: false)
11
+ end
12
+
13
+ if ENV['SELENIUM']
14
+ Capybara.javascript_driver = :selenium
15
+ elsif ENV['PHANTOM']
16
+ Capybara.javascript_driver = :poltergeist_debug
17
+ else
18
+ Capybara.javascript_driver = :poltergeist_debug
19
+ end
@@ -0,0 +1,159 @@
1
+ module Gaku::Testing::FeatureHelpers
2
+
3
+ @@resource = ''
4
+ @@resource_plural = ''
5
+
6
+ def set_resource(x)
7
+ @@resource = x
8
+ @@resource_plural = plural(x)
9
+ end
10
+
11
+ def get_resource
12
+ @@resource
13
+ end
14
+
15
+ def tab_link
16
+ "##{@@resource_plural}-tab-link"
17
+ end
18
+
19
+ def form
20
+ "#new-#{@@resource}"
21
+ end
22
+
23
+ def new_link
24
+ "#new-#{@@resource}-link"
25
+ end
26
+
27
+ def submit
28
+ "#submit-#{@@resource}-button"
29
+ end
30
+
31
+ def cancel_link
32
+ "#cancel-#{@@resource}-link"
33
+ end
34
+
35
+ def modal
36
+ '.modal'
37
+ end
38
+
39
+ def count_div
40
+ ".#{@@resource_plural}-count"
41
+ end
42
+
43
+ def table
44
+ "##{@@resource_plural}-index"
45
+ end
46
+
47
+ def table_rows
48
+ "##{@@resource_plural}-index tr"
49
+ end
50
+
51
+ def edit_link
52
+ '.edit-link'
53
+ end
54
+
55
+ def js_edit_link
56
+ '.js-edit-link'
57
+ end
58
+
59
+
60
+ def recovery_link
61
+ '.recovery-link'
62
+ end
63
+
64
+ def modal_delete_link
65
+ '.modal-delete-link'
66
+ end
67
+
68
+ def show_link
69
+ '.show-link'
70
+ end
71
+
72
+ def delete_link
73
+ '.delete-link'
74
+ end
75
+
76
+ def close
77
+ '.close'
78
+ end
79
+
80
+ def accept_alert
81
+ page.driver.browser.switch_to.alert.accept if Capybara.javascript_driver == :selenium
82
+ end
83
+
84
+ def size_of(selector)
85
+ page.all(selector).size
86
+ end
87
+
88
+ def visible?(selector)
89
+ find(selector).visible?
90
+ end
91
+
92
+ def invisible?(selector)
93
+ page.has_no_selector?(selector)
94
+ end
95
+
96
+ def click(selector)
97
+ if Capybara.javascript_driver == :selenium
98
+ find(selector).click
99
+ else
100
+ find(selector).trigger('click')
101
+ end
102
+ end
103
+
104
+ def click_option(resource)
105
+ find("option[value='#{resource.id}']").click
106
+ end
107
+
108
+ def ensure_delete_is_working
109
+ within(table) { click delete_link }
110
+ accept_alert
111
+ end
112
+
113
+ def wait_for_ready
114
+ page.has_no_selector?('.nprogress-busy')
115
+ end
116
+
117
+ def wait_for_ajax(timeout = Capybara.default_wait_time)
118
+ Timeout.timeout(timeout) do
119
+ active = page.evaluate_script('jQuery.active')
120
+ until active == 0
121
+ active = page.evaluate_script('jQuery.active')
122
+ end
123
+ end
124
+ end
125
+
126
+ def has_validations?
127
+ click submit
128
+ page.has_content? "can't be blank"
129
+ end
130
+
131
+ def count?(count)
132
+ within(count_div) { page.has_content? count }
133
+ end
134
+
135
+ def check_path(current_url,expected_path)
136
+ uri = URI.parse(current_url)
137
+ "#{uri.path}?#{uri.query}".should == expected_path
138
+ end
139
+
140
+ def picture_path
141
+ Rails.root + '../../../core/spec/support/120x120.jpg'
142
+ end
143
+
144
+ private
145
+
146
+ def plural(text)
147
+ a = []
148
+ a = text.split('-')
149
+ p = a.last.pluralize
150
+ result = a[0..-2] << p
151
+ result * '-'
152
+ end
153
+
154
+ end
155
+
156
+ RSpec.configure do |config|
157
+ config.include Gaku::Testing::FeatureHelpers, type: :feature
158
+ end
159
+
@@ -0,0 +1,35 @@
1
+ module Gaku::Testing::FlashHelpers
2
+
3
+ def flash?(text)
4
+ page.should have_selector('#notice', text: text)
5
+ end
6
+
7
+ def flash_created?
8
+ flash? 'successfully created'
9
+ end
10
+
11
+ def flash_updated?
12
+ flash? 'successfully updated'
13
+ end
14
+
15
+ def flash_destroyed?
16
+ flash? 'successfully destroyed'
17
+ end
18
+
19
+ def flash_recovered?
20
+ flash? 'successfully recovered'
21
+ end
22
+
23
+ def flash_uploaded?
24
+ flash? 'successfully uploaded'
25
+ end
26
+
27
+ def flash_error_for(field)
28
+ page.should have_selector("div.#{field}formError")
29
+ end
30
+
31
+ end
32
+
33
+ RSpec.configure do |config|
34
+ config.include Gaku::Testing::FlashHelpers, type: :feature
35
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'spec_helper_base'
2
+ require 'rubygems'
3
+
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'database_cleaner'
7
+ require 'active_record/fixtures'
8
+ require 'factory_girl_rails'
9
+ require 'ffaker'
10
+
11
+ require 'gaku/testing/env'
12
+ require 'gaku/testing/factories'
13
+ require 'gaku/testing/feature_helpers'
14
+ require 'gaku/testing/flash_helpers'
15
+ require 'gaku/testing/auth_helpers'
16
+ require 'gaku/core/url_helpers'
17
+
18
+
19
+ #require 'gaku/testing/support/features'
20
+
21
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
22
+
23
+ RSpec.configure do |config|
24
+
25
+ config.before(:each) do
26
+ if example.metadata[:js]
27
+ DatabaseCleaner.strategy = :truncation
28
+ else
29
+ DatabaseCleaner.strategy = :transaction
30
+ end
31
+
32
+ DatabaseCleaner.start
33
+ end
34
+
35
+ config.after(:each) do
36
+ DatabaseCleaner.clean
37
+ end
38
+
39
+
40
+ config.use_transactional_fixtures = false
41
+ config.infer_base_class_for_anonymous_controllers = false
42
+
43
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
44
+ config.include FactoryGirl::Syntax::Methods
45
+ config.include Gaku::Core::UrlHelpers
46
+
47
+ end
@@ -0,0 +1,17 @@
1
+ require 'gaku/testing/deferred_garbage_collection'
2
+ require 'gaku/testing/coverage'
3
+
4
+ Rails.logger.level = 3
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ config.order = 'random'
9
+
10
+ config.before(:all) do
11
+ DeferredGarbageCollection.start
12
+ end
13
+
14
+ config.after(:all) do
15
+ DeferredGarbageCollection.reconsider
16
+ end
17
+ end
@@ -0,0 +1,45 @@
1
+ require_relative 'spec_helper_base'
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/rails/extensions'
5
+ require 'rspec/rails/adapters'
6
+ #require 'rspec/rails/mocks'
7
+ require 'rspec/rails/view_rendering'
8
+ require 'rspec/rails/example'
9
+
10
+ require 'shoulda-matchers'
11
+ require 'database_cleaner'
12
+ require 'factory_girl_rails'
13
+ require 'handy_controller_helpers'
14
+
15
+ require 'gaku/testing/factories'
16
+ require 'gaku/testing/controller_helpers'
17
+ require 'gaku/testing/auth_helpers'
18
+ require 'gaku/core/url_helpers'
19
+
20
+ #require 'gaku/testing/support/controllers'
21
+
22
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
23
+
24
+
25
+ RSpec.configure do |config|
26
+ config.before(:suite) do
27
+ DatabaseCleaner.strategy = :transaction
28
+ DatabaseCleaner.clean_with(:truncation)
29
+ end
30
+
31
+ config.before(:each) do
32
+ DatabaseCleaner.start
33
+ end
34
+
35
+ config.after(:each) do
36
+ DatabaseCleaner.clean
37
+ end
38
+
39
+ config.include FactoryGirl::Syntax::Methods
40
+ config.include Devise::TestHelpers, type: :controller
41
+ config.include HandyControllerHelpers::AllHelpers, type: :controller
42
+ config.include Gaku::Core::UrlHelpers
43
+
44
+ config.alias_it_should_behave_like_to :ensures, 'ensures'
45
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'spec_helper_base'
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/rails/extensions'
5
+ require 'rspec/rails/adapters'
6
+ require 'rspec/rails/matchers'
7
+ require 'rspec/rails/mocks'
8
+
9
+ require 'database_cleaner'
10
+ require 'factory_girl_rails'
11
+ require 'paperclip/matchers'
12
+ require 'ffaker'
13
+ require 'shoulda-matchers'
14
+
15
+ require 'gaku/testing/factories'
16
+
17
+ Dir["#{File.dirname(__FILE__)}/support/models/**/*.rb"].each { |f| require f }
18
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
19
+
20
+ RSpec.configure do |config|
21
+
22
+ config.before(:suite) do
23
+ DatabaseCleaner.strategy = :transaction
24
+ DatabaseCleaner.clean_with(:truncation)
25
+ end
26
+
27
+ config.before(:each) do
28
+ DatabaseCleaner.start
29
+ end
30
+
31
+ config.after(:each) do
32
+ DatabaseCleaner.clean
33
+ end
34
+
35
+ config.include FactoryGirl::Syntax::Methods
36
+ config.include Paperclip::Shoulda::Matchers
37
+
38
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'spec_helper_base'
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/rails/view_rendering'
5
+ require 'rspec/rails/adapters'
6
+ require 'rspec/rails/example'
@@ -0,0 +1 @@
1
+ require 'gaku/testing'
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gaku_testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Rei Kagetsuki
8
+ - Nakaya Yukiharu
9
+ - Vassil Kalkov
10
+ - Georgi Tapalilov
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2014-02-24 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: gaku_core
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.1.1
30
+ description: Testing helpers used in other engines
31
+ email: info@genshin.org
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - lib/gaku/testing.rb
37
+ - lib/gaku/testing/flash_helpers.rb
38
+ - lib/gaku/testing/spec_helpers/spec_helper_models.rb
39
+ - lib/gaku/testing/spec_helpers/spec_helper_routing.rb
40
+ - lib/gaku/testing/spec_helpers/spec_helper_controllers.rb
41
+ - lib/gaku/testing/spec_helpers/spec_helper.rb
42
+ - lib/gaku/testing/spec_helpers/spec_helper_base.rb
43
+ - lib/gaku/testing/engine.rb
44
+ - lib/gaku/testing/env.rb
45
+ - lib/gaku/testing/feature_helpers.rb
46
+ - lib/gaku_testing.rb
47
+ homepage: http://github.com/Genshin/gaku
48
+ licenses: []
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ version: 2.0.0
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.1.11
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: Shared testing helpers for GAKU Engine
70
+ test_files: []