bigbluebutton_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/.gitignore +2 -1
  2. data/CHANGELOG.rdoc +12 -0
  3. data/Gemfile.lock +53 -14
  4. data/README.rdoc +31 -29
  5. data/Rakefile +63 -11
  6. data/app/controllers/bigbluebutton/rooms_controller.rb +89 -26
  7. data/app/controllers/bigbluebutton/servers_controller.rb +38 -5
  8. data/app/helpers/bigbluebutton_rails_helper.rb +12 -0
  9. data/app/models/bigbluebutton_room.rb +44 -1
  10. data/app/models/bigbluebutton_server.rb +48 -12
  11. data/app/views/bigbluebutton/rooms/_form.html.erb +8 -0
  12. data/app/views/bigbluebutton/rooms/index.html.erb +34 -43
  13. data/app/views/bigbluebutton/rooms/join_mobile.html.erb +9 -0
  14. data/app/views/bigbluebutton/rooms/show.html.erb +8 -0
  15. data/app/views/bigbluebutton/servers/_activity_list.html.erb +48 -0
  16. data/app/views/bigbluebutton/servers/_form.html.erb +4 -0
  17. data/app/views/bigbluebutton/servers/activity.html.erb +51 -0
  18. data/app/views/bigbluebutton/servers/index.html.erb +21 -25
  19. data/app/views/bigbluebutton/servers/show.html.erb +5 -0
  20. data/bigbluebutton_rails.gemspec +9 -6
  21. data/config/locales/en.yml +11 -2
  22. data/lib/bigbluebutton_rails/controller_methods.rb +47 -14
  23. data/lib/bigbluebutton_rails/exceptions.rb +6 -0
  24. data/lib/bigbluebutton_rails/rails/routes.rb +17 -12
  25. data/lib/bigbluebutton_rails/rails.rb +4 -0
  26. data/lib/bigbluebutton_rails/version.rb +1 -1
  27. data/lib/bigbluebutton_rails.rb +1 -0
  28. data/lib/generators/bigbluebutton_rails/install_generator.rb +28 -5
  29. data/lib/generators/bigbluebutton_rails/templates/migration.rb +3 -0
  30. data/lib/generators/bigbluebutton_rails/templates/migration_0_0_4.rb +38 -0
  31. data/lib/generators/bigbluebutton_rails/templates/migration_0_0_5.rb +23 -0
  32. data/{lib/generators/bigbluebutton_rails/templates/public → public}/images/loading.gif +0 -0
  33. data/{lib/generators/bigbluebutton_rails/templates/public → public}/javascripts/jquery.min.js +0 -0
  34. data/public/stylesheets/bigbluebutton_rails.css +138 -0
  35. data/spec/controllers/bigbluebutton/rooms_controller_spec.rb +284 -25
  36. data/spec/controllers/bigbluebutton/servers_controller_spec.rb +93 -1
  37. data/spec/factories/bigbluebutton_room.rb +1 -0
  38. data/spec/factories/bigbluebutton_server.rb +1 -0
  39. data/spec/factories/integration/bigbluebutton_server_integration.rb +8 -0
  40. data/spec/generators/install_generator_spec.rb +53 -10
  41. data/spec/generators/views_generator_spec.rb +6 -2
  42. data/spec/helpers/bigbluebutton_rails_helper_spec.rb +19 -0
  43. data/spec/integration_conf.yml.example +5 -0
  44. data/spec/models/bigbluebutton_room_spec.rb +99 -72
  45. data/spec/models/bigbluebutton_server_spec.rb +81 -20
  46. data/spec/rails_app/.gitignore +2 -1
  47. data/spec/rails_app/app/views/layouts/application.html.erb +1 -1
  48. data/spec/rails_app/config/cucumber.yml +8 -0
  49. data/spec/rails_app/config/database.yml +4 -1
  50. data/spec/rails_app/db/seeds.rb +6 -5
  51. data/spec/rails_app/features/manage_bigbluebutton_rooms.feature +9 -0
  52. data/spec/rails_app/features/manage_bigbluebutton_servers.feature +9 -0
  53. data/spec/rails_app/features/step_definitions/bigbluebutton_room_steps.rb +38 -0
  54. data/spec/rails_app/features/step_definitions/bigbluebutton_server_steps.rb +23 -0
  55. data/spec/rails_app/features/step_definitions/common_steps.rb +3 -0
  56. data/spec/rails_app/features/step_definitions/web_steps.rb +211 -0
  57. data/spec/rails_app/features/support/content.rb +11 -0
  58. data/spec/rails_app/features/support/env.rb +50 -0
  59. data/spec/rails_app/features/support/env_gem.rb +9 -0
  60. data/spec/rails_app/features/support/paths.rb +38 -0
  61. data/spec/rails_app/features/support/selectors.rb +39 -0
  62. data/spec/rails_app/lib/tasks/cucumber.rake +65 -0
  63. data/spec/rails_app/public/images/loading.gif +0 -0
  64. data/spec/rails_app/public/javascripts/jquery.min.js +16 -0
  65. data/spec/rails_app/public/stylesheets/bigbluebutton_rails.css +138 -0
  66. data/spec/rails_app/script/cucumber +10 -0
  67. data/spec/routing/bigbluebutton/rooms_routing_spec.rb +12 -0
  68. data/spec/spec_helper.rb +0 -1
  69. data/spec/support/integration/integration_conf.rb +16 -0
  70. data/spec/support/matchers/shoulda/respond_with_json_matcher.rb +67 -0
  71. data/spec/support/mocked_server.rb +1 -0
  72. metadata +91 -29
  73. data/lib/generators/bigbluebutton_rails/public_generator.rb +0 -16
  74. data/spec/generators/public_generator_spec.rb +0 -31
