feature 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
  require 'feature/testing'
3
3
 
4
- describe "Feature testing support" do
4
+ describe 'Feature testing support' do
5
5
  before(:each) do
6
6
  repository = SimpleRepository.new
7
7
  repository.add_active_feature(:active_feature)
8
8
  Feature.set_repository(repository)
9
9
  end
10
10
 
11
- it "should execute code block with an deactivated feature" do
11
+ it 'should execute code block with an deactivated feature' do
12
12
  expect(Feature.active?(:another_feature)).to be_falsey
13
13
 
14
14
  Feature.run_with_activated(:another_feature) do
@@ -18,7 +18,7 @@ describe "Feature testing support" do
18
18
  expect(Feature.active?(:another_feature)).to be_falsey
19
19
  end
20
20
 
21
- it "should execute code block with an deactivated feature" do
21
+ it 'should execute code block with an deactivated feature' do
22
22
  expect(Feature.active?(:active_feature)).to be_truthy
23
23
 
24
24
  Feature.run_with_deactivated(:active_feature) do
@@ -4,11 +4,11 @@ require 'tempfile'
4
4
  include Feature::Repository
5
5
 
6
6
  describe Feature::Repository::YamlRepository do
7
- context "proper config file" do
7
+ context 'proper config file' do
8
8
  before(:each) do
9
9
  @filename = Tempfile.new(['feature_config', '.yaml']).path
10
10
  fp = File.new(@filename, 'w')
11
- fp.write <<"EOF";
11
+ fp.write <<"EOF"
12
12
  features:
13
13
  feature_a_active: true
14
14
  feature_b_active: true
@@ -24,14 +24,14 @@ EOF
24
24
  File.delete(@filename)
25
25
  end
26
26
 
27
- it "should read active features from a config file" do
27
+ it 'should read active features from a config file' do
28
28
  expect(@repo.active_features).to eq([:feature_a_active, :feature_b_active])
29
29
  end
30
30
 
31
- context "re-read config file" do
31
+ context 're-read config file' do
32
32
  before(:each) do
33
33
  fp = File.new(@filename, 'w')
34
- fp.write <<"EOF";
34
+ fp.write <<"EOF"
35
35
  features:
36
36
  feature_a_active: true
37
37
  feature_c_inactive: false
@@ -39,30 +39,29 @@ EOF
39
39
  fp.close
40
40
  end
41
41
 
42
- it "should read active features new on each request" do
42
+ it 'should read active features new on each request' do
43
43
  expect(@repo.active_features).to eq([:feature_a_active])
44
44
  end
45
45
  end
46
46
 
47
- # For example, when all your features are in production and working fine.
48
- context "with no features" do
47
+ context 'with no features' do
49
48
  before(:each) do
50
49
  fp = File.new(@filename, 'w')
51
- fp.write <<"EOF";
50
+ fp.write <<"EOF"
52
51
  features:
53
52
  EOF
54
53
  fp.close
55
54
  end
56
55
 
57
- it "should read active features new on each request" do
56
+ it 'should read active features new on each request' do
58
57
  expect(@repo.active_features).to eq([])
59
58
  end
60
59
  end
61
60
 
62
- context "with optional environment name" do
61
+ context 'with optional environment name' do
63
62
  before(:each) do
64
63
  fp = File.new(@filename, 'w')
65
- fp.write <<"EOF";
64
+ fp.write <<"EOF"
66
65
  development:
67
66
  features:
68
67
  feature_a: true
@@ -75,12 +74,12 @@ EOF
75
74
  fp.close
76
75
  end
77
76
 
78
- it "has two active features for development environment" do
77
+ it 'has two active features for development environment' do
79
78
  repo = YamlRepository.new(@filename, 'development')
80
79
  expect(repo.active_features).to eq([:feature_a, :feature_b])
81
80
  end
82
81
 
83
- it "has one active feature for production environment" do
82
+ it 'has one active feature for production environment' do
84
83
  repo = YamlRepository.new(@filename, 'production')
85
84
  expect(repo.active_features).to eq([:feature_a])
86
85
  end
@@ -88,11 +87,11 @@ EOF
88
87
 
89
88
  # Sometimes needed when loading features from ENV variables or are time
90
89
  # based rules Ex: Date.today > Date.strptime('1/2/2012', '%d/%m/%Y')
91
- context "a config file with embedded erb" do
90
+ context 'a config file with embedded erb' do
92
91
  before(:each) do
93
92
  @filename = Tempfile.new(['feature_config', '.yaml']).path
94
93
  fp = File.new(@filename, 'w')
95
- fp.write <<"EOF";
94
+ fp.write <<"EOF"
96
95
  features:
