Skip to content

Commit

Permalink
Adding the first routing specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
daronco committed Jul 24, 2011
1 parent 285004e commit b2fec6e
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -33,8 +33,10 @@ gem 'therubyracer', :require => 'v8'
group :development, :test do
gem 'rspec-rails', '~> 2.6'
gem 'rspec-instafail'
gem 'fuubar'
gem 'shoulda-matchers'
gem 'cucumber-rails', '~> 0.5.0'
gem 'database_cleaner'
gem 'factory_girl'
gem 'forgery'
end
9 changes: 9 additions & 0 deletions Gemfile.lock
Expand Up @@ -97,7 +97,13 @@ GEM
multi_json (~> 1.0)
factory_girl (2.0.1)
ffi (1.0.9)
forgery (0.3.12)
nokogiri (~> 1.4)
fssm (0.2.7)
fuubar (0.0.5)
rspec (~> 2.0)
rspec-instafail (~> 0.1.4)
ruby-progressbar (~> 0.0.10)
gherkin (2.4.5)
json (>= 1.4.6)
hike (1.1.0)
Expand Down Expand Up @@ -157,6 +163,7 @@ GEM
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
ruby-progressbar (0.0.10)
rubyzip (0.9.4)
sass (3.1.2)
selenium-webdriver (0.2.2)
Expand Down Expand Up @@ -202,6 +209,8 @@ DEPENDENCIES
database_cleaner
devise
factory_girl
forgery
fuubar
jquery-rails
json
rails (~> 3.1.0.rc1)
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -12,7 +12,7 @@ require 'rake'
desc 'Default: run specs and features.'
task :default => [:spec, :cucumber]

RSpec::Core::RakeTask.new(:spec => ["db:test:prepare"])
#RSpec::Core::RakeTask.new(:spec => ["db:test:prepare"])
#RSpec::Core::RakeTask.new(:spec => ["db:test:prepare", "db:seed"]) # to run dependencies first

BigbluebuttonRailsPlayground::Application.load_tasks
105 changes: 105 additions & 0 deletions spec/routing/custom_rooms_routing_spec.rb
@@ -0,0 +1,105 @@
require 'spec_helper'

describe CustomRoomsController do
include Shoulda::Matchers::ActionController

describe "routing" do

# standard routes generated by bigbluebutton_rails
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms").
to(:action => :index, :server_id => "server-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/new").
to(:action => :new, :server_id => "server-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/external").
to(:action => :external, :server_id => "server-1")
}
it {
should route(:post, "/bigbluebutton/servers/server-1/rooms/external").
to(:action => :external_auth, :server_id => "server-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/edit").
to(:action => :edit, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1").
to(:action => :show, :server_id => "server-1", :id => "room-1")
}
it {
should route(:put, "/bigbluebutton/servers/server-1/rooms/room-1").
to(:action => :update, :server_id => "server-1", :id => "room-1")
}
it {
should route(:delete, "/bigbluebutton/servers/server-1/rooms/room-1").
to(:action => :destroy, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/join").
to(:action => :join, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/join_mobile").
to(:action => :join_mobile, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/running").
to(:action => :running, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/end").
to(:action => :end, :server_id => "server-1", :id => "room-1")
}
it {
should route(:get, "/bigbluebutton/servers/server-1/rooms/room-1/invite").
to(:action => :invite, :server_id => "server-1", :id => "room-1")
}
it {
should route(:post, "/bigbluebutton/servers/server-1/rooms/room-1/join").
to(:action => :auth, :server_id => "server-1", :id => "room-1")
}

# bigbluebutton_rails room matchers inside 'user'
it {
should route(:get, "/users/1/room/room-1").
to(:action => :show, :user_id => "1", :id => "room-1")
}
it {
should route(:get, "/users/1/room/room-1/join").
to(:action => :join, :user_id => "1", :id => "room-1")
}
it {
should route(:get, "/users/1/room/room-1/join_mobile").
to(:action => :join_mobile, :user_id => "1", :id => "room-1")
}
it {
should route(:get, "/users/1/room/room-1/running").
to(:action => :running, :user_id => "1", :id => "room-1")
}
it {
should route(:get, "/users/1/room/room-1/end").
to(:action => :end, :user_id => "1", :id => "room-1")
}
it {
should route(:get, "/users/1/room/room-1/invite").
to(:action => :invite, :user_id => "1", :id => "room-1")
}
it {
should route(:post, "/users/1/room/room-1/join").
to(:action => :auth, :user_id => "1", :id => "room-1")
}

# our custom routes added to /users/
it {
should route(:get, "/users/1/new_room").
to(:action => :user_new, :user_id => "1")
}

end

end

18 changes: 18 additions & 0 deletions spec/routing/custom_servers_routing_spec.rb
@@ -0,0 +1,18 @@
require 'spec_helper'

describe CustomServersController do
include Shoulda::Matchers::ActionController

# standard routes generated by bigbluebutton_rails
describe "routing" do
it { should route(:get, "/bigbluebutton/servers").to(:action => :index) }
it { should route(:post, "/bigbluebutton/servers").to(:action => :create) }
it { should route(:get, "/bigbluebutton/servers/new").to(:action => :new) }
it { should route(:get, "/bigbluebutton/servers/server-1/edit").to(:action => :edit, :id => "server-1") }
it { should route(:get, "/bigbluebutton/servers/server-1").to(:action => :show, :id => "server-1") }
it { should route(:put, "/bigbluebutton/servers/server-1").to(:action => :update, :id => "server-1") }
it { should route(:delete, "/bigbluebutton/servers/server-1").to(:action => :destroy, :id => "server-1") }
end

end

12 changes: 12 additions & 0 deletions spec/routing/home_routing_spec.rb
@@ -0,0 +1,12 @@
require 'spec_helper'

describe HomeController do
include Shoulda::Matchers::ActionController

describe "routing" do
pending { should route(:get, "/").to(:action => :index) }
it { should route(:get, "/home/index").to(:action => :index) }
end

end

3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -2,6 +2,7 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require "shoulda-matchers"

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Expand All @@ -22,7 +23,7 @@
config.mock_with :rspec

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shoulda/accept_nested_attributes_for.rb
@@ -1,6 +1,6 @@
module Shoulda
module Matchers
module ActiveRecord # :nodoc
module ActiveModel # :nodoc

# Usage example: accept_nested_attributes_for(:address)
def accept_nested_attributes_for(attribute)
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shoulda/have_attr_accessor.rb
Expand Up @@ -5,7 +5,7 @@
# it { should have_attr_accessor(:value).write_only }
module Shoulda
module Matchers
module ActiveRecord # :nodoc
module ActiveModel # :nodoc

def have_attr_accessor(attribute)
HaveAttrAccessorMatcher.new(attribute)
Expand Down

0 comments on commit b2fec6e

Please sign in to comment.