Skip to content

Commit

Permalink
Implement testing against matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
florentferry committed Mar 2, 2018
1 parent 532128a commit f341d24
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 380 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,6 @@
/pkg/ /pkg/
/spec/reports/ /spec/reports/
/tmp/ /tmp/

/fixtures/my_app/tmp
/fixtures/my_app/log
28 changes: 27 additions & 1 deletion .travis.yml
@@ -1,7 +1,33 @@
sudo: false
language: ruby language: ruby
sudo: false

before_install:
- gem update --system

rvm: rvm:
- 2.2
- 2.3
- 2.4 - 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: script:
- bundle exec rubocop - bundle exec rubocop
- bundle exec rake test - bundle exec rake test
9 changes: 9 additions & 0 deletions Gemfile
Expand Up @@ -4,3 +4,12 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }


# Specify your gem's dependencies in komponent.gemspec # Specify your gem's dependencies in komponent.gemspec
gemspec gemspec

gem "rails"
gem "rake", ">= 11.1"
gem "rubocop", require: false

group :test do
gem "aruba"
gem "cucumber"
end
72 changes: 9 additions & 63 deletions features/component_generator.feature
Expand Up @@ -2,17 +2,13 @@ Feature: Component generator


Background: Background:
Given I use a fixture named "my_app" 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 Scenario: Generate component
When I run `rails generate component AwesomeButton` When I run `rails generate component AwesomeButton`
And I cd to "frontend/components" And I cd to "frontend/components"
Then the following files should exist: Then the following files should exist:
| awesome_button/_awesome_button.html.erb | | 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.js |
| awesome_button/awesome_button_component.rb | | awesome_button/awesome_button_component.rb |
And the file named "index.js" should contain: And the file named "index.js" should contain:
Expand All @@ -27,7 +23,7 @@ Feature: Component generator
| admin/index.js | | admin/index.js |
| admin/sub_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.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.js |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_component.rb | | admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_component.rb |
And the file named "index.js" should contain: And the file named "index.js" should contain:
Expand Down Expand Up @@ -70,72 +66,22 @@ Feature: Component generator
Then a file named "_awesome_button.html.erb" should exist Then a file named "_awesome_button.html.erb" should exist


Scenario: Generate component with custom template engine defined to `haml` 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: 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` When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button" And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.scss" should exist Then a file named "_awesome_button.html.haml" should exist
And the file named "awesome_button.js" should contain:
"""
import "./awesome_button.scss";
"""


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: 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` When I run `rails generate component AwesomeButton`
And I cd to "frontend/components/awesome_button" And I cd to "frontend/components/awesome_button"
Then a file named "awesome_button.sass" should exist Then a file named "_awesome_button.html.slim" 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";
"""


Scenario: Generate component with `--locale` option Scenario: Generate component with `--locale` option
When I run `rails generate component AwesomeButton --locale` When I run `rails generate component AwesomeButton --locale`
Expand All @@ -162,7 +108,7 @@ Feature: Component generator
And I cd to "components" And I cd to "components"
Then the following files should exist: Then the following files should exist:
| awesome_button/_awesome_button.html.erb | | 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.js |
| awesome_button/awesome_button_controller.js | | awesome_button/awesome_button_controller.js |
| awesome_button/awesome_button_component.rb | | awesome_button/awesome_button_component.rb |
Expand All @@ -180,7 +126,7 @@ Feature: Component generator
And I cd to "components" And I cd to "components"
Then the following files should exist: 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.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.js |
| admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_controller.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 | | admin/sub_admin/awesome_button/admin_sub_admin_awesome_button_component.rb |
Expand Down
25 changes: 7 additions & 18 deletions features/install_generator.feature
@@ -1,32 +1,21 @@
Feature: Install generator Feature: Install generator


Scenario: Configure a default root path in komponent's configuration before installing component Scenario: Default root path
Given I run `rails new my_app --skip-spring` Given I use a fixture named "my_app"
When I cd to "my_app" When I run `rails generate komponent:install`
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`
And the file named "config/application.rb" should contain: 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: 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 run `rails generate component AwesomeButton`
And I cd to "app/frontend/components" And I cd to "frontend/components"
Then the following files should exist: Then the following files should exist:
| awesome_button/_awesome_button.html.erb | | 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.js |
| awesome_button/awesome_button_component.rb | | awesome_button/awesome_button_component.rb |
And the file named "index.js" should contain: And the file named "index.js" should contain:
Expand Down
18 changes: 0 additions & 18 deletions features/step_definitions/base.rb
@@ -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
4 changes: 0 additions & 4 deletions features/support/env.rb
@@ -1,4 +0,0 @@
Before do
delete_environment_variable 'RUBYOPT'
delete_environment_variable 'BUNDLE_GEMFILE'
end
2 changes: 1 addition & 1 deletion features/support/setup.rb
@@ -1,5 +1,5 @@
require 'aruba/cucumber' require 'aruba/cucumber'


Aruba.configure do |config| Aruba.configure do |config|
config.io_wait_timeout = 5 config.io_wait_timeout = 15
end end
52 changes: 0 additions & 52 deletions fixtures/my_app/Gemfile-rails

This file was deleted.

0 comments on commit f341d24

Please sign in to comment.