97
96
  feature_a_active: <%= 'true' == 'true' %>
98
97
  feature_b_active: true
@@ -104,35 +103,50 @@ EOF
104
103
  @repo = YamlRepository.new(@filename)
105
104
  end
106
105
 
107
- it "should read active features from the config file" do
106
+ it 'should read active features from the config file' do
108
107
  expect(@repo.active_features).to eq([:feature_a_active, :feature_b_active])
109
108
  end
110
109
  end
111
110
  end
112
111
 
113
- it "should raise exception on no file found" do
114
- repo = YamlRepository.new("/this/file/should/not/exist")
112
+ it 'should raise exception on no file found' do
113
+ repo = YamlRepository.new('/this/file/should/not/exist')
115
114
  expect do
116
115
  repo.active_features
117
116
  end.to raise_error(Errno::ENOENT, /No such file or directory/)
118
117
  end
119
118
 
120
- it "should raise exception on invalid yaml" do
119
+ it 'should raise exception on invalid yaml' do
121
120
  @filename = Tempfile.new(['feature_config', '.yaml']).path
122
121
  fp = File.new(@filename, 'w')
123
- fp.write "this is not valid feature config"
122
+ fp.write 'this is not valid feature config'
124
123
  fp.close
125
124
 
126
125
  repo = YamlRepository.new(@filename)
127
126
  expect do
128
127
  repo.active_features
129
- end.to raise_error(ArgumentError, "content of #{@filename} does not contain proper config")
128
+ end.to raise_error(ArgumentError, 'yaml config does not contain proper config')
130
129
  end
131
130
 
132
- it "should raise exception on not true/false value in config" do
131
+ it 'should raise exception on yaml without features key' do
133
132
  @filename = Tempfile.new(['feature_config', '.yaml']).path
134
133
  fp = File.new(@filename, 'w')
135
- fp.write <<"EOF";
134
+ fp.write <<"EOF"
135
+ fail:
136
+ feature: true
137
+ EOF
138
+ fp.close
139
+
140
+ repo = YamlRepository.new(@filename)
141
+ expect do
142
+ repo.active_features
143
+ end.to raise_error(ArgumentError, 'yaml config does not contain proper config')
144
+ end
145
+
146
+ it 'should raise exception on not true/false value in config' do
147
+ @filename = Tempfile.new(['feature_config', '.yaml']).path
148
+ fp = File.new(@filename, 'w')
149
+ fp.write <<"EOF"
136
150
  features:
137
151
  invalid_feature: neither_true_or_false
138
152
  EOF
@@ -141,6 +155,6 @@ EOF
141
155
  repo = YamlRepository.new(@filename)
142
156
  expect do
143
157
  repo.active_features
144
- end.to raise_error(ArgumentError, "neither_true_or_false is not allowed value in config, use true/false")
158
+ end.to raise_error(ArgumentError, 'neither_true_or_false is not allowed value in config, use true/false')
145
159
  end
146
160
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  set -e
4
4
 
5
- for rails_version in 3 4; do
5
+ for rails_version in 4; do
6
6
  RAILS_VERSION=$rails_version ./test-against-specific-rails-version.sh
7
7
  done
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e
4
4
 
5
- BUNDLE_GEMFILE=gemfiles/rails${RAILS_VERSION}.gemfile
5
+ export BUNDLE_GEMFILE=gemfiles/rails${RAILS_VERSION}.gemfile
6
6
 
7
7
  TESTAPP_NAME=testapp
8
8
 
@@ -22,3 +22,6 @@ cd $TESTAPP_NAME
22
22
  bundle install
23
23
  bundle exec rails g feature:install
24
24
  bundle exec rake db:migrate
25
+
26
+ cd ..
27
+ rm -Rf $TESTAPP_NAME
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'pathname'
2
2
  require 'coveralls'
3
+ require 'fakeredis/rspec'
4
+
3
5
  Coveralls.wear!
6
+ Coveralls::Output.silent = true
4
7
 
5
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
9
  $LOAD_PATH.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Gerdes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2014-10-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: github@mgsnova.de
@@ -22,22 +22,19 @@ files:
22
22
  - Rakefile
23
23
  - lib/feature.rb
24
24
  - lib/feature/generators/install_generator.rb
25
- - lib/feature/generators/templates/create_feature_toggles.rb
26
25
  - lib/feature/generators/templates/feature.rb
27
- - lib/feature/generators/templates/feature_toggle.rb
28
- - lib/feature/generators/templates/feature_toggle_without_attr_accessible.rb
29
26
  - lib/feature/repository.rb
30
27
  - lib/feature/repository/active_record_repository.rb
28
+ - lib/feature/repository/redis_repository.rb
31
29
  - lib/feature/repository/simple_repository.rb
