shoulda-context 1.2.2 → 2.0.0.rc1

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 (70) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +0 -1
  3. data/.rubocop.yml +190 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +27 -2
  6. data/Appraisals +15 -32
  7. data/CHANGELOG.md +27 -0
  8. data/Gemfile +4 -1
  9. data/Gemfile.lock +72 -0
  10. data/MIT-LICENSE +1 -1
  11. data/README.md +140 -29
  12. data/Rakefile +19 -14
  13. data/bin/install_gems_in_all_appraisals +16 -0
  14. data/bin/run_all_tests +16 -0
  15. data/bin/setup +190 -0
  16. data/bin/supported_ruby_versions +7 -0
  17. data/bin/update_gem_in_all_appraisals +17 -0
  18. data/bin/update_gems_in_all_appraisals +16 -0
  19. data/{bin → exe}/convert_to_should_syntax +0 -0
  20. data/gemfiles/rails_4_2.gemfile +10 -0
  21. data/gemfiles/rails_4_2.gemfile.lock +164 -0
  22. data/gemfiles/rails_5_0.gemfile +10 -0
  23. data/gemfiles/rails_5_0.gemfile.lock +170 -0
  24. data/gemfiles/rails_5_1.gemfile +10 -0
  25. data/gemfiles/rails_5_1.gemfile.lock +170 -0
  26. data/gemfiles/rails_5_2.gemfile +10 -0
  27. data/gemfiles/rails_5_2.gemfile.lock +178 -0
  28. data/lib/shoulda/context.rb +12 -16
  29. data/lib/shoulda/context/assertions.rb +16 -13
  30. data/lib/shoulda/context/configuration.rb +19 -0
  31. data/lib/shoulda/context/context.rb +22 -305
  32. data/lib/shoulda/context/dsl.rb +279 -0
  33. data/lib/shoulda/context/railtie.rb +14 -0
  34. data/lib/shoulda/context/test_framework_detection.rb +4 -5
  35. data/lib/shoulda/context/version.rb +1 -1
  36. data/lib/shoulda/context/world.rb +22 -0
  37. data/shoulda-context.gemspec +19 -17
  38. data/test/fake_rails_root/test/shoulda_macros/custom_macro.rb +1 -1
  39. data/test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb +1 -2
  40. data/test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb +1 -2
  41. data/test/shoulda/autoload_macro_test.rb +1 -1
  42. data/test/shoulda/context_test.rb +92 -53
  43. data/test/shoulda/convert_to_should_syntax_test.rb +5 -7
  44. data/test/shoulda/helpers_test.rb +24 -59
  45. data/test/shoulda/railtie_test.rb +43 -0
  46. data/test/shoulda/should_test.rb +163 -24
  47. data/test/shoulda/test_framework_detection_test.rb +64 -71
  48. data/test/support/current_bundle.rb +61 -0
  49. data/test/support/rails_application_with_shoulda_context.rb +46 -0
  50. data/test/support/snowglobe.rb +5 -0
  51. data/test/test_helper.rb +35 -11
  52. metadata +71 -60
  53. data/gemfiles/minitest_4_x.gemfile +0 -7
  54. data/gemfiles/minitest_4_x.gemfile.lock +0 -96
  55. data/gemfiles/minitest_5_x.gemfile +0 -7
  56. data/gemfiles/minitest_5_x.gemfile.lock +0 -102
  57. data/gemfiles/rails_3_0.gemfile +0 -8
  58. data/gemfiles/rails_3_0.gemfile.lock +0 -93
  59. data/gemfiles/rails_3_1.gemfile +0 -10
  60. data/gemfiles/rails_3_1.gemfile.lock +0 -114
  61. data/gemfiles/rails_3_2.gemfile +0 -10
  62. data/gemfiles/rails_3_2.gemfile.lock +0 -112
  63. data/gemfiles/rails_4_0.gemfile +0 -10
  64. data/gemfiles/rails_4_0.gemfile.lock +0 -107
  65. data/gemfiles/rails_4_1.gemfile +0 -10
  66. data/gemfiles/rails_4_1.gemfile.lock +0 -119
  67. data/gemfiles/test_unit.gemfile +0 -7
  68. data/gemfiles/test_unit.gemfile.lock +0 -95
  69. data/init.rb +0 -1
  70. data/rails/init.rb +0 -4