@@ -0,0 +1,211 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
20
+
21
+
22
+ require 'uri'
23
+ require 'cgi'
24
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
+
27
+ module WithinHelpers
28
+ def with_scope(locator)
29
+ locator ? within(*selector_for(locator)) { yield } : yield
30
+ end
31
+ end
32
+ World(WithinHelpers)
33
+
34
+ # Single-line step scoper
35
+ When /^(.*) within (.*[^:])$/ do |step, parent|
36
+ with_scope(parent) { When step }
37
+ end
38
+
39
+ # Multi-line step scoper
40
+ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
41
+ with_scope(parent) { When "#{step}:", table_or_string }
42
+ end
43
+
44
+ Given /^(?:|I )am on (.+)$/ do |page_name|
45
+ visit path_to(page_name)
46
+ end
47
+
48
+ When /^(?:|I )go to (.+)$/ do |page_name|
49
+ visit path_to(page_name)
50
+ end
51
+
52
+ When /^(?:|I )press "([^"]*)"$/ do |button|
53
+ click_button(button)
54
+ end
55
+
56
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
57
+ click_link(link)
58
+ end
59
+
60
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
61
+ fill_in(field, :with => value)
62
+ end
63
+
64
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
65
+ fill_in(field, :with => value)
66
+ end
67
+
68
+ # Use this to fill in an entire form with data from a table. Example:
69
+ #
70
+ # When I fill in the following:
71
+ # | Account Number | 5002 |
72
+ # | Expiry date | 2009-11-01 |
73
+ # | Note | Nice guy |
74
+ # | Wants Email? | |
75
+ #
76
+ # TODO: Add support for checkbox, select og option
77
+ # based on naming conventions.
78
+ #
79
+ When /^(?:|I )fill in the following:$/ do |fields|
80
+ fields.rows_hash.each do |name, value|
81
+ When %{I fill in "#{name}" with "#{value}"}
82
+ end
83
+ end
84
+
85
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
86
+ select(value, :from => field)
87
+ end
88
+
89
+ When /^(?:|I )check "([^"]*)"$/ do |field|
90
+ check(field)
91
+ end
92
+
93
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
94
+ uncheck(field)
95
+ end
96
+
97
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
98
+ choose(field)
99
+ end
100
+
101
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
102
+ attach_file(field, File.expand_path(path))
103
+ end
104
+
105
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
106
+ if page.respond_to? :should
107
+ page.should have_content(text)
108
+ else
109
+ assert page.has_content?(text)
110
+ end
111
+ end
112
+
113
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
114
+ regexp = Regexp.new(regexp)
115
+
116
+ if page.respond_to? :should
117
+ page.should have_xpath('//*', :text => regexp)
118
+ else
119
+ assert page.has_xpath?('//*', :text => regexp)
120
+ end
121
+ end
122
+
123
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
124
+ if page.respond_to? :should
125
+ page.should have_no_content(text)
126
+ else
127
+ assert page.has_no_content?(text)
128
+ end
129
+ end
130
+
131
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
132
+ regexp = Regexp.new(regexp)
133
+
134
+ if page.respond_to? :should
135
+ page.should have_no_xpath('//*', :text => regexp)
136
+ else
137
+ assert page.has_no_xpath?('//*', :text => regexp)
138
+ end
139
+ end
140
+
141
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
142
+ with_scope(parent) do
143
+ field = find_field(field)
144
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
145
+ if field_value.respond_to? :should
146
+ field_value.should =~ /#{value}/
147
+ else
148
+ assert_match(/#{value}/, field_value)
149
+ end
150
+ end
151
+ end
152
+
153
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
154
+ with_scope(parent) do
155
+ field = find_field(field)
156
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
157
+ if field_value.respond_to? :should_not
158
+ field_value.should_not =~ /#{value}/
159
+ else
160
+ assert_no_match(/#{value}/, field_value)
161
+ end
162
+ end
163
+ end
164
+
165
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
166
+ with_scope(parent) do
167
+ field_checked = find_field(label)['checked']
168
+ if field_checked.respond_to? :should
169
+ field_checked.should be_true
170
+ else
171
+ assert field_checked
172
+ end
173
+ end
174
+ end
175
+
176
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
177
+ with_scope(parent) do
178
+ field_checked = find_field(label)['checked']
179
+ if field_checked.respond_to? :should
180
+ field_checked.should be_false
181
+ else
182
+ assert !field_checked
183
+ end
184
+ end
185
+ end
186
+
187
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
188
+ current_path = URI.parse(current_url).path
189
+ if current_path.respond_to? :should
190
+ current_path.should == path_to(page_name)
191
+ else
192
+ assert_equal path_to(page_name), current_path
193
+ end
194
+ end
195
+
196
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
197
+ query = URI.parse(current_url).query
198
+ actual_params = query ? CGI.parse(query) : {}
199
+ expected_params = {}
200
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
201
+
202
+ if actual_params.respond_to? :should
203
+ actual_params.should == expected_params
204
+ else
205
+ assert_equal expected_params, actual_params
206
+ end
207
+ end
208
+
209
+ Then /^show me the page$/ do
210
+ save_and_open_page
211
+ end
@@ -0,0 +1,11 @@
1
+ module ContentHelpers
2
+ def page_has_content(text)
3
+ if page.respond_to? :should
4
+ page.should have_content(text)
5
+ else
6
+ assert page.has_content?(text)
7
+ end
8
+ end
9
+ end
10
+
11
+ World(ContentHelpers)
@@ -0,0 +1,50 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ require 'cucumber/rails'
8
+
9
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
10
+ # order to ease the transition to Capybara we set the default here. If you'd
11
+ # prefer to use XPath just remove this line and adjust any selectors in your
12
+ # steps to use the XPath syntax.
13
+ Capybara.default_selector = :css
14
+
15
+ # By default, any exception happening in your Rails application will bubble up
16
+ # to Cucumber so that your scenario will fail. This is a different from how
17
+ # your application behaves in the production environment, where an error page will
18
+ # be rendered instead.
19
+ #
20
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
21
+ # exceptions and display an error page (just like when the app is running in production).
22
+ # Typical scenarios where you want to do this is when you test your error pages.
23
+ # There are two ways to allow Rails to rescue exceptions:
24
+ #
25
+ # 1) Tag your scenario (or feature) with @allow-rescue
26
+ #
27
+ # 2) Set the value below to true. Beware that doing this globally is not
28
+ # recommended as it will mask a lot of errors for you!
29
+ #
30
+ ActionController::Base.allow_rescue = false
31
+
32
+ # Remove/comment out the lines below if your app doesn't have a database.
33
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
34
+ begin
35
+ DatabaseCleaner.strategy = :transaction
36
+ rescue NameError
37
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
38
+ end
39
+
40
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
41
+ # See the DatabaseCleaner documentation for details. Example:
42
+ #
43
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
44
+ # DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
45
+ # end
46
+ #
47
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
48
+ # DatabaseCleaner.strategy = :transaction
49
+ # end
50
+ #
@@ -0,0 +1,9 @@
1
+ # Load the environment to test the gem bigbluebutton_rails using cucumber
2
+
3
+ # Load support files
4
+ Dir["#{File.dirname(__FILE__)}/../../../support/integration/**/*.rb"].each { |f| require f }
5
+
6
+ # Load the factories in the gem spec/factories folder
7
+ require 'factory_girl'
8
+ require 'forgery'
9
+ Dir["#{ File.dirname(__FILE__)}/../../../factories/**/*.rb"].each { |f| require f }
@@ -0,0 +1,38 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /^the home\s?$/
12
+ '/'
13
+ when /the new bigbluebutton server/i
14
+ new_bigbluebutton_server_path
15
+ when /the new bigbluebutton room/i
16
+ new_bigbluebutton_server_room_path(@server)
17
+
18
+
19
+ # Add more mappings here.
20
+ # Here is an example that pulls values out of the Regexp:
21
+ #
22
+ # when /^(.*)'s profile page$/i
23
+ # user_profile_path(User.find_by_login($1))
24
+
25
+ else
26
+ begin
27
+ page_name =~ /^the (.*) page$/
28
+ path_components = $1.split(/\s+/)
29
+ self.send(path_components.push('path').join('_').to_sym)
30
+ rescue NoMethodError, ArgumentError
31
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
32
+ "Now, go and add a mapping in #{__FILE__}"
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ World(NavigationHelpers)
@@ -0,0 +1,39 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when "the page"
12
+ "html > body"
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^the (notice|error|info) flash$/
18
+ # ".flash.#{$1}"
19
+
20
+ # You can also return an array to use a different selector
21
+ # type, like:
22
+ #
23
+ # when /the header/
24
+ # [:xpath, "//header"]
25
+
26
+ # This allows you to provide a quoted selector as the scope
27
+ # for "within" steps as was previously the default for the
28
+ # web steps:
29
+ when /^"(.+)"$/
30
+ $1
31
+
32
+ else
33
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
34
+ "Now, go and add a mapping in #{__FILE__}"
35
+ end
36
+ end
37
+ end
38
+
39
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,65 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+
38
+ task :statsetup do
39
+ require 'rails/code_statistics'
40
+ ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
41
+ ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
42
+ end
43
+ end
44
+ desc 'Alias for cucumber:ok'
45
+ task :cucumber => 'cucumber:ok'
46
+
47
+ task :default => :cucumber
48
+
49
+ task :features => :cucumber do
50
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
51
+ end
52
+
53
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
54
+ task 'db:test:prepare' do
55
+ end
56
+
57
+ task :stats => 'cucumber:statsetup'
58
+ rescue LoadError
59
+ desc 'cucumber rake task not available (cucumber not installed)'
60
+ task :cucumber do
61
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
62
+ end
63
+ end
64
+
65
+ end