whowish_word 0.6.5 → 1.0.0
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.
- data/.gitignore +2 -2
- data/Gemfile +2 -4
- data/lib/whowish_word/action_controller/base.rb +6 -46
- data/lib/whowish_word/action_view/base.rb +18 -40
- data/lib/whowish_word/backends/defer_to_i18n.rb +18 -0
- data/lib/whowish_word/backends/flat_file_store.rb +75 -0
- data/lib/whowish_word/constant.rb +1 -3
- data/lib/whowish_word/initializer.rb +10 -29
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +31 -85
- data/lib/whowish_word/whowish_word.rb +3 -6
- data/rails/Gemfile +2 -12
- data/rails/Gemfile.lock +30 -44
- data/rails/app/views/layouts/integration.html.erb +0 -1
- data/rails/config/application.rb +0 -17
- data/rails/config/boot.rb +0 -3
- data/rails/config/environment.rb +0 -9
- data/rails/config/routes.rb +0 -3
- data/rails/spec/controllers/whowish_word_controller_spec.rb +36 -10
- data/rails/spec/features/whowish_word_spec.rb +75 -0
- data/rails/spec/spec_helper.rb +15 -11
- data/rails/spec/support/browser_helper.rb +31 -0
- data/rails/spec/support/json_rspec_helper.rb +0 -3
- data/whowish_word.gemspec +4 -4
- metadata +24 -48
- data/lib/whowish_word/action_mailer/base.rb +0 -7
- data/lib/whowish_word/action_view/template.rb +0 -31
- data/lib/whowish_word/authentication.rb +0 -14
- data/lib/whowish_word/db_migration/active_record/whowish_word_html.rb +0 -15
- data/lib/whowish_word/db_migration/mongoid/whowish_word_html.rb +0 -6
- data/lib/whowish_word/rails/app/models/active_record/whowish_word_html.rb +0 -4
- data/lib/whowish_word/rails/app/models/mongoid/whowish_word_html.rb +0 -9
- data/lib/whowish_word/word_for.rb +0 -94
- data/rails/app/assets/javascripts/home2.js +0 -2
- data/rails/app/assets/javascripts/integration.js +0 -2
- data/rails/app/assets/javascripts/test_javascript.js +0 -2
- data/rails/app/assets/javascripts/test_word_for.js +0 -2
- data/rails/app/assets/stylesheets/home2.css +0 -4
- data/rails/app/assets/stylesheets/integration.css +0 -4
- data/rails/app/assets/stylesheets/test_javascript.css +0 -4
- data/rails/app/assets/stylesheets/test_word_for.css +0 -4
- data/rails/app/controllers/home2_controller.rb +0 -2
- data/rails/app/controllers/test_javascript_controller.rb +0 -11
- data/rails/app/controllers/test_word_for_controller.rb +0 -5
- data/rails/app/helpers/home2_helper.rb +0 -2
- data/rails/app/helpers/test_javascript_helper.rb +0 -2
- data/rails/app/helpers/test_word_for_helper.rb +0 -2
- data/rails/app/views/home2/index.html.erb +0 -2
- data/rails/app/views/home2/test.html.erb +0 -3
- data/rails/app/views/test_javascript/change_value.html.erb +0 -32
- data/rails/app/views/test_javascript/index.html.erb +0 -87
- data/rails/app/views/test_javascript/replace_with_html.html.erb +0 -96
- data/rails/app/views/test_word_for/_partial.html.erb +0 -5
- data/rails/app/views/test_word_for/index.html.erb +0 -9
- data/rails/config/database.yml +0 -25
- data/rails/config/mongoid.rb +0 -6
- data/rails/config/mongoid.yml +0 -14
- data/rails/db/.gitdummy +0 -0
- data/rails/mongo.bat +0 -5
- data/rails/public/jasmine/MIT.LICENSE +0 -20
- data/rails/public/jasmine/jasmine-html.js +0 -190
- data/rails/public/jasmine/jasmine.css +0 -166
- data/rails/public/jasmine/jasmine.js +0 -2476
- data/rails/public/jasmine/jasmine_favicon.png +0 -0
- data/rails/public/javascripts/jquery.loading_button.js +0 -72
- data/rails/public/sinonjs/sinonjs.js +0 -2821
- data/rails/public/test/jquery_version.html +0 -26
- data/rails/spec/integration/whowish_word_spec.rb +0 -102
- data/rails/spec/support/browser.rb +0 -194
- data/spec/spec_helper.rb +0 -19
@@ -1,16 +1,13 @@
|
|
1
1
|
require File.expand_path("../config", __FILE__)
|
2
2
|
require File.expand_path("../constant", __FILE__)
|
3
3
|
require File.expand_path("../initializer", __FILE__)
|
4
|
-
|
5
|
-
require File.expand_path("../authentication", __FILE__)
|
4
|
+
Dir[File.expand_path("../backends/**/*.rb", __FILE__)].each { |f| require f }
|
6
5
|
|
7
6
|
module WhowishWord
|
8
7
|
include WhowishWord::Constant
|
9
8
|
include WhowishWord::Initializer
|
10
|
-
include WhowishWord::WordFor
|
11
|
-
# include WhowishWord::Authentication
|
12
9
|
|
13
|
-
attr_accessor :config_file_dir
|
10
|
+
attr_accessor :config_file_dir, :backend
|
14
11
|
|
15
12
|
def init(config_file_dir = File.join(Rails.root, 'config', 'locales', 'whowish_word'))
|
16
13
|
install_route
|
@@ -18,6 +15,7 @@ module WhowishWord
|
|
18
15
|
load_rails
|
19
16
|
|
20
17
|
@config_file_dir = config_file_dir
|
18
|
+
@backend = WhowishWord::Backends::FlatFileStore
|
21
19
|
|
22
20
|
Rails.configuration.i18n.load_path = Dir[File.join(@config_file_dir, '**', '*.{rb,yml}')]
|
23
21
|
|
@@ -57,7 +55,6 @@ module WhowishWord
|
|
57
55
|
end
|
58
56
|
end
|
59
57
|
end
|
60
|
-
|
61
58
|
end
|
62
59
|
|
63
60
|
extend self
|
data/rails/Gemfile
CHANGED
@@ -1,18 +1,8 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rails', '3.2.3'
|
4
|
+
gem 'poltergeist', '1.5.0'
|
5
|
+
gem 'rspec-rails', '2.14.1'
|
4
6
|
|
5
|
-
gem 'rubyzip'
|
6
|
-
gem 'rspec-rails'
|
7
|
-
gem 'watir-webdriver-rails'
|
8
|
-
|
9
|
-
group :active_record do
|
10
|
-
gem 'sqlite3'
|
11
|
-
end
|
12
|
-
|
13
|
-
group :mongoid do
|
14
|
-
gem 'mongoid'
|
15
|
-
gem 'bson_ext'
|
16
|
-
end
|
17
7
|
|
18
8
|
|
data/rails/Gemfile.lock
CHANGED
@@ -28,35 +28,35 @@ GEM
|
|
28
28
|
activesupport (3.2.3)
|
29
29
|
i18n (~> 0.6)
|
30
30
|
multi_json (~> 1.0)
|
31
|
-
addressable (2.2.8)
|
32
31
|
arel (3.0.2)
|
33
|
-
bson (1.6.4)
|
34
|
-
bson_ext (1.6.4)
|
35
|
-
bson (~> 1.6.4)
|
36
32
|
builder (3.0.0)
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
capybara (2.2.1)
|
34
|
+
mime-types (>= 1.16)
|
35
|
+
nokogiri (>= 1.3.3)
|
36
|
+
rack (>= 1.0.0)
|
37
|
+
rack-test (>= 0.5.4)
|
38
|
+
xpath (~> 2.0)
|
39
|
+
cliver (0.3.2)
|
40
|
+
diff-lcs (1.2.5)
|
40
41
|
erubis (2.7.0)
|
41
|
-
ffi (1.0.11)
|
42
42
|
hike (1.2.1)
|
43
43
|
i18n (0.6.0)
|
44
44
|
journey (1.0.4)
|
45
45
|
json (1.7.3)
|
46
|
-
libwebsocket (0.1.3)
|
47
|
-
addressable
|
48
46
|
mail (2.4.4)
|
49
47
|
i18n (>= 0.4.0)
|
50
48
|
mime-types (~> 1.16)
|
51
49
|
treetop (~> 1.4.8)
|
52
50
|
mime-types (1.18)
|
53
|
-
|
54
|
-
bson (~> 1.6.2)
|
55
|
-
mongoid (2.4.11)
|
56
|
-
activemodel (~> 3.1)
|
57
|
-
mongo (<= 1.6.2)
|
58
|
-
tzinfo (~> 0.3.22)
|
51
|
+
mini_portile (0.5.2)
|
59
52
|
multi_json (1.3.6)
|
53
|
+
nokogiri (1.6.1)
|
54
|
+
mini_portile (~> 0.5.0)
|
55
|
+
poltergeist (1.5.0)
|
56
|
+
capybara (~> 2.1)
|
57
|
+
cliver (~> 0.3.1)
|
58
|
+
multi_json (~> 1.0)
|
59
|
+
websocket-driver (>= 0.2.0)
|
60
60
|
polyglot (0.3.3)
|
61
61
|
rack (1.4.1)
|
62
62
|
rack-cache (1.2)
|
@@ -83,50 +83,36 @@ GEM
|
|
83
83
|
rake (0.9.2.2)
|
84
84
|
rdoc (3.12)
|
85
85
|
json (~> 1.4)
|
86
|
-
rspec (2.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
rspec-
|
91
|
-
rspec-expectations (2.10.0)
|
92
|
-
diff-lcs (~> 1.1.3)
|
93
|
-
rspec-mocks (2.10.1)
|
94
|
-
rspec-rails (2.10.1)
|
86
|
+
rspec-core (2.14.7)
|
87
|
+
rspec-expectations (2.14.4)
|
88
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
89
|
+
rspec-mocks (2.14.4)
|
90
|
+
rspec-rails (2.14.1)
|
95
91
|
actionpack (>= 3.0)
|
92
|
+
activemodel (>= 3.0)
|
96
93
|
activesupport (>= 3.0)
|
97
94
|
railties (>= 3.0)
|
98
|
-
rspec (~> 2.
|
99
|
-
|
100
|
-
|
101
|
-
childprocess (>= 0.2.5)
|
102
|
-
ffi (~> 1.0)
|
103
|
-
libwebsocket (~> 0.1.3)
|
104
|
-
multi_json (~> 1.0)
|
105
|
-
rubyzip
|
95
|
+
rspec-core (~> 2.14.0)
|
96
|
+
rspec-expectations (~> 2.14.0)
|
97
|
+
rspec-mocks (~> 2.14.0)
|
106
98
|
sprockets (2.1.3)
|
107
99
|
hike (~> 1.2)
|
108
100
|
rack (~> 1.0)
|
109
101
|
tilt (~> 1.1, != 1.3.0)
|
110
|
-
sqlite3 (1.3.6)
|
111
102
|
thor (0.14.6)
|
112
103
|
tilt (1.3.3)
|
113
104
|
treetop (1.4.10)
|
114
105
|
polyglot
|
115
106
|
polyglot (>= 0.3.1)
|
116
107
|
tzinfo (0.3.33)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
watir-webdriver
|
108
|
+
websocket-driver (0.3.2)
|
109
|
+
xpath (2.0.0)
|
110
|
+
nokogiri (~> 1.3)
|
121
111
|
|
122
112
|
PLATFORMS
|
123
113
|
ruby
|
124
114
|
|
125
115
|
DEPENDENCIES
|
126
|
-
|
127
|
-
mongoid
|
116
|
+
poltergeist (= 1.5.0)
|
128
117
|
rails (= 3.2.3)
|
129
|
-
rspec-rails
|
130
|
-
rubyzip
|
131
|
-
sqlite3
|
132
|
-
watir-webdriver-rails
|
118
|
+
rspec-rails (= 2.14.1)
|
data/rails/config/application.rb
CHANGED
@@ -1,28 +1,11 @@
|
|
1
|
-
$ORM_ENGINE = :active_record
|
2
|
-
#$ORM_ENGINE = :mongoid
|
3
|
-
|
4
1
|
require File.expand_path('../boot', __FILE__)
|
5
2
|
|
6
|
-
# Pick the frameworks you want:
|
7
|
-
|
8
|
-
require "active_record/railtie"
|
9
3
|
require "action_controller/railtie"
|
10
|
-
require "action_mailer/railtie"
|
11
4
|
require "active_resource/railtie"
|
12
|
-
#require "rails/test_unit/railtie"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# If you have a Gemfile, require the gems listed there, including any gems
|
17
|
-
# you've limited to :test, :development, or :production.
|
18
|
-
Bundler.require(:default, $ORM_ENGINE, Rails.env) if defined?(Bundler)
|
19
5
|
|
20
6
|
module WhowishWordRails
|
21
|
-
|
22
7
|
class Application < Rails::Application
|
23
8
|
config.encoding = "utf-8"
|
24
|
-
config.filter_parameters += [:password]
|
25
9
|
config.active_support.deprecation = :stderr
|
26
10
|
end
|
27
|
-
|
28
11
|
end
|
data/rails/config/boot.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
# Set up gems listed in the Gemfile.
|
4
3
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
5
4
|
|
6
5
|
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
7
|
-
|
8
|
-
|
9
6
|
require File.expand_path('../../../lib/whowish_word', __FILE__)
|
data/rails/config/environment.rb
CHANGED
@@ -1,15 +1,6 @@
|
|
1
|
-
|
2
|
-
# Load the rails application
|
3
1
|
require File.expand_path('../application', __FILE__)
|
4
2
|
|
5
|
-
|
6
|
-
if $ORM_ENGINE == :mongoid
|
7
|
-
require File.expand_path('../mongoid', __FILE__)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Initialize the rails application
|
11
3
|
WhowishWordRails::Application.initialize!
|
12
|
-
|
13
4
|
WhowishWordRails::Application.config.secret_token = '81c5a4d251df513e47294d8ca73770dd43039b821f06e0a6161f93f1cbdfecd1d7e57f20ceeb6c2ce7e12e5b595c55808a403859cc4b0c324c4760bac9645bb9'
|
14
5
|
|
15
6
|
Rails.logger = Logger.new(STDOUT)
|
data/rails/config/routes.rb
CHANGED
@@ -2,18 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe WhowishWordController do
|
4
4
|
it "adds a word correctly" do
|
5
|
-
|
6
5
|
word_id = "test"
|
7
|
-
content = "Hello"
|
8
|
-
|
6
|
+
content = "Hello#{Time.now}"
|
7
|
+
|
9
8
|
post :change_word, {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
body = expect_json_response
|
9
|
+
:word_id => word_id,
|
10
|
+
:content => content
|
11
|
+
}
|
12
|
+
|
13
|
+
body = expect_json_response
|
15
14
|
body['ok'].should be_true
|
16
|
-
|
15
|
+
|
17
16
|
I18n.t(word_id.to_sym).should == content
|
18
17
|
end
|
19
|
-
|
18
|
+
|
19
|
+
context 'with successful set' do
|
20
|
+
before do
|
21
|
+
WhowishWord.backend.any_instance.should_receive(:set).and_return(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns ok: true' do
|
25
|
+
post :change_word, { :word_id => 'hi1', :content => 'hi2' }
|
26
|
+
response.body.should == '{"ok":true}'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with unsuccessful set' do
|
31
|
+
before do
|
32
|
+
WhowishWord.backend.any_instance.should_receive(:set).and_return(false)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns ok: false' do
|
36
|
+
post :change_word, { :word_id => 'hi', :content => 'hi' }
|
37
|
+
response.body.should == '{"ok":false}'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns status :unprocessable_entity' do
|
41
|
+
post :change_word, { :word_id => 'hi', :content => 'hi' }
|
42
|
+
response.status.should == 422
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'WhowishWord workflow spec' do
|
4
|
+
it "edits a normal text" do
|
5
|
+
new_text = "NormalText #{Time.now.to_i}"
|
6
|
+
|
7
|
+
visit '/integration?edit_mode=yes'
|
8
|
+
click 'whowishWordId0_____html'
|
9
|
+
fill_in "whowishWordDialogContent", :with => new_text
|
10
|
+
click "whowishWordDialogSaveButton"
|
11
|
+
wait_until { find('#whowishWordId0').should have_content(new_text) }
|
12
|
+
|
13
|
+
visit '/integration?edit_mode=yes'
|
14
|
+
wait_until { find('#whowishWordId0').should have_content(new_text) }
|
15
|
+
click 'whowishWordId0_____html'
|
16
|
+
wait_until { find('#whowishWordDialogContent').value.should == new_text }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "edits a value" do
|
20
|
+
new_text = "Value #{Time.now.to_i}"
|
21
|
+
|
22
|
+
visit '/integration/value?edit_mode=yes'
|
23
|
+
click 'whowishWordId0_____value'
|
24
|
+
fill_in "whowishWordDialogContent", :with => new_text
|
25
|
+
click "whowishWordDialogSaveButton"
|
26
|
+
wait_until { find('#whowishWordId0').value.should == new_text }
|
27
|
+
|
28
|
+
visit '/integration/value?edit_mode=yes'
|
29
|
+
wait_until { find('#whowishWordId0').value.should == new_text }
|
30
|
+
click 'whowishWordId0_____value'
|
31
|
+
wait_until { find('#whowishWordDialogContent').value.should == new_text }
|
32
|
+
end
|
33
|
+
|
34
|
+
it "edits an attribute" do
|
35
|
+
new_text = "Attribute #{Time.now.to_i}"
|
36
|
+
|
37
|
+
visit '/integration/attr?edit_mode=yes'
|
38
|
+
click 'whowishWordId0_____title'
|
39
|
+
fill_in "whowishWordDialogContent", :with => new_text
|
40
|
+
click "whowishWordDialogSaveButton"
|
41
|
+
wait_until { find('#whowishWordId0')[:title].should == new_text }
|
42
|
+
|
43
|
+
visit '/integration/attr?edit_mode=yes'
|
44
|
+
wait_until { find('#whowishWordId0')[:title].should == new_text }
|
45
|
+
click 'whowishWordId0_____title'
|
46
|
+
wait_until { find("#whowishWordDialogContent").value.should == new_text }
|
47
|
+
end
|
48
|
+
|
49
|
+
it "edits an option" do
|
50
|
+
new_text = "OptionText#{Time.now.to_i}"
|
51
|
+
new_value = "OptionValue#{Time.now.to_i}"
|
52
|
+
|
53
|
+
visit '/integration/select?edit_mode=yes'
|
54
|
+
click 'whowishWordId0_____value'
|
55
|
+
fill_in "whowishWordDialogContent", :with => new_value
|
56
|
+
click "whowishWordDialogSaveButton"
|
57
|
+
wait_until { find('#whowishWordId0').value.should == new_value }
|
58
|
+
|
59
|
+
click 'whowishWordId0_____text'
|
60
|
+
fill_in "whowishWordDialogContent", :with => new_text
|
61
|
+
click "whowishWordDialogSaveButton"
|
62
|
+
wait_until { find('#whowishWordId0').text.should == new_text }
|
63
|
+
|
64
|
+
visit '/integration/select?edit_mode=yes'
|
65
|
+
wait_until { find('#whowishWordId0').value.should == new_value }
|
66
|
+
click 'whowishWordId0_____value'
|
67
|
+
wait_until { find("#whowishWordDialogContent").value.should == new_value }
|
68
|
+
click 'whowishWordDialogCloseButton'
|
69
|
+
|
70
|
+
wait_until { find('#whowishWordId0').text.should == new_text }
|
71
|
+
click 'whowishWordId0_____text'
|
72
|
+
wait_until { find("#whowishWordDialogContent").value.should == new_text }
|
73
|
+
click 'whowishWordDialogCloseButton'
|
74
|
+
end
|
75
|
+
end
|
data/rails/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
1
|
ENV["RAILS_ENV"] ||= 'test'
|
5
2
|
|
3
|
+
require 'rubygems'
|
6
4
|
require File.expand_path("../../config/environment", __FILE__)
|
7
|
-
|
8
5
|
require 'rspec/rails'
|
9
|
-
require '
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
require 'capybara/rspec'
|
7
|
+
require 'capybara/poltergeist'
|
8
|
+
|
9
|
+
Capybara.run_server = true
|
10
|
+
Capybara.register_driver :poltergeist do |app|
|
11
|
+
Capybara::Poltergeist::Driver.new(app, {
|
12
|
+
:debug => false,
|
13
|
+
:js_errors => true,
|
14
|
+
})
|
15
|
+
end
|
16
|
+
Capybara.default_driver = :poltergeist
|
17
|
+
Capybara.default_wait_time = 5
|
13
18
|
|
14
|
-
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f}
|
19
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
|
15
20
|
|
16
21
|
RSpec.configure do |config|
|
17
|
-
config.include Browser
|
18
22
|
config.include JsonRspecHelper
|
19
|
-
|
23
|
+
config.include BrowserHelper
|
20
24
|
config.mock_with :rspec
|
21
25
|
end
|
22
26
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module BrowserHelper
|
2
|
+
def click(id)
|
3
|
+
wait_until { find("##{id}").should be_visible }
|
4
|
+
find("##{id}").click
|
5
|
+
end
|
6
|
+
|
7
|
+
# Hacky way to wait for AJAX because we need a very customized matchers
|
8
|
+
# We shouldn't be using this, but I cannot make it work
|
9
|
+
def wait_until(&block)
|
10
|
+
count = 0
|
11
|
+
while true
|
12
|
+
begin
|
13
|
+
block.call
|
14
|
+
return
|
15
|
+
rescue => e
|
16
|
+
if count < 30 # Timeout in 3 seconds
|
17
|
+
count += 1
|
18
|
+
sleep(0.1)
|
19
|
+
retry
|
20
|
+
else
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def snap
|
28
|
+
@screenshot_number ||= 0
|
29
|
+
page.save_screenshot("tmp/poltergeist_#{@screenshot_number += 1}.png", :full => true)
|
30
|
+
end
|
31
|
+
end
|