data/Rakefile CHANGED
@@ -1,21 +1,26 @@
1
- require 'bundler/setup'
2
- require 'bundler/gem_tasks'
3
- require 'rake/testtask'
4
- require 'appraisal'
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+ require "pry-byebug"
5
5
 
6
- $LOAD_PATH.unshift("lib")
7
- load 'tasks/shoulda.rake'
6
+ require_relative "test/support/current_bundle"
7
+
8
+ load "tasks/shoulda.rake"
8
9
 
9
10
  Rake::TestTask.new do |t|
10
- t.libs << 'lib' << 'test'
11
- t.pattern = 'test/**/*_test.rb'
11
+ t.libs << "test"
12
+ t.ruby_opts += ["-w"]
13
+ t.pattern = "test/**/*_test.rb"
12
14
  t.verbose = false
13
15
  end
14
16
 
15
- desc 'Test the plugin under all supported Rails versions.'
16
- task :all => ['appraisal:cleanup', 'appraisal:install'] do
17
- exec('rake appraisal test')
17
+ task :default do
18
+ if Tests::CurrentBundle.instance.appraisal_in_use?
19
+ Rake::Task["test"].invoke
20
+ elsif ENV["CI"]
21
+ exec "appraisal install && appraisal rake --trace"
22
+ else
23
+ appraisal = Tests::CurrentBundle.instance.latest_appraisal
24
+ exec "appraisal install && appraisal #{appraisal} rake --trace"
25
+ end
18
26
  end
