summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-28 13:37:19 +0000
committerRémy Coutable <remy@rymai.me>2016-10-28 13:37:19 +0000
commit2672f44e25b6b2638b850208a1ef4a97983f28ed (patch)
tree6e204d694ade9efb50dd47e171fb965309eba5fc /lib
parent4fd015183cdb280083384c69261c2ab5d475a54b (diff)
parentcd3c8e9b1279dce29c5283b54d9b3305be73110f (diff)
downloadgitlab-ce-2672f44e25b6b2638b850208a1ef4a97983f28ed.tar.gz
Merge branch 'clean-up-issue_spec.js' into 'master'
Replace static fixture by generated one in issue_spec.js ## What does this MR do? - clean up `issue_spec.js` - introduce an alternative approach to #19445 - rename `rake teaspoon` to `rake teaspoon:tests` - introduce `rake teaspoon:fixtures` which generates fixtures using RSpec - introduce `rake teaspoon` which runs `rake teaspoon:fixtures` and `rake teaspoon:tests` ## Why was this MR needed? - many duplications - missing existence checks - missing conditions - static fixtures don't match real views ## Reasoning I want to explain some of my decisions here, so that they stay visible for future discussions. ### Why not HAML? - same number of HAML templates as number of fixtures (many input files) - embedded logic less readable - can not be rendered by JavaScript (because of inline Ruby) ### Why RSpec? - real controllers for fixtures - spys available for mocking - easily report failed fixture generations ### Why not magic_lamp? (#19445) - introduces another dependency/tool - needs to run a server concurrently to teaspoon - makes it harder to use a JavaScript test runner - static HTML files serve faster See merge request !6059
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/teaspoon.rake23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/tasks/teaspoon.rake b/lib/tasks/teaspoon.rake
new file mode 100644
index 00000000000..156fa90537d
--- /dev/null
+++ b/lib/tasks/teaspoon.rake
@@ -0,0 +1,23 @@
+Rake::Task['teaspoon'].clear if Rake::Task.task_defined?('teaspoon')
+
+namespace :teaspoon do
+ desc 'GitLab | Teaspoon | Generate fixtures for JavaScript tests'
+ RSpec::Core::RakeTask.new(:fixtures) do |t|
+ ENV['NO_KNAPSACK'] = 'true'
+ t.pattern = 'spec/javascripts/fixtures/*.rb'
+ t.rspec_opts = '--format documentation'
+ end
+
+ desc 'GitLab | Teaspoon | Run JavaScript tests'
+ task :tests do
+ require "teaspoon/console"
+ options = {}
+ abort('rake teaspoon:tests failed') if Teaspoon::Console.new(options).failures?
+ end
+end
+
+desc 'GitLab | Teaspoon | Shortcut for teaspoon:fixtures and teaspoon:tests'
+task :teaspoon do
+ Rake::Task['teaspoon:fixtures'].invoke
+ Rake::Task['teaspoon:tests'].invoke
+end