32
30
  - lib/feature/repository/yaml_repository.rb
33
31
  - lib/feature/testing.rb
34
32
  - spec/feature/active_record_repository_spec.rb
35
33
  - spec/feature/feature_spec.rb
34
+ - spec/feature/redis_repository_spec.rb
36
35
  - spec/feature/simple_repository_spec.rb
37
36
  - spec/feature/testing_spec.rb
38
37
  - spec/feature/yaml_repository_spec.rb
39
- - spec/integration/rails/gemfiles/rails3.gemfile
40
- - spec/integration/rails/gemfiles/rails3.gemfile.lock
41
38
  - spec/integration/rails/gemfiles/rails4.gemfile
42
39
  - spec/integration/rails/gemfiles/rails4.gemfile.lock
43
40
  - spec/integration/rails/test-against-several-rails-versions.sh
@@ -1,10 +0,0 @@
1
- class CreateFeatureToggles < ActiveRecord::Migration
2
- def change
3
- create_table :feature_toggles do |t|
4
- t.string :name
5
- t.boolean :active
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- class FeatureToggle < ActiveRecord::Base
2
- attr_accessible :name, :active
3
-
4
- # Feature name should be present and unique
5
- validates :name, presence: true, uniqueness: true
6
- end
@@ -1,4 +0,0 @@
1
- class FeatureToggle < ActiveRecord::Base
2
- # Feature name should be present and unique
3
- validates :name, presence: true, uniqueness: true
4
- end
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~> 3.2.19'
4
- gem 'railties'
@@ -1,86 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- actionmailer (3.2.19)
5
- actionpack (= 3.2.19)
6
- mail (~> 2.5.4)
7
- actionpack (3.2.19)
8
- activemodel (= 3.2.19)
9
- activesupport (= 3.2.19)
10
- builder (~> 3.0.0)
11
- erubis (~> 2.7.0)
12
- journey (~> 1.0.4)
13
- rack (~> 1.4.5)
14
- rack-cache (~> 1.2)
15
- rack-test (~> 0.6.1)
16
- sprockets (~> 2.2.1)
17
- activemodel (3.2.19)
18
- activesupport (= 3.2.19)
19
- builder (~> 3.0.0)
20
- activerecord (3.2.19)
21
- activemodel (= 3.2.19)
22
- activesupport (= 3.2.19)
23
- arel (~> 3.0.2)
24
- tzinfo (~> 0.3.29)
25
- activeresource (3.2.19)
26
- activemodel (= 3.2.19)
27
- activesupport (= 3.2.19)
28
- activesupport (3.2.19)
29
- i18n (~> 0.6, >= 0.6.4)
30
- multi_json (~> 1.0)
31
- arel (3.0.3)
32
- builder (3.0.4)
33
- erubis (2.7.0)
34
- hike (1.2.3)
35
- i18n (0.6.11)
36
- journey (1.0.4)
37
- json (1.8.1)
38
- mail (2.5.4)
39
- mime-types (~> 1.16)
40
- treetop (~> 1.4.8)
41
- mime-types (1.25.1)
42
- multi_json (1.10.1)
43
- polyglot (0.3.5)
44
- rack (1.4.5)
45
- rack-cache (1.2)
46
- rack (>= 0.4)
47
- rack-ssl (1.3.4)
48
- rack
49
- rack-test (0.6.2)
50
- rack (>= 1.0)
51
- rails (3.2.19)
52
- actionmailer (= 3.2.19)
53
- actionpack (= 3.2.19)
54
- activerecord (= 3.2.19)
55
- activeresource (= 3.2.19)
56
- activesupport (= 3.2.19)
57
- bundler (~> 1.0)
58
- railties (= 3.2.19)
59
- railties (3.2.19)
60
- actionpack (= 3.2.19)
61
- activesupport (= 3.2.19)
62
- rack-ssl (~> 1.3.2)
63
- rake (>= 0.8.7)
64
- rdoc (~> 3.4)
65
- thor (>= 0.14.6, < 2.0)
66
- rake (10.3.2)
67
- rdoc (3.12.2)
68
- json (~> 1.4)
69
- sprockets (2.2.2)
70
- hike (~> 1.2)
71
- multi_json (~> 1.0)
72
- rack (~> 1.0)
73
- tilt (~> 1.1, != 1.3.0)
74
- thor (0.19.1)
75
- tilt (1.4.1)
76
- treetop (1.4.15)
77
- polyglot
78
- polyglot (>= 0.3.1)
79
- tzinfo (0.3.40)
80
-
81
- PLATFORMS
82
- ruby
83
-
84
- DEPENDENCIES
85
- rails (~> 3.2.19)
86
- railties