19
-
20
- desc 'Default: run tests'
21
- task :default => [:all]
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SUPPORTED_VERSIONS=$(bin/supported_ruby_versions)
6
+
7
+ install-gems-for-version() {
8
+ local version="$1"
9
+ (export RBENV_VERSION=$version; bundle && bundle exec appraisal install)
10
+ }
11
+
12
+ for version in $SUPPORTED_VERSIONS; do
13
+ echo
14
+ echo "*** Installing gems for $version ***"
15
+ install-gems-for-version $version
16
+ done
data/bin/run_all_tests ADDED
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SUPPORTED_VERSIONS=$(bin/supported_ruby_versions)
6
+
7
+ run-tests-for-version() {
8
+ local version="$1"
9
+ (export RBENV_VERSION=$version; bundle exec rake)
10
+ }
11
+
12
+ for version in $SUPPORTED_VERSIONS; do
13
+ echo
14
+ echo "*** Running tests for $version ***"
15
+ run-tests-for-version $version
16
+ done
data/bin/setup ADDED
@@ -0,0 +1,190 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ RUBY_VERSION=$(bin/supported_ruby_versions | xargs -n 1 echo | sort -V | tail -n 1)
6
+
7
+ cd "$(dirname "$(dirname "$0")")"
8
+
9
+ uname=$(uname)
10
+
11
+ if [[ $uname == 'Darwin' ]]; then
12
+ platform='mac'
13
+ else
14
+ platform='linux'
15
+ fi
16
+
17
+ banner() {
18
+ echo -e "\033[34m== $@ ==\033[0m"
19
+ }
20
+
21
+ success() {
22
+ echo -e "\033[32m$@\033[0m"
23
+ }
24
+
25
+ warning() {
26
+ echo -e "\033[33m$@\033[0m"
27
+ }
28
+
29
+ error() {
30
+ echo -e "\033[31m$@\033[0m"
31
+ }
32
+
33
+ has-executable() {
34
+ type "$1" &>/dev/null
35
+ }
36
+
37
+ is-running() {
38
+ pgrep "$1" >/dev/null
39
+ }
40
+
41
+ install() {
42
+ local apt_package=""
43
+ local rpm_package=""
44
+ local brew_package=""
45
+ local default_package=""
46
+ local package=""
47
+
48
+ for arg in "$@"; do
49
+ case $arg in
50
+ apt=*)
51
+ apt_package="$arg"
52
+ ;;
53
+ rpm=*)
54
+ rpm_package="$arg"
55
+ ;;
56
+ brew=*)
57
+ brew_package="$arg"
58
+ ;;
59
+ *)
60
+ default_package="$arg"
61
+ ;;
62
+ esac
63
+ done
64
+
65
+ if has-executable brew; then
66
+ package="${brew_package:-$default_package}"
67
+
68
+ if [[ -n $package ]]; then
69
+ brew install "$package"
70
+ fi
71
+ elif has-executable apt-get; then
72
+ package="${apt_package:-$default_package}"
73
+
74
+ if [[ -n $package ]]; then
75
+ sudo apt-get install -y "$package"
76
+ fi
77
+ elif has-executable yum; then
78
+ package="${yum_package:-$default_package}"
79
+
80
+ if [[ -n $package ]]; then
81
+ sudo yum install -y "$package"
82
+ fi
83
+ else
84
+ error "Sorry, I'm not sure how to install $default_package."
85
+ exit 1
86
+ fi
87
+ }
88
+
89
+ check-for-build-tools() {
90
+ if [[ $platform == "linux" ]]; then
91
+ if ! has-executable apt-get; then
92
+ error "You don't seem to have a package manager installed."
93
+ echo "The setup script assumes you're using Debian or a Debian-derived flavor of Linux"
94
+ echo "(i.e. something with Apt). If this is not the case, then we would gladly take a"
95
+ echo "PR fixing this!"
96
+ exit 1
97
+ fi
98
+
99
+ # TODO: Check if build-essential is installed on Debian?
100
+ else
101
+ if ! has-executable brew; then
102
+ error "You don't seem to have Homebrew installed."
103
+ echo
104
+ echo "Follow the instructions here to do this:"
105
+ echo
106
+ echo "http://brew.sh"
107
+ exit 1
108
+ fi
109
+
110
+ # TODO: Check that OS X Command Line Tools are installed?
111
+ fi
112
+ }
113
+
114
+ install-development-libraries() {
115
+ install apt=ruby-dev rpm=ruby-devel
116
+ install rpm=zlib-devel
117
+ }
118
+
119
+ install-dependencies() {
120
+ if ! has-executable sqlite3; then
121
+ banner 'Installing SQLite 3'
122
+ install sqlite3
123
+ install apt=libsqlite3-dev rpm=sqlite-devel
124
+ fi
125
+
126
+ if ! has-executable psql; then
127
+ banner 'Installing PostgreSQL'
128
+ install postgresql
129
+ install apt=libpq-dev rpm=postgresql-devel
130
+ fi
131
+
132
+ if ! is-running postgres; then
133
+ banner 'Starting PostgreSQL'
134
+ start postgresql
135
+ fi
136
+
137
+ if ! has-executable heroku; then
138
+ banner 'Installing Heroku'
139
+ install heroku/brew/heroku heroku
140
+ fi
141
+
142
+ if has-executable rbenv; then
143
+ if ! (rbenv versions | grep $RUBY_VERSION'\>' &>/dev/null); then
144
+ banner "Installing Ruby $RUBY_VERSION with rbenv"
145
+ rbenv install --skip-existing "$RUBY_VERSION"
146
+ fi
147
+ elif has-executable rvm; then
148
+ if ! (rvm ls | grep $RUBY_VERSION'\>' &>/dev/null); then
149
+ banner "Installing Ruby $RUBY_VERSION with rvm"
150
+ error "You don't seem to have Ruby $RUBY_VERSION installed."
151
+ echo
152
+ echo "Use RVM to do so, and then re-run this command."
153
+ echo
154
+ fi
155
+ else
156
+ error "You don't seem to have a Ruby manager installed."
157
+ echo
158
+ echo 'We recommend using rbenv. You can find installation instructions here:'
159
+ echo
160
+ echo 'http://github.com/rbenv/rbenv'
161
+ echo
162
+ echo "When you're done, simply re-run this script!"
163
+ exit 1
164
+ fi
165
+
166
+ banner 'Installing Ruby dependencies'
167
+ gem install bundler -v '~> 1.0' --conservative
168
+ bundle check || bundle install
169
+ bundle exec appraisal install
170
+
171
+ if ! has-executable node; then
172
+ banner 'Installing Node'
173
+
174
+ if [[ $platform == 'linux' ]]; then
175
+ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
176
+
177
+ install nodejs
178
+
179
+ if ! has-executable npm; then
180
+ install npm
181
+ fi
182
+ else
183
+ install nodejs
184
+ fi
185
+ fi
186
+ }
187
+
188
+ check-for-build-tools
189
+ install-development-libraries
190
+ install-dependencies
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+
5
+ travis_config_path = File.expand_path('../../.travis.yml', __FILE__)
6
+ travis_config = YAML.load_file(travis_config_path)
7
+ puts travis_config.fetch('rvm').join(' ')
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SUPPORTED_VERSIONS=$(bin/supported_ruby_versions)
6
+ gem="$1"
7
+
8
+ update-gem-for-version() {
9
+ local version="$1"
10
+ (export RBENV_VERSION=$version; bundle update "$gem"; bundle exec appraisal update "$gem")
11
+ }
12
+
13
+ for version in $SUPPORTED_VERSIONS; do
14
+ echo
15
+ echo "*** Updating $gem for $version ***"
16
+ update-gem-for-version $version
17
+ done
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SUPPORTED_VERSIONS=$(bin/supported_ruby_versions)
6
+
7
+ update-gems-for-version() {
8
+ local version="$1"
9
+ (export RBENV_VERSION=$version; bundle update "${@:2}"; bundle exec appraisal update "${@:2}")
10
+ }
11
+
12
+ for version in $SUPPORTED_VERSIONS; do
13
+ echo
14
+ echo "*** Updating gems for $version ***"
15
+ update-gems-for-version "$version" "$@"
16
+ done
File without changes
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest"
6
+ gem "test-unit"
7
+ gem "sqlite3", "~> 1.3.6"
8
+ gem "rails", "~> 4.2.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,164 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ shoulda-context (2.0.0.rc1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.2.10)
10
+ actionpack (= 4.2.10)
11
+ actionview (= 4.2.10)
12
+ activejob (= 4.2.10)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ actionpack (4.2.10)
16
+ actionview (= 4.2.10)
17
+ activesupport (= 4.2.10)
18
+ rack (~> 1.6)
19
+ rack-test (~> 0.6.2)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ actionview (4.2.10)
23
+ activesupport (= 4.2.10)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
28
+ activejob (4.2.10)
29
+ activesupport (= 4.2.10)
30
+ globalid (>= 0.3.0)
31
+ activemodel (4.2.10)
32
+ activesupport (= 4.2.10)
33
+ builder (~> 3.1)
34
+ activerecord (4.2.10)
35
+ activemodel (= 4.2.10)
36
+ activesupport (= 4.2.10)
37
+ arel (~> 6.0)
38
+ activesupport (4.2.10)
39
+ i18n (~> 0.7)
40
+ minitest (~> 5.1)
41
+ thread_safe (~> 0.3, >= 0.3.4)
42
+ tzinfo (~> 1.1)
43
+ appraisal (2.2.0)
44
+ bundler
45
+ rake
46
+ thor (>= 0.14.0)
47
+ arel (6.0.4)
48
+ ast (2.4.0)
49
+ builder (3.2.3)
50
+ byebug (10.0.2)
51
+ coderay (1.1.2)
52
+ concurrent-ruby (1.1.4)
53
+ crass (1.0.4)
54
+ erubis (2.7.0)
55
+ globalid (0.4.2)
56
+ activesupport (>= 4.2.0)
57
+ i18n (0.9.5)
58
+ concurrent-ruby (~> 1.0)
59
+ jaro_winkler (1.5.2)
60
+ loofah (2.2.3)
61
+ crass (~> 1.0.2)
62
+ nokogiri (>= 1.5.9)
63
+ m (1.5.1)
64
+ method_source (>= 0.6.7)
65
+ rake (>= 0.9.2.2)
66
+ mail (2.7.1)
67
+ mini_mime (>= 0.1.1)
68
+ metaclass (0.0.4)
69
+ method_source (0.9.2)
70
+ mini_mime (1.0.1)
71
+ mini_portile2 (2.4.0)
72
+ minitest (5.11.3)
73
+ mocha (1.8.0)
74
+ metaclass (~> 0.0.1)
75
+ nokogiri (1.10.1)
76
+ mini_portile2 (~> 2.4.0)
77
+ parallel (1.14.0)
78
+ parser (2.6.0.0)
79
+ ast (~> 2.4.0)
80
+ power_assert (1.1.3)
81
+ powerpack (0.1.2)
82
+ pry (0.12.2)
83
+ coderay (~> 1.1.0)
84
+ method_source (~> 0.9.0)
85
+ pry-byebug (3.6.0)
86
+ byebug (~> 10.0)
87
+ pry (~> 0.10)
88
+ psych (3.1.0)
89
+ rack (1.6.8)
90
+ rack-test (0.6.3)
91
+ rack (>= 1.0)
92
+ rails (4.2.10)
93
+ actionmailer (= 4.2.10)
94
+ actionpack (= 4.2.10)
95
+ actionview (= 4.2.10)
96
+ activejob (= 4.2.10)
97
+ activemodel (= 4.2.10)
98
+ activerecord (= 4.2.10)
99
+ activesupport (= 4.2.10)
100
+ bundler (>= 1.3.0, < 2.0)
101
+ railties (= 4.2.10)
102
+ sprockets-rails
103
+ rails-deprecated_sanitizer (1.0.3)
104
+ activesupport (>= 4.2.0.alpha)
105
+ rails-dom-testing (1.0.8)
106
+ activesupport (>= 4.2.0.beta, < 5.0)
107
+ nokogiri (~> 1.6)
108
+ rails-deprecated_sanitizer (>= 1.0.1)
109
+ rails-html-sanitizer (1.0.4)
110
+ loofah (~> 2.2, >= 2.2.2)
111
+ railties (4.2.10)
112
+ actionpack (= 4.2.10)
113
+ activesupport (= 4.2.10)
114
+ rake (>= 0.8.7)
115
+ thor (>= 0.18.1, < 2.0)
116
+ rainbow (3.0.0)
117
+ rake (12.3.2)
118
+ rubocop (0.65.0)
119
+ jaro_winkler (~> 1.5.1)
120
+ parallel (~> 1.10)
121
+ parser (>= 2.5, != 2.5.1.1)
122
+ powerpack (~> 0.1)
123
+ psych (>= 3.1.0)
124
+ rainbow (>= 2.2.2, < 4.0)
125
+ ruby-progressbar (~> 1.7)
126
+ unicode-display_width (~> 1.4.0)
127
+ ruby-progressbar (1.10.0)
128
+ snowglobe (0.1.0)
129
+ sprockets (3.7.2)
130
+ concurrent-ruby (~> 1.0)
131
+ rack (> 1, < 3)
132
+ sprockets-rails (3.2.1)
133
+ actionpack (>= 4.0)
134
+ activesupport (>= 4.0)
135
+ sprockets (>= 3.0.0)
136
+ sqlite3 (1.3.13)
137
+ test-unit (3.3.0)
138
+ power_assert
139
+ thor (0.20.3)
140
+ thread_safe (0.3.6)
141
+ tzinfo (1.2.5)
142
+ thread_safe (~> 0.1)
143
+ unicode-display_width (1.4.1)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ appraisal
150
+ bundler (~> 1.0)
151
+ m
152
+ minitest
153
+ mocha
154
+ pry-byebug
155
+ rails (~> 4.2.0)
156
+ rake
157
+ rubocop
158
+ shoulda-context!
159
+ snowglobe
160
+ sqlite3 (~> 1.3.6)
161
+ test-unit
162
+
163
+ BUNDLED WITH
164
+ 1.17.3