Created
January 29, 2013 10:51
-
-
Save lazyatom/4663437 to your computer and use it in GitHub Desktop.
An example of action usage in Kintama
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe ThingController do | |
describe "creating a thing" do | |
action { post :create, attributes } | |
describe "when not logged in" do | |
it "should redirect to login" do | |
assert_redirected_to login_path | |
end | |
end | |
describe "when logged in" do | |
setup do | |
@user = stub(:user) | |
login_as(@user) | |
end | |
describe "with valid attributes" do | |
let(:attributes) { {name: "thing-name"} } | |
it "should return a 200" do | |
assert_response 200 | |
end | |
it "should create the thing" do | |
assert_equal 1, Thing.count | |
assert_equal 'thing-name', Thing.first.name | |
end | |
end | |
describe "with invalid attributes" do | |
let(:attributes) { {name: ''} } | |
it "should return a 406" do | |
assert_response 406 | |
end | |
it "should not create a thing" do | |
assert_equal 0, Thing.count | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment