Permalink
Browse files

Implement testing against matrix

  • Loading branch information...
florentferry committed Mar 2, 2018
1 parent 532128a commit f341d245988b1e45fd59a90b5c6b55f9051d0682
View
@@ -7,3 +7,6 @@
/pkg/
/spec/reports/
/tmp/
/fixtures/my_app/tmp
/fixtures/my_app/log
View
@@ -1,7 +1,33 @@
sudo: false
language: ruby
sudo: false
before_install:
- gem update --system
rvm:
- 2.2
- 2.3
- 2.4
- 2.5
- ruby-head
gemfile:
- Gemfile-rails.4.2.x
- Gemfile-rails.5.0.x
- Gemfile-rails.5.1.x
- Gemfile-rails.5.2.x
cache:
bundler: true
yarn: true
install:
- bundle install
- nvm install node
- node -v
- npm i -g yarn
- yarn
script:
- bundle exec rubocop
- bundle exec rake test
View
@@ -4,3 +4,12 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in komponent.gemspec
gemspec
gem "rails"
gem "rake", ">= 11.1"
gem "rubocop", require: false
group :test do
gem "aruba"
gem "cucumber"
end
@@ -2,17 +2,13 @@ Feature: Component generator
Background:
Given I use a fixture named "my_app"
And I set the environment variables to:
| variable | value |
| BUNDLE_GEMFILE | Gemfile-rails |
When I successfully run `bundle install --jobs=3 --retry=3` for up to 60 seconds
Scenario: Generate component
When I run `rails generate component AwesomeButton`
And I cd to "frontend/components"
Then the following files should exist:
| awesome_button/_awesome_button.html.erb |
| awesome_button/awesome_button.scss |
| awesome_button/awesome_button.css |
| awesome_button/awesome_button.js |
| awesome_button/awesome_button_component.rb |
And the file named "index.js" should contain:
@@ -27,7 +23,7 @@ Feature: Component generator
| admin/index.js |
| admin/sub_admin/index.js |
| admin/sub_admin/awesome_button/_admin_sub_admin_awesome_button.html.erb |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.scss |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.css |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.js |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_component.rb |
And the file named "index.js" should contain:
@@ -70,72 +66,22 @@ Feature: Component generator
Then a file named "_awesome_button.html.erb" should exist
Scenario: Generate component with custom template engine defined to `haml`
When I append to "Gemfile-rails" with:
"""
gem 'haml-rails'
"""
And I run `bundle install`
And I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "_awesome_button.html.haml" should exist
Scenario: Generate component with custom template engine defined to `slim`
When I append to "Gemfile-rails" with:
"""
gem 'slim-rails'
"""
And I run `bundle install`
And I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "_awesome_button.html.slim" should exist
Scenario: Generate component with `scss` stylesheet engine
When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.scss" should exist
And the file named "awesome_button.js" should contain:
"""
import "./awesome_button.scss";
"""
Scenario: Generate component with custom stylesheet engine defined to `scss`
Given a file named "config/initializers/custom_configuration.rb" with:
"""
Rails.application.config.generators.stylesheet_engine = :sass
Rails.application.config.generators.template_engine = :haml
"""
When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.scss" should exist
And the file named "awesome_button.js" should contain:
"""
import "./awesome_button.scss";
"""
Then a file named "_awesome_button.html.haml" should exist
Scenario: Generate component with custom stylesheet engine defined to `sass`
Scenario: Generate component with custom template engine defined to `slim`
Given a file named "config/initializers/custom_configuration.rb" with:
"""
Rails.application.config.sass.preferred_syntax = :sass
Rails.application.config.generators.template_engine = :slim
"""
When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.sass" should exist
And the file named "awesome_button.js" should contain:
"""
import "./awesome_button.sass";
"""
Scenario: Generate component with custom stylesheet engine defined to `css`
Given I remove "sass-rails" gem
When I run `bundle install`
And I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.css" should exist
And the file named "awesome_button.js" should contain:
"""
import "./awesome_button.css";
"""
Then a file named "_awesome_button.html.slim" should exist
Scenario: Generate component with `--locale` option
When I run `rails generate component AwesomeButton --locale`
@@ -162,7 +108,7 @@ Feature: Component generator
And I cd to "components"
Then the following files should exist:
| awesome_button/_awesome_button.html.erb |
| awesome_button/awesome_button.scss |
| awesome_button/awesome_button.css |
| awesome_button/awesome_button.js |
| awesome_button/awesome_button_controller.js |
| awesome_button/awesome_button_component.rb |
@@ -180,7 +126,7 @@ Feature: Component generator
And I cd to "components"
Then the following files should exist:
| admin/sub_admin/awesome_button/_admin_sub_admin_awesome_button.html.erb |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.scss |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.css |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button.js |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_controller.js |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_component.rb |
@@ -1,32 +1,21 @@
Feature: Install generator
Scenario: Configure a default root path in komponent's configuration before installing component
Given I run `rails new my_app --skip-spring`
When I cd to "my_app"
And I append to "Gemfile" with:
"""
gem 'komponent', path: '../../..'
"""
And a file named "config/initializers/custom_configuration.rb" with:
"""
Rails.application.config.komponent.root = Rails.root.join("app/frontend")
"""
And I run `bundle install --jobs=3 --retry=3`
And I run `rails webpacker:install`
And I run `rails generate komponent:install`
Scenario: Default root path
Given I use a fixture named "my_app"
When I run `rails generate komponent:install`
And the file named "config/application.rb" should contain:
"""
config.i18n.load_path += Dir[config.root.join('app/frontend/components/**/*.yml')]
config.i18n.load_path += Dir[config.root.join('frontend/components/**/*.yml')]
"""
And the file named "config/application.rb" should contain:
"""
config.autoload_paths << config.root.join('app/frontend/components')
config.autoload_paths << config.root.join('frontend/components')
"""
And I run `rails generate component AwesomeButton`
And I cd to "app/frontend/components"
And I cd to "frontend/components"
Then the following files should exist:
| awesome_button/_awesome_button.html.erb |
| awesome_button/awesome_button.scss |
| awesome_button/awesome_button.css |
| awesome_button/awesome_button.js |
| awesome_button/awesome_button_component.rb |
And the file named "index.js" should contain:
@@ -1,18 +0,0 @@
After do
set_environment_variable "BUNDLE_GEMFILE", ""
end
Given("I remove {string} gem") do |gem_name|
file_name = "Gemfile-rails"
file_name = expand_path(file_name)
tmp = Tempfile.new
File.foreach(file_name) do |line|
tmp.puts(line) unless /#{gem_name}/ =~ line
end
tmp.close
FileUtils.mv(tmp.path, file_name)
tmp.unlink
end
View
@@ -1,4 +0,0 @@
Before do
delete_environment_variable 'RUBYOPT'
delete_environment_variable 'BUNDLE_GEMFILE'
end
@@ -1,5 +1,5 @@
require 'aruba/cucumber'
Aruba.configure do |config|
config.io_wait_timeout = 5
config.io_wait_timeout = 15
end

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit f341d24

Please sign in to comment.