Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.1"?>
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 3.0 Language//EN"
"http://www.w3.org/2008/SMIL30/SMIL30Language.dtd">
<smil xmlns="http://www.w3.org/ns/SMIL" version="3.0" baseProfile="Language">
<head>
<layout>
<root-layout width="150" height="200"/>
<region xml:id="b" left="0" width="150" top="0" height="150" backgroundColor="purple"/>
<region xml:id="t" left="0" width="150" top="150" height="50"/>
</layout>`
def self.role_perms(role_name)
if role_name == :anybody
"return true"
else
"user.acts_as_if? '#{role_name}'"
end
end
def self.access_func(method_name, info)
with_existing :article do
on_visiting edit_article_path do
it { lets_me_edit_the(:article) }
it { shows_failure_on_invalid_update_of(:article) }
end
where it_is_unpublished do
on_visiting articles_path do
specify { page.should_not have_content(@article.name) }
end
Scenario: Search by topic
Given there are 240 courses which do not have the topic "biology"
And there are 2 courses A001, B205 that each have "biology" as one of the topics
When I search for "biology"
Then I should see the following courses:
| Course code |
| A001 |
| B205 |
Scenario: Search by topic
Given a topic exists
And some courses exist covering that topic
And other courses exist that do not cover the topic
When I search for that topic
Then I should see the courses that cover the topic
And I should not see the courses that do not cover the topic
with_existing :user do
on_visiting edit_user_path do
it {should let_me_edit_the_user}
end
end
context "when a user exists" do
before { @user = Factory :user }
context "when I visit the page for editing that user" do
before { visit "/users/#{@user.id}/edit" }
it {should let_me_edit_the_user}
end
end
def creating_a_user
@user = Factory.build @user
fill_in "user[email]", :with => @user.email
click_button "Create"
end
on_following_link_to new_user_path do
where :creating_a_user do
specify { page.should have_content(@user.email) }
end
@ludicast
ludicast / backbone_tunes.coffee
Created November 5, 2011 02:14
translation into coffeescript of code for backbone.js peepcode
window.Album = Backbone.Model.extend
isFirstTrack: (index)->
index == 0
isLastTrack: (index)->
index >= @get('tracks').length - 1
trackUrlAtIndex: (index)->
if @get('tracks').length > index
@get('tracks')[index].url
else
null
@ludicast
ludicast / Tunes.coffee
Created November 28, 2011 00:43
Coffeescript conversion of peepcode-tunes for angularjs
class @TunesCtrl
constructor:($xhr)->
@player = @$parent.$new Player
$xhr 'GET', 'albums.json', (statusCode, body)=>
@albums = body
TunesCtrl.$inject = ['$xhr']
class @Player
constructor:(@$audio)->