Module: Charming::Generators::AppGenerator::AppSpecTemplates
- Included in:
- Charming::Generators::AppGenerator
- Defined in:
- lib/charming/generators/app_generator/app_spec_templates.rb
Instance Method Summary collapse
Instance Method Details
#spec_component ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/charming/generators/app_generator/app_spec_templates.rb', line 72 def spec_component %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe #{app_name.class_name}::AppFrameComponent do describe "#render" do it "returns a string" do component = described_class.new(title: "#{app_name.class_name}") expect(component.render).to be_a(String) end end end ) end |
#spec_controller ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/charming/generators/app_generator/app_spec_templates.rb', line 28 def spec_controller %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe #{app_name.class_name}::HomeController do let(:application) { #{app_name.class_name}::Application.new } subject(:controller) { described_class.new(application: application) } describe "#show" do it "renders the view with the state" do response = controller.dispatch(:show) expect(response).to respond_to(:body) end end end ) end |
#spec_state ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/charming/generators/app_generator/app_spec_templates.rb', line 7 def spec_state %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe #{app_name.class_name}::HomeState do describe "#title" do it "has the correct default string value" do instance = described_class.new expect(instance.title).to eq("#{app_name.class_name}") end it "accepts overridden title values" do instance = described_class.new(title: "Alternative") expect(instance.title).to eq("Alternative") end end end ) end |
#spec_view ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/charming/generators/app_generator/app_spec_templates.rb', line 49 def spec_view %(# frozen_string_literal: true require "#{app_name.snake_name}" RSpec.describe "home/show template" do describe "#render" do it "renders the state title" do template = Charming::Presentation::Templates.resolve("home/show", root: #{app_name.class_name}::Application.root) view = Charming::Presentation::TemplateView.new( template: template, namespace: #{app_name.class_name}, home: double(title: "#{app_name.class_name}"), theme: #{app_name.class_name}::Application.new.theme ) expect(view.render).to include("#{app_name.class_name}") end end end ) end |